Over this weekend, i was searching for something to do (not that i dont have tasks piled up), and i remembered there was no easy way to edit audio files tags. I know there are some excellent programs out there such as easytag and exfalso . However they need you to run a separate program to edit the tags.
Also there is a nautilus extension provided by totem that displays the metadata in the file properties dialog, but cannot edit it. I thought i may be a good idea to make a metadata editor extension for nautilus, so thats what i came up with.
Installation:
The extension requires that exfalso be installed on your computer (since it directly uses the exfalso metadata editor). On fedora, its a simple command:
$ yum install quodlibet
The extension itself is a single python file which you need to put into a directory ~/.nautilus/python-extensions/ (create the directory if it does not exist). The file is available at: https://sites.google.com/site/pankaj86/files/media_tag_editor.py.
Now the mandatory screenshot:
Tuesday, July 13, 2010
Nautilus media tag editor extension by yours truly
Posted by
Pankaj
at
2:38 PM
5
comments
Labels: audio tag editor, exfalso, nautilus
Monday, July 12, 2010
benchmarking pitfalls
In this post i'm going to list some of the pitfalls which can happen when you are trying to optimize your code and test the timings of specific code snippets.
As an example, consider the case of testing the performance of custom array class implemented in pysph at http://code.google.com/p/pysph/source/browse/source/pysph/base/carray.pyx?repo=kunalp-alternate , which is a simple substitute for 1D numpy arrays.
Now in orfer to test the performace i wrote a simple benchmark code:
cdef double t, t1, t2, num
cdef int N, i
cdef dict ret = {}
empty = numpy.empty
zeros = numpy.zeros
cdef DoubleArray carr
cdef numpy.ndarray[ndim=1, dtype=numpy.float64_t] narr
for N in ns:
carr = DoubleArray(N)
t = time()
for i in range(N):
num = carr[i]
t = time()-t
narr = zeros(N)
t1 = time()
for i in range(N):
num = narr[i]
t1 = time()-t1
t2 = time()
for i in range(N):
num = carr.data[i]
t2 = time()-t2
ret['carr loopget %d'%N] = t/N
ret['carrd loopget %d'%N] = t2/N
ret['narr loopget %d'%N] = t1/N
return ret
This snippet simply times the retrieval of a value from a custom DoubleArray class (using its data attribute which is a c array) versus a numpy buffer, both should ideally be at c speed, but the numpy buffer is not unless you disable cython array bounds check.
Now if you run it you would be surprized to see the timings:
carr loopget 100 9.05990600586e-08
carr loopget 1000 3.38554382324e-08
carr loopget 10000 3.42130661011e-08
carr loopget 100000 3.51309776306e-08
carrd loopget 100 9.53674316406e-09
carrd loopget 1000 9.53674316406e-10
carrd loopget 10000 9.53674316406e-11
carrd loopget 100000 9.53674316406e-12
narr loopget 100 9.53674316406e-09
narr loopget 1000 1.90734863281e-09
narr loopget 10000 1.09672546387e-09
narr loopget 100000 1.01089477539e-09
Strangely, getting the value in the c data array is extremely fast, and in fact takes the same time independent of the size of the array.
My first thought was that the access time in C was extremely small as compared to the time it took to call the python's time function. However my readings about gcc and compiler optimizations came to my mind.
Trick: Note that the assignment which is tested in the code snippet does not affect any other part of the code, and the variable num is never even read again. Hence the compiler optimizes it away (this technique is called dead code removal). Thus in the case of C array access the assignments do not occur at all. This does not happen for the other two parts because in calling python functions the compiler can never be sure what is done of the variables, and hence cannot reliably determine whether the assignment has any side-effect or not, so that the assignment is not removed while compilation.
Keeping this fact in mind, let us try to modify the test code so that this specific optimization does not take place. Consider our new test code:
cpdef dict loopget(ns=Ns):
cdef double t, t1, t2, num
cdef int N, i
cdef dict ret = {}
empty = numpy.empty
zeros = numpy.zeros
cdef dict d = {}
cdef DoubleArray carr
cdef numpy.ndarray[ndim=1, dtype=numpy.float64_t] narr
for N in ns:
carr = DoubleArray(N)
t = time()
for i in range(N):
num = carr[i]
t = time()-t
d[num] = num
narr = zeros(N)
t1 = time()
for i in range(N):
num = narr[i]
t1 = time()-t1
d[num] = num
t2 = time()
for i in range(N):
num = carr.data[i]
t2 = time()-t2
d[num] = num
ret['carr loopget %d'%N] = t/N
ret['carrd loopget %d'%N] = t2/N
ret['narr loopget %d'%N] = t1/N
return ret
The purpose of these added statements is to make sure that the assignment to num is not useless and that the compiler does not optimize it away. Since the new statements occur outside the time() calls it shouldn't affect our tests.
Let us now check the new timings:
carr loopget 1000 4.19616699219e-08
carr loopget 10000 4.52041625977e-08
carr loopget 100000 4.62603569031e-08
carrd loopget 100 9.53674316406e-09
carrd loopget 1000 3.09944152832e-09
carrd loopget 10000 1.31130218506e-09
carrd loopget 100000 1.07049942017e-09
narr loopget 100 2.14576721191e-08
narr loopget 1000 2.86102294922e-09
narr loopget 10000 1.69277191162e-09
narr loopget 100000 2.29835510254e-09
As you can see now the times are more reasonable.
Conclusion: Timing testing code is not a trivial thing to do :)
Posted by
Pankaj
at
12:03 PM
0
comments
Labels: bench, optimization
Friday, July 9, 2010
nearest particle search
Nearest neighbour particle search (NNPS) is a common requirement of (meshfreee) particle methods, such as SPH. The requirement is to locate all particles within a fixed distance (the kernel support) of a specified particle, and the trick is to avoid doing brute-force distance comparison of every particle with every other particle (O(N^2)). There are many techniques available to implement this. One of the simplest for a fixed kernel support of all particles is to bin the particles and then search for the particles only in the neighbouring bins. Such a technique is implemented here: http://code.google.com/p/pysph/source/browse/source/pysph/base/nnps.pyx?repo=kunalp-alternate.
Here i'm gonna present some timings for the nnps. Note that the timings are old and also include some constant extra times for other operations (calling of rand() numpy function which i've now converted to the c rand() function).
Here are the timings result (Click on image to view the raw data sheet) :
As you can see, it shows that the bin size should be atleast thrice the kernel support size to get good performance.
Posted by
Pankaj
at
10:04 PM
0
comments
Labels: nnps
Wednesday, July 7, 2010
aero nebula cluster
For those who do not know, i'm currently in my last year of the DD program in Aerospace engineering, and my project is implementation of solid mechanics code using SPH (smoothed particle hydrodynamics) integrated into the pysph project.
It pysph is basically a SPH implementation framework written in python/cython. (Now you know my reason for all those optimization posts :) ).
Now for most CFD codes, you need to run them in parallel on clusters so as to reduce the time required. So i just saw the specs of the nebula cluster (on which i have login) in aero department. Its really wonderful. The specs are:
20 nodes (15 working) each node with 12 six-core AMD opteron 2427 processors with 2.2 GHz xloxk speed and 12 GB RAM, in all 180 6-core processors.
This is sure gonna make parallelizing much more fun and interesting.
PS: I just rad and saw quite a few videos from google about their patented map-reduce technique. It would be interesting to implement SPH in map-reduce and let it run in the "cloud", the buzzword of today.
Posted by
Pankaj
at
9:39 PM
2
comments
Thursday, June 17, 2010
the linux proxy problem
For those of you who use linux for anything more than web browsing (in university/office) must be aware of the problems a proxy can pose. In many places as in my institute, you need to necessarily use a specified proxy server to access outside world, needing authentication for your credentials.
In my college, a common login registered in a central ldap server provides for all authentication services (used for course registration/fees payments/emails/proxy/...). Hence it is very important to protect it. Here i will show one way to avoid anyone easily getting your password.
Network proxy loophole in GNOME:
If you are using GNOME (default Fedora/Ubuntu) and you set your proxy details in "system->preferences->network proxy" then you open a simple loophole in the settings.
After setting your username/password, open a new terminal and type
echo $http_proxy
Now you can clearly see your password as
http://<user>:<pass>@proxy.com:3128/
Now since many people come to your rooms in colleges you can see how simple it is to get your credentials.
Is there a way out:
There may be other ways, but here's the one which i follow. I create a local forwarding proxy server on my own computer and direct all applications to use that proxy. The settings for my proxy server are written in a file only readable by the root.
What follows is a step-by-step guide to set it up. Tested on Fedora
What do i use:
I use a small proxy server 3proxy, you could also use any other proxy server such as squid. In fact i used to use squid before i came to know of 3proxy (when it was packaged in fedora). Squid is a much more feature rich and heavy proxy. When i was using it had a bug whereby it would do at least 100 cpu wakeups per second, using precious power on my laptop. This may have been fixed by now.
Installation:
On Fedora systems you can do
yum install 3proxy
A similar command for apt-get may work on Ubuntu (i've never tried)
Configuration:
The configuration you need to do is
- Open the file /etc/3proxy.cfg in editor of your choice as root
- Locate the line containing 'proxy -n'
- Above this line, upto the line 'dnspr', comment out all uncommented lines and instead add the following lines:
auth iponly
allow * * 127.0.0.0/24,<local_IPs> * * * *
allow * * * * * * *
parent 1000 http <proxy.server.com> <port> <proxy_user> <proxy_pass>
proxy -n
The values in angle brackets need to be replaced by you configuration The values for my college are given in parenthesis
<local IPs> = ips not connected through proxy [10.0.0.0/8]
<proxy.server.name> = proxy server [netmon.iitb.ac.in]
<port> = proxy port [80]
<proxy_user> = proxy authentication username
<proxy_pass> = proxy authentication password - Comment out all lines with the content:
socks
pop3p
ftppr
admin
dnspr
tcppm
udppm - Save the file
- as root run (this will make the file only readable by root user)
chmod o-rwx /etc/3proxy.cfg
chkconfig 3proxy on - ??
- profit
Now in whichever application you need to set the proxy server, set it as
http://127.0.0.1:3128/
without any authentication.
Thats it, now only root knows your ldap password, and no one else can snoop
EDIT:
If you automatically want to set the proxy environment variable of the whole system, then you can create a file /etc/profile.d/proxy.sh with the following content
export http_proxy=http://127.0.0.1:3128/
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
Many (not all) programs on linux use these environment variables to get proxy settings.
EDIT2 :
To set multiple proxies (different hosts go through different proxies) you can do something like below (see 3proxy.cfg manual for much more detail and many other options):
- # direct connection allow * 127.0.0.1 127.0.0.0/24,<local_IPs> * * # through proxy1 allow * * <hosts_thru_proxy1> * * parent 1000 http <proxy1.server.com> <port> <proxy_user> # through proxy2 allow * * <hosts_thru_proxy2> * * parent 1000 http <proxy2.server.com> <port> <proxy_user> # through proxy3 allow * * <hosts_thru_proxy3> * * parent 1000 http <proxy3.server.com> <port> <proxy_user> allow * * * * * proxy -n
Posted by
Pankaj
at
9:55 PM
25
comments
Sunday, May 30, 2010
research made simple with zotero
If you are into study/research of any kind (academic/non-academic) which involves reading up things and keeping track of them then you are in for a great productivity boost. This will help if you are reading books/news/articles/wikipedia/journals or any such sort of thing. The too I'm talking about is zotero
With zotero you can save proper bibliographic references of lots of material you see on the internet and manage/search/cite them in various forms. Its really difficult to describe all the wonderful things zotero can do for your research, so it'll be really good for you if you watch the screencast http://www.zotero.org/support/screencast_tutorials/zotero_tour
Some features you'll find helpful:
Collect:
- Single click saving of references. For example single click on any sciencedirect article, if you have subscribed (as in my college), a single click will save all information about the article, including the pdf (with well thought name instead of fulltext.pdf) if its available.
- To enable saving pdf select in Zotero Preferences->General tab -> automatically attach associated pdfs and other files when saving.
- In search tab in preferences, you may also want to enable indexing of pdfs if you need.
- Clicking on sites with references to lots of articles (wikipedia references, cited by in Scopus etc), you can easily select all the references you need to save
- You can search all your saved articles, add notes, tags etc
- You can group all articles in collections based on topic
- You can create saved searches based on various criteria
- To cite an article(s) simply select them and right click to 'create bibliography from selectd articles' and choose a format style from the many available (including all popular journals) and you are done
- If you are using bibtex to manage bibliographies for your article then select the articles and right click to do 'export selected items' and select bibtex format
- Zotero plugins are available for Openoffice and MS Office too, so you can easily insert the references in your articles, without the pain of collecting anf formatting
- If you work in team then this is a really wonderful feature. Create a simple login on the zotero server (you can also use openid)
- In zotero preferences->sync tab enter your zotero login details and enable sync my library and group library.
- All synced items (including attached pdfs) are available on the internet anywhere without even installing zotero addon. You just need to login to zotero and see your collection. This is very useful if your college has access to some journals but when you are somewhere else in a conference and you need to check and article. 100 MB space is freely available and you can buy even more.
- 'My library' is your personal collection. Group libraries are shared collections, which can be shared with other people you are working with.
Posted by
Pankaj
at
3:01 PM
1 comments
Saturday, May 29, 2010
numpy array performance / divide and conquer considered harmful
This is again a post about python code speed, the data and inference are more than a few months old but still valid.
Here's a spreadsheet showing speed of array math operations (+, -, *, /) between numpy arrays and python lists.
Check this spreadsheet to see the timings of various operations
https://spreadsheets.google.com/ccc?key=0AomYDYyBBNkkdHAtMkdHMF9TZ29lMmZQV3UwYkxWNFE&hl=en
The operations I considered for comparison were:
- x+0.1
- x-0.1
- x*0.1
- x/0.1
- x*(1/0.1)
- x+y
- x-y
- x*y
- x/y
- [p+yp[j] for j,p in enumerate(xp)]
- [xp[j]+yp[j] for j in xrange(i)]
The raw timings data is available here:
See the timings plot yourself
Conclusion:
- Use numpy arrays for size > 10
- Avoid division as much as you can to improve the speed of your numerical codes
- Instead of x/0.1 do x*(1/0.1) . This itself causes large speedup as N is increased.
- x/0.1 and x/y take almost the same time
- +, -, * take almost same time, / takes much more time, and its expense increases as N is increased.
- Once again, do not divide.
- The same thing is valid in cython code also. Avoid division even in cython code, and even if you are using double instead of numpy arrays (buffer). Rewrite expressions to minimize the usage of division operator.
Posted by
Pankaj
at
3:54 PM
1 comments
Wednesday, May 26, 2010
cython timings test
The TASK : To optimize cython functions
Detailed: functions which depend on a once initialized attribute value
This often comes handy in many cases, for example to write a Laplacian function of a scalar field in spherical/axisymmetric coordinate system, you would need three independent cases for 1,2,3 dimensions for performance purposes and if u do not write all functions as general 3D functions.The test CODE : test_kernel.pyx
| cdef class Kernel: cdef int dim cdef double (*func)(Kernel,double) def __init__(self, dim=1): self.dim = dim if dim == 1: self.func = self.func1 elif dim == 2: self.func = self.func2 cdef double func1(self, double x): return 1+x cdef double func2(self, double x): return 2+x cdef double c_func(self, double x): '''this is only to make function signature compatible with func1 and func2''' return self.func(self, x) def p_func(self, double x): return self.func(self, x) cpdef double py_func(self, double x): return self.func(self, x) cpdef double py_c_func(self, double x): return self.c_func(x) def py_func1(self, x): return self.func1(x) def py_func2(self, x): return self.func2(x) cdef double func_common(self, double x): cdef int dim = self.dim if dim == 1: return 10+x elif dim == 2: return 20+x def py_func_c_common(self, x): return self.func_common(x) cpdef double py_func_common(self, double x): cdef int dim = self.dim if dim == 1: return 10+x elif dim == 2: return 20+x |
Compilation command:
cython -a test_kernel.pyx;
gcc <optimization-flag> -shared -fPIC test_kernel.c -lpython2.6 -I /usr/include/python2.6/ -o test_kernel.so
where optimization flag is either empty or "-O2" or "-O3"
Cython optimization
Tip 1:
Type (cdef) as many variables as you can. You also need to type the locals in each function. Try to try to use C data types wherever possible.
Tip 2:
use:
cython -a file.pyx
command to generate a html file which shows lines which cause expensive python functions to be called. Clicking on a line shows the corresponding C code generated, highlighting expensive calls in shades of red. Try to eliminate as many such calls as you can.
The TEST :
time_kernel.pyimport timeit def time(s): '''returns time in microseconds''' t = 1e6*timeit.timeit(s,'import test_kernel;k1=test_kernel.Kernel(1);k2=test_kernel.Kernel(2);',number=1000000)/1000000. print s, t return t time('k1.p_func(0)') time('k1.py_func(0)') time('k1.py_func1(0)') time('k1.py_c_func(0)') time('k1.py_func_c_common(0)') time('k1.py_func_common(0)') time('k2.p_func(0)') time('k2.py_func(0)') time('k2.py_func2(0)') time('k2.py_c_func(0)') time('k2.py_func_c_common(0)') time('k2.py_func_common(0)') |
Timings :
| function | time (μs) | (ns) | |||||
| Optimization flag -> | None | -O2 | -O3 | sum | (k1+k2)/2 | penalty | |
| 1 | k1.p_func(0) | 0.20178 | 0.18321 | 0.18035 | 0.18845 | 0.19368 | 0.0000 |
| 2 | k1.py_func(0) | 0.23224 | 0.18599 | 0.18393 | 0.20072 | 0.19541 | 1.7345 |
| 3 | k1.py_func1(0) | 0.21477 | 0.18991 | 0.19252 | 0.19907 | 0.19802 | 4.3456 |
| 4 | k1.py_c_func(0) | 0.23395 | 0.19196 | 0.19243 | 0.20611 | 0.19761 | 3.9311 |
| 5 | k1.py_func_c_common(0) | 0.19566 | 0.18458 | 0.19062 | 0.19029 | 0.19767 | 3.9960 |
| 6 | k1.py_func_common(0) | 0.21981 | 0.18707 | 0.18984 | 0.19891 | 0.19510 | 1.4237 |
| 7 | k2.p_func(0) | 0.20448 | 0.18388 | 0.18194 | 0.19010 | ||
| 8 | k2.py_func(0) | 0.21798 | 0.18859 | 0.18437 | 0.19698 | ||
| 9 | k2.py_func2(0) | 0.20413 | 0.18124 | 0.18194 | 0.18910 | ||
| 10 | k2.py_c_func(0) | 0.23114 | 0.19166 | 0.19238 | 0.20506 | ||
| 11 | k2.py_func_c_common(0) | 0.19860 | 0.18783 | 0.18745 | 0.19129 | ||
| 12 | k2.py_func_common(0) | 0.21609 | 0.18747 | 0.18640 | 0.19666 | ||
| Average | 0.21560 | 0.18681 | 0.18703 | 0.19648 | |||
Result :
| task | function | penalty cost (ns) |
| C function + python accessor : base case | p_func | |
| cpdef instead of def | py_func | 1.7345 |
| calling a cdef class method instead of a function pointer attribute | py_func1,py_func2 | 4.3456 |
| one extra c function call | py_c_func | 3.9311 |
| (def + cdef) instead of (cpdef) | py_func_c_common-py_func_common | 2.5723 |
| One C comparison vs one C function call | py_func_common | 1.4237 |
Conclusion :
As can be clearly seen that the results are clearly inconclusive :)This was a small test carried on my laptop with no controlled environment. Also thought the results seemed close to repeatable, nevertheless many trials should be conduction and each value should have a standard deviation also to check the repeatability. However one clear conclusion is do not forget to add optimization flags. Setuptools already does that for you.
Also using a function pointer is not so bad after all. It would become more advantageous in case of more number of comparisons.
Cython provides great speedups (who didn't know that :) ). The pure python version of py_func_common took 0.408μs for dim=1 and 0.518μs for dim=2
These results are purely from python point of view. The effect of cdef/cpdef should also be considered in c/cython code which calls these functions.
CAVEAT:
I am no optimization expert. I have done this out of out of sheer boredom :)If anyone wants to verify, you are welcome
Any information content is purely coincindental
Posted by
Pankaj
at
10:58 PM
1 comments
Tuesday, April 27, 2010
Tracing python programs
Coming with the easier python debugging enabled by the new gdb with python hooks is another awesome python feature coming in the new Fedora "Goddard" 13 release. That is tracing of python processes and their function calls. This feature is developed on top of systemtap, the linux analogue of Sun's awesome Dtrace system tracer.
So what does it mean? For the uninitiated, it implements hooks (tracepoints) in the python main shared libraries (libpython.so and libpython3.so) so that systemtap can trace whenever a python function is entered/exited in any python process on the system. This means you can anytime check a python process to see which functions are being called and how many times etc. This has really cool uses. More information about this feature is available at https://fedoraproject.org/wiki/Features/SystemtapStaticProbes#Python_2
Just to illustrate the use try the following examples (from the above link)
First install python-debuginfo. Now add yourself to stapdev and stapusr groups or run the following command as root:
$ stap /usr/share/doc/python3-libs-3.1.2/pyfuntop.stp
This will display a top like output on the terminal showing the python functions which are called by all running processes and the number of times its being called. Its fun to watch, just run a python program and check all the functions being called :)
Here's a sample output from my laptop
PID FILENAME LINE FUNCTION CALLS 15479 /usr/lib/python2.6/site-packages/yum/packages.py 261 verCMP 15768 15479 /usr/lib/python2.6/site-packages/yum/packages.py 270 __cmp__ 15767 15479 /usr/lib/python2.6/site-packages/rpmUtils/updates.py 129 returnNewest 9045 15479 /usr/lib/python2.6/site-packages/rpmUtils/miscutils.py 36 compareEVR 1191 15479 /usr/lib/python2.6/site-packages/yum/packages.py 48 comparePoEVR 578 15479 /usr/lib/python2.6/site-packages/yum/packages.py 296 verEQ 556 15479 /usr/lib/python2.6/site-packages/yum/packages.py 55 comparePoEVREQ 556 15479 /usr/lib/python2.6/site-packages/yum/__init__.py 778This shows the functions called during a 1 second interval (the script updates the display every second) by checking of available updates by packagekit.2 15479 /usr/lib/python2.6/site-packages/yum/__init__.py 206 _getConfig 2 15479 /usr/lib/python2.6/site-packages/yum/config.py 69 __get__ 2 15479 /usr/lib64/python2.6/logging/__init__.py 1026 debug 1 15479 /usr/lib64/python2.6/logging/__init__.py 1236 isEnabledFor 1 15479 /usr/lib64/python2.6/logging/__init__.py 1222 getEffectiveLevel 1 15479 /usr/lib/python2.6/site-packages/rpmUtils/updates.py 272 doUpdates 1
Another system script displays the python function call hierarchy of any program you run. Try this by running
$ stap -v /usr/share/doc/python-libs-2.6.4/systemtap-example.stp -c python
Now you will get a python terminal after a long hierarchy of function calls. Here you can see all python functions called for each line you enter on the python terminal. Its not as much fun, but useful if you want to check where all those extra unneeded function calls are being made.
Read a short writeup from the developer of these features at http://fedoraproject.org/wiki/Python_in_Fedora_13 and also check http://press.redhat.com/2010/04/27/fedora-13-spotlight-feature-exploring-new-frontiers-of-python-development/
Posted by
Pankaj
at
10:04 PM
5
comments
Saturday, April 24, 2010
hard disk speed and os partition
I knew this for quite some time, but now i have experimental evidence also that installing your os and keeping your home partition near the front of the hard disk results in more responsive computer. This is because conventional hard disks are rotary which means the read data faster from the outer sectors than from the inner sectors. So the next time you install your os keep it near the front partition.
Here's a screenshot of the palimpsest utility (Applications -> system tools -> disk utility in fedora, package gnome-disk-utility) showing the read only benchmark speed and access (seek) times. As you can see the initial part has nearly double the speed than the last part. Seek times don't show any such obvious relation.
Posted by
Pankaj
at
6:18 PM
0
comments
Labels: hard disk
Friday, April 23, 2010
Easier cython/python/c debugging with new GDB
We all know how debugging is an dreaded integral part of every programmer's work. It can also be fun sometimes depending on the time to deadline, complexity of the bug and time already spent.
So if anyone is still left who does assignments or other programs without debugging (using print statements etc) then please consider learning it. Else you are simply increasing your work and frustration.
For debugging in any programming language my advise would be to use the eclipse debugger gui which provides all the standard features present in any debugger and integration with java, c/c++, python and a host of other languages.
This post was not about plain debugging. Its about the new features in GDB 7 (the GNU debugger) which enables writing pretty printers in python. More information can be had from the net. However it means a much easier debugging experience with cython. The good folks at Fedora have written some cool scripts to integration python scripting capability of gdb to enable easier cython debugging.
Check out the awesomeness at https://fedoraproject.org/wiki/Features/EasierPythonDebugging
In short now you can do the following easily with the new gdb
- automatically display python frame information in PyEval_EvalFrameEx in gdb backtraces, including in ABRT:
- python source file, line number, and function names
- values of locals, if available
- name of function for wrapped C functions
Also not to forget the uber cool features it could enable not only for python developers but for all. As an example check out the blog at http://labs.trolltech.com/blogs/2010/04/22/peek-and-poke-vol-3/
Posted by
Pankaj
at
9:31 PM
0
comments
Thursday, March 4, 2010
funny slashdot comment about windows
Are you saying that this linux can run on a computer without windows underneath it, at all ? As in, without a boot disk, without any drivers, and without any services ? That sounds preposterous to me. If it were true (and I doubt it), then companies would be selling computers without a windows. This clearly is not happening, so there must be some error in your calculations. I hope you realise that windows is more than just Office ? Its a whole system that runs the computer from start to finish, and that is a very difficult thing to acheive. A lot of people dont realise this. Microsoft just spent $9 billion and many years to create Vista, so it does not sound reasonable that some new alternative could just snap into existence overnight like that. It would take billions of dollars and a massive effort to achieve. IBM tried, and spent a huge amount of money developing OS/2 but could never keep up with Windows. Apple tried to create their own system for years, but finally gave up recently and moved to Intel and Microsoft. Its just not possible that a freeware like the Linux could be extended to the point where it runs the entire computer fron start to finish, without using some of the more critical parts of windows. Not possible. I think you need to re-examine your assumptions.
Posted by
Pankaj
at
11:16 PM
1 comments
Labels: windows
Saturday, February 27, 2010
Increasing coursework
I just realized that the coursework in my college increases at a very fast pace as the years go by.
Here's the proof:
my directory sizes of the data in each year's courseware. 4th years data is as yet incomplete as mid-terms are just over and half a sem is still remaining. (y* are the year's coursework directories)
[pankaj@localhost courseware]$ du -sh y*
158M y1
322M y2
1.7G y3
2.2G y4
UPDATE: The score is 6.9 GB for y4 at the end of the year, most of it is a single course, with hundreds of MB of datasets and simulation videos
Posted by
Pankaj
at
5:38 PM
0
comments
Labels: courseware
real programmers
i just found a funny old article about programming. I'm glad i'm not a 'real' programmer (just for your information, i'm a complex programmer)
check the link http://www.pbm.com/~lindahl/real.programmers.html
Posted by
Pankaj
at
5:02 PM
0
comments
Labels: real programmer
Tuesday, February 23, 2010
my academic schedule
Now you know how stupid my lectures are scheduled.
Legend:
Blue : Moodle calendar (academic assignments, submissions etc)
Green : Indian holidays
Yellow : My edited calendar for lecture schedules and other academic things :)
Posted by
Pankaj
at
10:02 PM
0
comments
Labels: academic calendar
Thursday, November 26, 2009
Installing Salome platfrom on Fedora (12 x86_64)
The salome platform is a good open source platform for FEA/CFD etc. It includes a good preprocessor to easily create geometries, mesh them in a variety of ways and also import/export various types of formats. I generally use it with OpenFOAM, which is a FVM library and collection of programs to solve various types of flows and also structures and other problems.
Check them out at http://www.salome-platform.org/ and http://www.openfoam.com/features/
So the main thing i'm writing this is as a reminder to me and to save hoursof other people's time who try installing salome-platform on any of the modern linux distros.
Step 1 > Download the package. If the package is not available for you distro choose debian or mandriva whichever is closer to your distro (both work in case of fedora)
Step 2 > Extract (tar -xvf filename) to a convenient location (your home or anywhere else doesn't matter. u can delete this later)
Step 3 > Change the file config_files/gcc-common.sh to match your installation of gcc. I replaced gcc_root="/usr/bin".
Step 4 > Run ./runInstall. Choose appropriate options in the gui and finish the wizard.
Step 5 > To run salome type:
$ . KERNEL_<version>/salome.sh
$ runSalome
Thats it
Step 6 > Now steps 1 to 5 are simple, anyone can do it without any help. Here comes the main point which took me hours despite me already having installed and used various versions of salome in previous fedora installations.
If you see an error message like
Configure parser: Warning : could not find user configuration file
runSalome running on localhost
Configure parser: Warning : could not find user configuration file
Searching for a free port for naming service: 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 - OK
Searching Naming Service ++++++++++Failed to narrow the root naming context
Traceback (most recent call last):
File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/runSalome.py", line 648, in useSalome
clt = startSalome(args, modules_list, modules_root_dir)
File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/runSalome.py", line 429, in startSalome
clt=orbmodule.client(args)
File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/orbmodule.py", line 48, in __init__
self.initNS(args or {})
File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/orbmodule.py", line 81, in initNS
sys.exit(1)
SystemExit: 1
on running salome then here's what you need to do.
1 > edit /etc/hosts (of course you need root for that) and make sure you have a line such as
Posted by
Pankaj
at
11:50 PM
0
comments
Sunday, November 15, 2009
Why i use Fedora linux
This question crops up fairly too often in my conversation with friends who use linux (most of them use ubuntu). So i decided to settle the matter once and for all.
My reason for using fedora is simple, its the same reason why some people like strawberry flavoured ice-creams and some hate it, its THEIR OWN PREFERENCE.
Also i first started with fedora because it was the first linux i ever saw (in my NSL computer lab for cs101 course). Yes, contrary to popular belief, i did not use linux from my childhood, the first computer in my home was 3 months before i joined IIT. And the first linux i saw was in IIT. I event learnt my first two languages C/C++ and Java by READING BOOKS, and even read the complete print copy of "Dive into Python" before actually diving into python!
The first linux i used was Knoppix live which came with a dvd of a magazine. I used it exclusively for 2 weeks as i didn't know how to install an os. Then after burning about 6-7 cds (i wasted a few) i installed my first linux, Fedora 5 Bordeaux and have installed every Fedora release ever since, and never felt the need to change my distro. Most of them are mostly the same from the inside.
However, just in case you want to make points, i'll list a few:
http://fedoraproject.org/wiki/Overview
- Fedora (+RH) devs work hard on bringing new features in linux. Many of the new features in linux are brought by them. For example the latest features in linux have been developed by fedora/RH devs including but not limited to the NetworkManager, pulseaudio, packagekit,.pulseaudio and many more. Also check http://fedoraproject.org/wiki/Red_Hat_contributions
- The openness of fedora is what i really like and wish all the world were so open. By this open i do not mean open-source code, i mean openness of mind, acceptance of others, openness of governance, openness of activities, no hidden agenda.
- The fedora features mention exactly what is there in a new fedora release (many of the things are own contributions). Compare http://fedoraproject.org/wiki/Releases/12/FeatureList with http://www.ubuntu.com/products/whatisubuntu/910features . I couldn't figure out what different from the previous release apart from firefox 3.5, openoffice 3.1 and ubuntuone.
- Fedora stays closer to upstream and is generally more updated.
- http://fedoraproject.org/wiki/Foundations
Posted by
Pankaj
at
12:38 PM
0
comments
Wednesday, October 7, 2009
use more screen space in firefox
Many of my friends and not so friends have seemed to like google chrome browser in that it makes available more screen space for the web page to display. Of course its a good things, especially for laptops with wider screens and scant vertical space. However not many know that firefox has been customizable enough for long so that you can make available more space for you if you need. Though it cannot compete with chrome, you can still extract much more from it. Here's my compact menubar+addressbar+bookmarks bar in firefox all in a single line.
To do this right click on the menubar and click customize. Then modift the toolbars and menubars to your hearts content.
Here's my firefox compact look especially for notebooks. Also notice how the fastdial extension gives you access to most frequently used websites without the need of a separate bookmarks toolbar.
Here's the customization screen
So enjoy the more real estate in firefox.
Posted by
Pankaj
at
6:44 PM
0
comments
Labels: firefox
Saturday, October 3, 2009
thermal handler : protect your computer from overheat
So recently i started encoding some of the videos i had from dvds into compressed formats as the dvds are getting scratched and damaged. So i used the avidemux program for it. However my laptop gets overheated a lot during high cpu usage.
Other problems with overheating came when i had to run my dsmc and other assignments. Since they run for a looong time, my laptop overheats and i used to keep it hanging on its side during overnight runs. To my horror once when i compiled openfoam on my laptop overnight, i saw it shutdown in the morning with a failed compile and overheat. So here's my solution for all those who suffer from the problem of overheating computers (for linux users only).
Checkout the all new "thermal handler" from yours truly. The solution for all your computer overheat problems due to high cpu usage.
What it does:
Checks the temperature periodically and pauses processes using high cpu when a certain temperature is reached (default 90) and resumes them when the temperature falls below a certain value (default 65). None of your data crashes. The programs resume from the same state they were paused. No data loss. (Note that root processes cant be paused by the user)
What you need to do:
just run from a shell:
Here's thermal handler at work:
Download it from here : http://home.iitb.ac.in/%7Epankajp/web/downloads/thermal_handler.py
EDIT: Thanks to Prashant Agrawal for reporting that the initial version didn't work on AMD cpus and helping me to test. I've updated the file to work on AMD cpus now. check it out
Posted by
Pankaj
at
12:13 PM
4
comments
Labels: overheat, python, thermal_handler
Friday, October 2, 2009
animate2
Now i present before you the much improved animate2.
Here are the major changes
- Plot saving is fixed when multiple subplots are present
- animate() is retained for compatibility, new users are expected to use animate2() with changed api for the function
- Much more customizability
- Plot frame traits (properties) can now be specified. Ex: plot title, axes labels, ticks, colors etc using extended traits notation to set the plot object properties
- Each plot (line) can be customized. Plots can now be of various types such as scatted, line etc. Their properties can also be set such colors, thickness, style (dot-dash etc). Plots can also be labelled to add legends to the plot
- Read the docstrings and the examples in __main__. They explain a lot of common uses.
Check out the video below
Video with subtitles explaining the video is available here:
http://home.iitb.ac.in/%7Epankajp/web/downloads/animate2.mkv
Requirements:
To run this you will need the Enthought tool suite ETS (only traits with wx backend and chaco are required)
Hope this is useful for someone.
You can get the code animate.py from here that is:
http://home.iitb.ac.in/%7Epankajp/web/downloads/animate.py
Posted by
Pankaj
at
7:44 PM
0
comments






