The escape sequence for printing in the same line is '\r' in BASH and \033[A in python.
Include that in any code in BASH shell X11 environment to print in the same line instead of jumping to the next line.
For example, the bash code
for ((i=1;i<10;i++))
do
echo -e "i = " $i
done
prints output as:
i = 1
i = 2
i = 3
i = 4
i = 5
i = 6
i = 7
i = 8
i = 9
But the same code with the escape sequence '\r'
for ((i=1;i<10;i++))
do
echo -en "i = \r" $i
# (or) printf "i= %d \r" $i
sleep 1s
done
prints the output in a single line as:
i = 1
and finally the line goes off.
This can be very useful when following the progress of a code.
I haven't tried it in C, but it might work in C and C++ as well.
In python the following works:
#!/usr/bin/python
import time
for i in range(0,10):
print "i= %d \033[A" %i
time.sleep(1)
Sunday, March 29, 2009
Monday, March 16, 2009
Kernel .config file for IBM T60 laptop (Ubuntu)
To check if compiling a new lighter kernel can save battery runtime and be faster on my IBM T60 laptop, I created a kernel .config file and compiled a new kernel.
I currently run Ubuntu 8.1 on my laptop. Ubuntu default kernel is loaded with a lot of kernel modules which I did not need for my laptop.
Here is a gist of my crude understanding of the outcome:
1) GNOME was too heavy to notice any considerable battery runtime improvement.
2) The applications definitely load faster on GNOME. Possibly by a few microseconds as I could feel a tangible difference.
3) XFCE works brilliantly well with the new kernel. I could almost get 20 mins extra with an overall runtime of approx 2 hr 45 mins.
4) The applications load very fast in XFCE.
5) I did get faster boot, shutdown, and recovery from sleep.
I did not try to quantify any of the above. If any of you try it on your laptop do let me know about the performance. Thanks.
I currently run Ubuntu 8.1 on my laptop. Ubuntu default kernel is loaded with a lot of kernel modules which I did not need for my laptop.
Here is a gist of my crude understanding of the outcome:
1) GNOME was too heavy to notice any considerable battery runtime improvement.
2) The applications definitely load faster on GNOME. Possibly by a few microseconds as I could feel a tangible difference.
3) XFCE works brilliantly well with the new kernel. I could almost get 20 mins extra with an overall runtime of approx 2 hr 45 mins.
4) The applications load very fast in XFCE.
5) I did get faster boot, shutdown, and recovery from sleep.
I did not try to quantify any of the above. If any of you try it on your laptop do let me know about the performance. Thanks.
Monday, March 9, 2009
Scientific Python VMD module
Scientific Python has a very useful VMD visualization module. There was small bug in the code which had to be fixed.
You can create any VMD object very easily using this module.
Here (Download) is the updated module.
View the module
You can create any VMD object very easily using this module.
Here (Download) is the updated module.
View the module
Wednesday, March 4, 2009
Simple brochure template in latex
It is hard to search online and find a simple latex template for making a brochure.
So here is one...brouchure.tex -download
brochure.tex - view
So here is one...brouchure.tex -download
brochure.tex - view
Subscribe to:
Posts (Atom)