Skip to main content

Posts

Showing posts from 2011

shutdown

We may think that why to bother typing commands when using the GUI to shutting down the computer is easy and straight. But at time we may want to shut down the computer after some time when the download finishes or some other task completes. But we cannot wait until that time. So we can use shutdown command in such cases. For example, if you want to shut down the computer at 2:12 pm then you can use the following command in your ubuntu box: sudo shutdown -h 14:12 "Going to Shutdown at 2:12 pm"

Kile

Though the default installation of Kile, a latex editor, in ubuntu works fine for simple things, but at times it needs extra packages (for e.g. algorithm.sty, etc). In that case we can install the following extra scientific packages in Ubuntu linux as follows: sudo apt-get install texlive-science

Hide drive icon from your Ubuntu Desktop

It is useful when we wish to configure our desktop item to be stable. Sometimes its annoying when the drive icons appear and disappear when we mount and unmount them. So follow the following steps to get rid of this situation:    1. Hit Alt+F2 then the  "Run Application" window will apper.    2. Then type "gconf-editor" and press Enter  so as to get the Configuration Editor.    3. Browse to apps > nautilus > desktop.    4. Check off  "volumes_visible"  then you are done

Bash script to archive different files and folders into a single folder which will be named using current timestamp

I use this script to back up files that are created in different locations. I feel easy to collect all the related files and folders to compress and save them as a single zip archive which is named as per the current date and time. #!/bin/bash # this program creates a zip archive of myFolder(containing files and folders), file1 , file2 , file3 and file4 and puts the archive in myOpDir. The name of the final zip archive will be given by the current timestamp. For eg : final_20111220_103015.zip #create a directory for putting all the files myFolder="/home/user/Desktop/myFolderWithContents" myOpDir="/home/user/Desktop/myFinalDir" file1="/home/user/Desktop/test.tcl" file2="/home/user/Desktop/test.dump.xml" file3="/home/user/Desktop/myDir/test.txt" file4="/home/user/Desktop/myDir/test.txt.xml" mkdir $myOpDir/temp # copy the files and folder to to temp dir cp -r $myFolder $myOpDir/temp/` cp $file1 $myOpDir/temp/test.tcl cp $fil

Python : split any file (binary) to different pieces and join them

This python program takes an input file and then splits it into different smaller chunks. Next it can collect all the different chunks and join it to get the original file. -------------------------------------------------------- # define the function to split the file into smaller chunks def splitFile(inputFile,chunkSize): #read the contents of the file f = open(inputFile, 'rb') data = f.read() # read the entire content of the file f.close() # get the length of data, ie size of the input file in bytes bytes = len(data) #calculate the number of chunks to be created noOfChunks= bytes/chunkSize if(bytes%chunkSize): noOfChunks+=1 #create a info.txt file for writing metadata f = open('info.txt', 'w') f.write(inputFile+','+'chunk,'+str(noOfChunks)+','+str(chunkSize)) f.close() chunkNames = [] for i in range(0, bytes+1, chunkSize): fn1 = "chunk%s&

believe in yourself

ya time is powerful, my friend its revels the truth it uncovers the mystery you need to go with it else you are left alone. May be, its time to change your shoe trace a new path ya my friend, And as always don't just wait for your pals you may remain waiting Mind it, at times you need to change ya you need to do it my friend And the truth is there is no one for you no damn interfaces And my friend, Everyone have a reason damn selfish reason for walking with you And the another truth is there is always a humble heart walking with you you need to believe it search it in yourself ya its just you my friend believe in yourself

ffmpeg video converter

Some tips to remember while using ffmpeg in ubuntu: #install restricted packages (more info in: http://ubuntuforums.org/showthread.php?t=786095 ) sudo apt-get install ubuntu-restricted-extras # video converting with ffmpeg The default ffmpeg installation does not support all features so do this way: sudo apt-get install ffmpeg libavcodec-extra-52 #Change flv/avi files to mp4(parameters customized for nokia 5800 mobile phone) ffmpeg -f mp4 -vcodec libxvid -s 640x360 -b 768k -r 25 -aspect 16:9 -acodec libfaac -ab 96k -ar 44100 -ac 2 output.mp4 -i input.avi/flv #change to mp3 (more info in http://ubuntuforums.org/showthread.php?t=1125181 ) ffmpeg -acodec libmp3lame -ac 2 -ab 128 -vn -y output.mp3 -i “mysource.flv” # bash scrit to convert all files in a folder to mp4 using the above method for i in *; do ffmpeg -f mp4 -vcodec mpeg4 -b 2200k -r 30 -s 640x360 -acodec libfaac -ar 32000 -ab 128k -ac 2 "_$i.mp4" -i "$i"; done # convert all files in the current folder to