This is O.R.Senthil Kumaran's blogspot on programming and technical things. The title is a line from "Zen of Python".
sudo NOPASSWD in ubuntu
1. sudo visudo
2. Go to the last line and add
username ALL=(ALL) NOPASSWD: ALL
I could not change the default editor to use vim by exporting the EDITOR variable. I had to use nano only, which has some quirks like it asks you the save in DOS Format or Mac Format ( I choose Mac). Btw, while using uxterm, you cannot use nano editor, because the Meta key is bound by uxterm and you wont be able to save it. I had to xfce4-terminal to do the first step. Phew!
Installing VirtualBox Guest additions on Ubuntu Guest
Virtualbox Tip (Ubuntu Host, Windows Guest)
Accessing a Shared Folder from a Windows Guest
- net use
: \\vboxsvr\
where
C:\Users\vbox> net use s: \\vboxsrv\TempFiles The command completed successfully.
My Ubuntu Install
- Install Ubuntu using Ubuntu mini iso
- sudo aptitude install xorg
- sudo aptitude install ratpoison
- sudo aptitude install build-essential checkinstall
- sudo aptitude install vim
- sudo aptitude install subversion
- sudo aptitude install chromium-browser
- sudo aptitude install mutt
- sudo aptitude install ssh
- sudo aptitude install socat
- sudo aptitude install msmtp
- sudo aptitude install fetchmail
- sudo aptitude install virtualbox-ose
- sudo aptitude install flashplugin-nonfree
- sudo aptitude install openssl ca-certificates
- sudo aptitude install procmail and follow http://ubuntuforums.org/showthread.php?t=565326
- sudo aptitude install alsa and alsactl init
- sudo aptitude install xfonts-terminus-oblique xfonts-terminus-dos xfonts-terminus console-terminus
- sudo aptitude install irssi
- sudo aptitude install ttf-inconsolata
- sudo aptitude install fortune fortunes
- search and run google-repo-setup.sh
- sudo aptitude install picasa
- sudo aptitude install cowsay xcowsay
- sudo visudo and then write senthil ALL=NOPASSWD: ALL
- sudo aptitude install urlview
- sudo aptitude install xscreensaver xscreensaver-data
Making xterm beautiful
Do the following steps.
sudo aptitude install ttf-inconsolata
Open your .Xresources file and type
XTerm*faceName: Inconsolata
XTerm*faceSize: 16
Do an
xrdb -merge .Xresources
Thanks to levin, this answered my question on "What's there in a font and why are so many of them?" very well.
Cyanogen Mod Upgrade on ADP2
Dimension (LxWxTmm) 113 x 55.56 x 14.65
Display Size 3.17
HVGA Resolution
Capacitive touch screen
512MB FLASH Memory
192MB RAM
MSM7200A,528MHz chipset
GSM/GPRS/EDGE Quad band
850/900/1800/1900 MHz
WCDMA 1700/2100 MHz : BC4
2100 MHz : BC1
HSPA Speed HSDPA 7.2 Mbps
HSUPA 2 Mbps
Blutooth 2.0 with EDR
WiFi 802.11b/g
3MP Auto Focus Camera
1340 Battery(mAh)
microSD Memory Slot
USB 2.0
GPS/AGPS
Mailing list
----
ADP2 is SAPPHIRE PVT 32B DEV S-ON G
HBOOT-1.33.3007 (SAPP30000)
CPLD-10
RADIO-2.22.19.26I
Sep 25 2009, 16:22:56
----
PVT32B handsets have 192MB total RAM (96MB usable by OS) and use the Qualcomm MSM7201A CPU.
----
Follow the instructions here:
http://wiki.cyanogenmod.com/index.php?title=Full_Update_Guide_-_HTC_Magic_(32B)
startopenbox
This is what my settings are. I do a startopenbox.sh to load the second window manager.
File: openbox.xinitrc
xrdb -load $HOME/.Xresources xsetroot -solid gray & feh --bg-scale /home/senthil/sentosa.jpg & xclock -g 50x50-0+0 -bw 0 & xterm & openbox
File: startopenbox.sh
#!/bin/bash xinit ./openbox.xinitrc -display :1 -- :1 2>/dev/null &
Any Advice for young programmers ?
Read More http://www.wired.com/thisdayintech/2010/10/1014cplusplus-released/all/1#ixzz12dSGVsJC
Bjarne Stroustrup's old interview
Stroustrup: I'm suffering from having successfully completed a very large project. The ISO C++ standard is done. The third edition of The C++ Programming Language is there to acquaint serious programmers with what Standard C++ has to offer and how best to use it. And The Design and Evolution documents the design decisions that shaped C++. There is more to be done, but nothing that requires a full-time language designer. Now is the time to enjoy the flexibility and power of C++ by writing code, rather than focusing on possible changes.
Apart from that, I'm taking the opportunity to learn a few things-a couple of new languages and something about how software is used in a large business-and planning some experiments in distributed computing.
C++ Standard Library
Stroustrup: The most novel and interesting part of the standard library is the general and extensible framework for containers and algorithms. It is often called the STL and is primarily the work of Alex Stepanov (then at Hewlett-Packard Labs, now at Silicon Graphics).
Alex worked on providing uncompromisingly general and uncompromisingly efficient fundamental algorithms which, for example, find an element in a data structure, sort a container, or count the occurrences of a value in a data structure. Such algorithms are fundamental to much computing.
recording script using recordmydesktop command
#!/bin/bash # # Warning: this does not have robust error checking! bad=67 if [ $# -lt 1 ] then echo "Usage: $0 [filename] [[optional time]]" exit $bad fi if [ $# -eq 1 ] #check for arguments then time=3 #if one (only filename) exists, sleep for 3 seconds filename=$1 #set filename else time=$2 #else, we'll sleep for $2 seconds filename=$1 #set filename fi recordmydesktop -windowid `xwininfo |grep "Window id:"|sed -e "s/xwininfo\:\ Window id:\ //;s/\ .*//"` -o $filename.ogv -delay $time --no-sound ffmpeg -i $filename.ogv -b 384000 -s 640x480 -pass 1 -passlogfile log-file $filename.flv
SSH - Swiss Army Knife
Download Picasaweb Album on Linux
Direct download to Picasa does not work. It works on Windows.
James Gosling on Development of Java
James Gosling:So long as they do that. The development of Java is not an inexpensive thing. It takes a fair amount of funding. It's not just about writing code. Learning the code is two or three percent of the expense. You're shipping fifteen million copies a week, just the bandwith is horrible. The QA when you have to worry about something that has thirty issues. When you've got everything, every stock exchange, every phone company on the planet. Their security depends on Java. So it's not a causual piece of testing.
You know, when it comes to open source contributions, our history with contributions over the years have been kinda snarky. We'd get lost of people sending code and fixes. But on average, we'd get a submission that fixed the bug but it caused three or four more. And it probably didn't fix the bug for everybody. It probably only fixed the bug for their one case. And trying to get people in the community to actually think about the whole code base and not just their particular issue today. Doing one line of change means an immense amount of testing.
Most open source projects are way too casual for that. Sometimes when you get bugs that are potential security issues, you have to move fast, you have to put immense resources on getting it done. Maybe it's just one engineer fixing one character in one line, but then testing it and making sure you didn't introduce a bug. The harder stuff is if you have a bug, there are probably people out there who have worked around that bug, so how many of the workarounds are you going to break. And when you've got nine or ten million in the developer community you have enormous applications, trivial fixes are not trivial. And open source projects, the way the average open source projects are constituted. IT's easy to get people to do the fun stuff. It's hard to get people to do the hard stuff.
Like QAing the math libraries. Like doing QA on sine and cosine, you absolutely have to have a PHd in Mathematics. Sine and cosine: it sounds really simple, but there is unbelievable amount of depths of subtlety in there. There are extraordinarily few people on the planet qualified to QA that type of stuff.
http://www.basementcoders.com/transcripts/James_Gosling_Transcript.html
Quote HTML Function in python
def _quote_html(html):
return html.replace("&", "&").replace("<", "<").replace(">", ">")
-bash: /bin/ls: Argument list too long
ls *-output.logon directory containing 7000 files fails with the error
-bash: /bin/ls: Argument list too long
The best way to go about with this is:
find . -name '*-output.log' | xargs ls -l
using imapfilter
I struggled a bit to use imapfilter to delete the mails at the server.
The following was configuration
--------------
-- Options --
---------------
options.timeout = 120
options.subscribe = true
----------------
-- Accounts --
----------------
-- Connects to "imap1.mail.server", as user "user1" with "secret1" as
-- password.
account1 = IMAP {
server = 'myserver.com',
port = 993,
username = 'username',
password = 'password.',
ssl = 'tls1',
}
results = account1.INBOX:contain_subject('Subject')
-- Delete messages. This DOES NOT Work.
-- results:delete_messages()
-- This Works
account1.INBOX:delete_messages(results)
urlopen with multiple retries
def _retry_thrice(func, exc, *args, **kwargs):
for i in range(3):
try:
return func(*args, **kwargs)
except exc, last_exc:
continue
except:
raise
raise last_exc
def _wrap_with_retry_thrice(func, exc):
def wrapped(*args, **kwargs):
return _retry_thrice(func, exc, *args, **kwargs)
return wrapped
# Connecting to remote hosts is flaky. Make it more robust by retrying
# the connection several times.
_urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError)
Constructing a command for subprocess execution
Consider the following command and see how shlex module makes it more suitable for subprocess.Popen
/bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'"
import shlex
cmd = """/bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" """
list_cmd1 = cmd.split(' ')
list_cmd2 = shlex.split(cmd)
print list_cmd1
print list_cmd2
['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"]
Least used Modules from Python Standard Library
I (Geremy Condra) ran some statistics (over pypi) on the number of
times modules out of the stdlib got imported a few months ago and came
up with a reasonably comprehensive list of the least-used things in
the stdlib. For the record, since I wound up parsing import statements
and know some garbage data got in, its reasonable to assume that a few
otherwise valid imports aren't recorded here. But enough with the
disclaimers.
0 AL
0 ColorPicker
0 DEVICE
0 FL
0 FrameWork
0 Nav
0 PixMapWrapper
0 SUNAUDIODEV
0 aepack
0 aetypes
0 al
0 applesingle
0 autoGIL
0 buildtools
0 cd
0 cfmfile
0 dbhash
0 dl
0 dummy_threading
0 findertools
0 flp
0 fm
0 fpectl
0 gensuitemodule
0 icopen
0 imageop
0 imgfile
0 jpeg
0 macerrors
0 macostools
0 macresource
0 nis
0 posixfile
0 spwd
0 sunaudiodev
0 symtable
0 videoreader
0 winsound
1 Tix
1 audioop
2 ic
3 Bastion
3 binhex
3 dumbdbm
3 dummy_thread
3 fractions
3 future_builtins
3 mailcap
3 ossaudiodev
3 tabnanny
3 xdrlib
4 ScrolledText
4 macpath
4 stringprep
5 DocXMLRPCServer
5 GL
5 aifc
5 mimify
5 sunau
6 fl
6 pickletools
6 statvfs
6 turtle
7 W
8 codeop
8 multifile
8 nntplib
8 poplib
8 sndhdr
9 EasyDialogs
9 pipes
9 pyclbr
10 dbm
10 gdbm
10 imputil
11 MiniAEFrame
11 fpformat
11 numbers
14 CGIHTTPServer
14 pty
16 rexec
18 netrc
19 msvcrt
19 uu
20 rlcompleter
21 compileall
22 tty
24 lib2to3
24 mutex
25 chunk
25 mhlib
27 whichdb
28 robotparser
29 ssl
30 dircache
32 gl
33 runpy
34 posix
36 aetools
36 wave
37 termios
42 bdb
44 imaplib
46 ast
47 bsddb
47 imghdr
50 crypt
50 smtpd
53 Carbon
57 MimeWriter
57 msilib
60 cmath
66 filecmp
67 syslog
68 MacOS
73 cProfile
74 asynchat
74 repr
75 ftplib
76 htmllib
83 abc
91 quopri
93 pkgutil
98 anydbm
98 telnetlib
99 trace
102 formatter
104 __main__
104 readline
105 colorsys
110 _winreg
111 curses
113 plistlib
115 modulefinder
116 UserString
121 cookielib
125 mailbox
126 cgitb
128 bz2
128 sched
134 io
146 mimetools
147 pydoc
148 SimpleXMLRPCServer
154 mmap
155 user
156 site
157 symbol
159 zipimport
166 pstats
172 fileinput
173 encodings
179 py_compile
180 SimpleHTTPServer
181 profile
183 cmd
198 Tkinter
200 fcntl
206 copy_reg
225 linecache
226 hotshot
234 multiprocessing
262 dis
273 UserList
273 resource
287 SocketServer
289 shelve
297 sqlite3
317 grp
322 asyncore
335 timeit
339 keyword
345 sgmllib
363 token
367 test
383 parser
386 shlex
421 wsgiref
451 contextlib
458 unicodedata
471 tokenize
472 pwd
487 webbrowser
526 hmac
529 heapq
542 platform
573 gettext
594 pdb
597 popen2
607 json
608 marshal
619 smtplib
621 bisect
637 difflib
647 commands
657 BaseHTTPServer
677 Cookie
688 locale
695 zlib
708 HTMLParser
710 code
721 rfc822
748 compiler
759 gzip
759 select
771 ctypes
788 gc
796 binascii
812 getpass
822 __builtin__
854 htmlentitydefs
857 tarfile
869 decimal
872 xmlrpclib
903 csv
933 atexit
943 functools
946 exceptions
976 array
979 sha
1044 thread
1056 calendar
1064 zipfile
1070 UserDict
1078 new
1102 uuid
1148 Queue
1159 sets
1172 signal
1213 hashlib
1242 getopt
1276 email
1310 imp
1321 fnmatch
1328 mimetypes
1348 collections
1442 httplib
1469 cPickle
1505 md5
1614 weakref
1618 textwrap
1654 pickle
1722 errno
1729 stat
2020 pprint
2060 struct
2389 codecs
2391 ConfigParser
2406 operator
2578 math
2626 base64
2925 inspect
3013 cgi
3105 itertools
3250 xml
3318 glob
3402 __future__
3505 warnings
3549 socket
3722 urlparse
4014 traceback
4142 subprocess
4194 threading
4198 cStringIO
4224 string
4501 copy
4696 random
5088 shutil
5392 tempfile
5426 doctest
5642 optparse
5913 types
6185 StringIO
6522 urllib
7346 distutils
7930 datetime
8416 urllib2
9567 logging
9906 time
13019 re
14714 unittest
18334 sys
27468 os
How to charge canon fs 200 camcoder.
perforce tip - p4 describe changelist
The command is:
p4 describe -du changenumber
-du stands for unified diff which is often more helpful than others.
Look for p4 help describe for more information.
CD Creation in Ubuntu
wodim name_of_iso. I have used it thrice and everytime I forget the name. Speak of poorly named programs, I would give this a high rank.
If you want to create an iso, there is genisoimage program too. I have not used it yet, but I would be using it now. Spent 15 minutes today to findout the name of 'wodim' program.
Linux Tip - ^
Simple Countdown Clock - Python and xdaliclock
sending -countdown argument properly to the xdaliclock binary.
I find having this script in my /usr/local/bin pretty useful.
#!/usr/bin/python
# A Simple Countdown Clock using xdaliclock
# usage: countdown [time]
# time defaults to 1 hour.
import time
import sys
import subprocess
try:
hours = float(sys.argv[1])
except IndexError:
hours = 1
hours = int(time.time()) + int(hours * 3600)
command = 'xdaliclock -countdown %d' % hours
subprocess.Popen(command.split())
power 2 in python using lshift
$ python -mtimeit 'pow(2,64)'
1000000 loops, best of 3: 1.18 usec per loop
12:31 AM:senthil@:~
$ python -mtimeit 'getattr(1,"__lshift__")(64)'
1000000 loops, best of 3: 0.356 usec per loop
12:32 AM:senthil@:~
I don't know the reason for this difference, I shall update the post when i find out why.
Py3k PEPS at APAC PyCon
The Conference Experience was very good. I had a chance to meet Mark Hammond and discuss a lot of Windows Related things with him with. His presentation on raindrop, couch db and and his perspective on Windows development was very good. It was good to meet in person Liew Beng Keat, the organizer of the Conference who had done a lot of hard work to put this together. I also met Steve Holden, who was present along with his wife, I assume they had a good holiday time at SG, as it is a shopper's paradise. It was good to the warmth in Steve's welcome and this makes him a very good organizer, I guess.
On the first day, the talks I enjoyed the most were Mark's Couch DB talk, wherein I gained good knowledge of JSON based Non-Relational database and a javascript based map-reduce framework. The concept was very interesting. The final talk by Wesley Chun drew in a huge enthusiasm. Wesley did a very nice presentation on Py3k and explaining its features and kind of potrayed the picture that it would take long time for people to move to Py3k. Well, it could be true, but as I debated with him, it would be very good to just potray positively how Py3k is a more symmetrical in many ways that Py2k. His point of view was pragmatism and training for corporations. I tend to agree with him to an extent, but I still believe that for some "good programmer" to start learning Python, Python 3 is a very well designed a symmetrical one rather than Python 2. The libraries and packages will catch up soon.
I also enjoyed Graham Dumpleton's short pitch on mod_wsgi and flask. I still use mod_python and plan to move to more web-development related libraries soon.
My presentation on Py3k PEPS was on next day, it went well and was attended by a small interested audience. Following Presentation by Martin Faassen was very good too. He presented a perspecive on creating libraries, the creative aspect of development of software. Steve Holden's Metaclass Madness talk was enlightening too. It was short presentation and a consise one. It would good to write an article based on his presentation if its not already there. Because Python Metaclasses are something which does not have a lot of literature around in the web. The Q&A in the Metaclass'es talk was good one, as one person asked as when do the metaclasses take effective if we were to wrap teh private methods ( which was denoted by startswith('__') and and it turned out that Class mangles them to _Classname__privatemethod and the metaclass wrapper comes to affect later only). If I write an article, I shall discuss this in more detail. There are some interesting studies which can be done on Metaclass vs Class decorators.
I also attended Noufal's game related talk. It was good one which was attended by a sizable audience. He walked through the code and explained the physics of the game. It was good to see that if developing games we can use real world physics in games using libraries, Interesting. Also, I am not sure, how effective showing a lot of code in the talk is effective. It is very difficult to follow through. Somethings slides with less bullets and easily chew-able points make the presentation more grasping and provide useful inputs to the audience.
The singpass coder's tournament was good one too. I managed to come into Second round. My trials some with functional programming and mis-reading of problem statements cost me some time. But it was a very enjoyable game. A person by name 'Che' from China won the iPad and Noufal got the $100 Amazon Web-services coupon.
On Both days, Shalini came to pick me up from the conference and we went for a stroll in the nearby park of Fort Canning. It was good to talk, walking in the park and saw a lot of people practicing tai-chi. On Saturday we visited a lot of friends, inviting them for our marriage reception at Singapore, we also went to Jackie Chan movie, "The Karate Kid", it was fun. I liked the part where the kid shows his dancing skills on DDR to his girlfriend and she in turn amazes him after acting very shy. The concept of kung-fu as a way of life is also good. On Sunday we did some purchasing, spent a wonderful afternoon at home and in the evening I headed back to India.
Latin Characters in xterm
A - á Á
B - â Â
C - ã Ã
D - ä Ä
E - å Å
F - æ Æ
G - ç Ç
H - è È
I - é É
J - ê Ê
K - ë Ë
L - ì Ì
M - í Í
N - î Î
O - ï Ï
P - ð Ð
Q - ñ Ñ
R - ò Ò
S - ó Ó
T - ô Ô
U - õ Õ
V - ö Ö
W - ÷ ×
X - ø Ø
Y - ã Ù
Z - ú Ú
Martin Vön Löwis
Résumé
float.as_integer_ration
$ ./python
Python 2.7b1+ (trunk:80674M, May 1 2010, 08:23:48)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 3.14.as_integer_ratio()
(7070651414971679, 2251799813685248)
>>> x*1.0/y
3.14
>>>
Posting via Jabber
Video Chat on Ubuntu
1. Install Skype 2.0 on Ubuntu.
2. Follow the instructions mentioned here to make the Video option work fine.
How to Use Math Symbols in gnome-terminal
For e.g. CTRL + SHIFT + U + 2200 will output ∀ After typing CTRL + SHIFT + U,
when the terminal identifies that what follows is unicode, you might leave the
keypresses and just type the codepoint.
∀ U2200
∁ U2201
∂ U2202
∃ U2203
∄ U2204
∅ U2205
∆ U2206
U2207
U2208
∉ U2209
∊ U220A