Skip to main content

Posts

Showing posts from 2012

Get HDMI sound working in Ubuntu without logging out

It is a known issue in Ubuntu that the when a HDMI cable is plugged in, the sound settings do not automatically show the HDMI sound output option. The only way to make it work was to log out and log back in again with the HDMI cable plugged in. This bug is discussed here: https://bugs.launchpad.net/ubuntu/+source/gnome-control-center/+bug/974963 But the page also lists a very useful workaround thanks to Beltrachi, The idea is to send noise to the hdmi output. $ cat /dev/urandom | aplay -f S16_LE -c2 -r44100 -D hdmi Press Ctrl+c when the noise is heard in the TV. The hdmi should be working now. The sound in the speaker might disappear after the hdmi cable is unplugged. The dosage is similar for this case also. Just send noise to the default speakers. $ cat /dev/urandom | aplay -f S16_LE -c2 -r44100 If that doesn't seem to work then try to select the PC speakers as the output device in the Sound controls.

GRtensor commands

I would try to collect some useful resources for GRtensor package of Maple. I contains a host of commands which are very useful but the documentation is scarce. A good page to learn the applicability of the commands through example is http://www.smf.mx/~dgfm-smf/TallerVI/CursoSussman/hoja2/hoja21.html All GRtensor outputs needs o be simplified one way or another and GRtensor provides specialized routines to accomplish just that. The gralter command does the job instead of the Maple command simplify . http://grtensor.phy.queensu.ca/Griihelp/gralter.help And everyone needs to know the keyboard shortcuts of any program they are using. It makes life efficient. http://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet%2fdocumenting%2f2DMathShortcutKeys For example, I was unable to enter the Greek symbols for a long time till I found that it is very easy to do so in Maple. Just type the Greek word in English and press escape key. A menu pops up displaying all names t

Using the 3D modelling software Blender3D efficiently

Blender 3D is an excellent tool for building 3D models. It is a free alternative to professional 3D modelling softwares like 3DS MAX and MAYA. I personally found it to be easier to use and more efficient than 3DS MAX. Its shortcuts are easier to remember and the workflow is much more streamlined than 3DS MAX. There are plethora of superbly written tutorials out there on Blender3D so I am not going to go into that. People who are interested in some tutorials can look at  http://en.wikibooks.org/wiki/Subject:Blender_3D I would start with a list of useful keyboard shortcuts which makes the Blender3D experience all the more enjoyable. The following are not a complete list of keyboard shortcuts for Blender3D but they are most useful ones in my opinion.  BLENDER shortcuts Manipulate view select -> right click  pan : middle mouse + shift zoom middle + ctrl rotate view : middle click + drag select multiple object : shift + right click or press b -> then

Add arXiv hyperlink to bibtex in under 1 seconds

Add hyperlinks of arXiv numbers to all the bibtex entries in a bib file in under 1 second. This is accomplished by a script.  The user only needs to have a bibtex file which already has the eprint entry for every bibtex item. The rest would be handled by the script. This procedure is not necessary for some packages and bst files. it becomes necessary when specialized citation packages, like natbib, are used. Natbib generally do not include the hyperlink to the eprint number and some bst files for natbib like pjgsm.bst would completely ignore the eprint field. The following script would amend this situation. It basically hard codes the hyperlinked arXiv number  into the journal entry. So hen the bibtex is run the journal entry would include the hyperlinked arXiv number. I wrote this script with bibtex from the NASA ADS server in mind. Bibtex from other sources might need some modification. Critical comments and suggested improvements are welcome. ===============================

Search inside text files

When we have many text files such as code samples or research documents then more often than not we want something which is in one of the files but we cannot remember which one. This is when searching inside text files becomes necessary. There is a one-liner that can do the job. find . -name "*" | xargs -d '\n' grep -i -A2 -B2 --color=auto "KEYWORD" 2> /dev/null For example, $ find . - name "*" | xargs - d '\n' grep - i - A2 - B2 -- color = auto "21sma" 2 > / dev / null ./ coding / python / stock - python / stock - analysis / stock - analysis . py - # create SMA columns ./ coding / python / stock - python / stock - analysis / stock - analysis . py - # min_periods starts averaging from day-0 not day-200 so it is always continuous with no initial 200-day gap ./ coding / python / stock - python / stock - analysis / stock - analysis . py : stock [ '21SMA' ] = stock [ 'Adj Close' ]

How to join audio tracks smoothly in Audacity

Audio tracks can be mixed easily in full fledged video editors like kdenlive or Adobe Premiere but for mixing or joining audio they would not provide the amount of control that audio editors like Audacity provide. The example I am going to show today would demonstrate the range of tools in Audacity that allows us to control the waveform and to mold it to our desire. Today I am going to take a small track like a small 1 min. clip of storm sound and make a long continuous sounding storm audio clip from it. STEP 1 : Open file Open the clip in Audacity. STEP 2 : Removing unwanted audio portion There is always unwanted sections of the audio that we have to discard. Select the portion of background noise or unwanted audio. Press DELETE key. STEP 3 : Duplicating the track Now we make a copy of the entire waveform and paste it at the end of the track. Select the SELECT tool (the one which looks like I). Then select the whole waveform and prss Ctrl+c. Now click ap

Joining Mp4 Files

The following parts are independent. PROCEDURE 1 Try the simple one first. Just copy the video and the audio stream. mencoder file1.mp4 file2.mp4 -ovc copy -oac copy -of lavf format=mp4 -o output.mp4 Sometimes this might not work. Many times the audio copy would fail with the errors like. Audio format 0x4134504d is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it. In these cases it is better to re-encode the audio with lame. mencoder file1.mp4 file2.mp4 -ovc copy -oac mp3lame -of lavf format=mp4 -o output.mp4 If we want free format encoding we could also use FAAC encoder (Freeware Advanced Audio Coder.). In this example the video codec used in also a free format to encode to H.264 HD format. mencoder video1.mp4 video2.mp4 -o video3.mp4 -of lavf -lavfopts format=mp4 -vf harddup -oac lavc -ovc lavc -lavcopts acodec=libfaac:vcodec=libx264 PROCEDURE 2 MP4Box -add file1.mp4 -add file2.mp4 out

To convert a video file to HD format

In the following exposition we would discuss the command line procedure to produce videos with HD aspect ratio from normal videos. This would allow the video to fill a HD screen . NOTE: This procedure will not improve quality of a video. If it is grainy then it would remain grainy in the final result. Changing aspect ratio only allows the video to fit HD screens and not improve its quality. To improve quality you can try smoothing in AVIDEMUX. There are many GUIs to convert a video file to HD 16:9 format. But I find its best to use the CLI. STEP 1 : Get video file info We have to get the file to the 16:9 ratio.  To achieve this first obtain video info using mplayer. Just play the video and press ESC immediately upon starting.  Now look at the line starting with VIDEO. It should say something like this, VIDEO:  [H264]  640x380  0bpp  29.970 fps  138.8 kbps (16.9 kbyte/s) The 2nd column would be video codec. 3rd would be resolution. 5th is fps for video and 4th is sound

Save youtube videos from browser cache(new method)

This post supersedes the previous post that I wrote at http://kheyali.blogspot.com/2009/11/how-to-save-online-video.html A new method have to be used because flash changed the way it stored the cached file. The file is deleted immediately upon creation but a file handle is kept open. This is similar to the situation that if a copy is open in memory and someone deletes the file from disk, upon saving the file the file reappears on disk. But someone already did the work of writing the procedure down. So I list it here. http://liori.jogger.pl/2010/11/08/getting-flash-videos-from-almost-deleted-files/

Non-English characters: How are they displayed

We have come a long way since every time we needed to read some non-English texts we needed to install special fonts in Windows. After I started using Linux I always wondered how does all these types of characters display so perfectly. I knew that it was Unicode. But what I didn't grasp immediately is how the OS can display such an enormous variety of characters. Unicode is not just a character set like we learnt in school. Instead it is an encoding algorithm (in some sense). What it does is that it assigns numbers different basic characters and then any characters can be constructed out of these elementary characters. What happens is that two characters like a and '   are merged to get  á. People who know LaTeX would instantly realize that this is how LaTeX also works. But this composting is done in the browser directly in the OS itself not as a separate software. This process is called "pre-composition" or "decomposition" depending on how the mergi

How to add and synchronize subtitles

This is tutorial on Adding subtitle to a video clip and synchronizing it correctly.  Shifting the subtitles correctly for out of sync subtitles. Adding subtitle to a video clip Lets say that the video clip is from a movie and we want to cut the subtitles from that portion of the movie and add it to this clip. The only problem is that the subtitles files are written in a continuous manner which makes it difficult to plain cut and paste operation of the relevant section.  The steps involved are -- 1.Get the subtitle file.  2. Get the relevant portion of the subtitle file from the whole srt file and save it in another srt file. If for eg. we want know some words at the beginning and the end we can extract the text from the srt file using grep. Example file : The relevant section is in yellow. 1220 01:53:46,980 --> 01:53:48,140 Father-in-law! 1221 01:54:17,648 --> 01:54:23,780 I'm a foreigner , I came from foreign... 1222 01:

Ubuntu screen lock freeze

Ubuntu screen lock freeze is a OpenGL problem. Fix it by setting  --- Install Compiz Settings Manager: Code: sudo apt-get install compizconfig-settings-manager -Go to OpenGL plug-in & uncheck the Sync to VBlank option. http://www.preshweb.co.uk/2011/05/ubuntu-11-04-x-freezing-after-screensaver-active-laptop-lid-closed/ If you are already into the fix restart X by opening a tty Ctrl+Fn > root login . Type /etc/init.d/lightdm restart for Ubuntu 12.04 or later or /etc/init.d/gdm restart for others. If you are using any other display manager then restart it instead.

Howto play HD clips in PS3

PS3 cannot play HD clips encoded in the matroska format, popularly known as MKV format . PS3 mostly supports MP4 containers with h.264 video and AAC-LC audio. The good news is that the MKV is just a container for H.264 HD format video. Therefore, the video need not be re-encoded. It just have to extracted from the MKV container and pasted into the MP4 container. However, MKV files contain uncompressed audio files in the PCM/WAV format. So these audio files have to extracted and converted to the lossy low complexity AAC formats. The LC in AAC-LC stands for low complexity. It is pretty easy to do. The required steps are same for Linux, Mac or Windows but the softwares used might be different. I would focus on Linux only. The video repackaging steps are taken from  http://askubuntu.com/questions/50433/how-to-convert-mkv-file-into-mp4-file-losslessly . The audio part is mine. 1. Reconnaissance -- Find which channels contain which format.  mkvmerge --identify video.mkv File &#

Howto mix audio tracks in Audacity

Motivation : To convert uncompressed audio formats with multiple audio formats into mp3 format. LAME cannot encode WAV and PCM files (uncompressed audio formats) into MP3 which has more than 4 channels. The common error is Unsupported number of channels: 6 where 6 here is the no. of channels in the audio file. The only way to get around this is to downmix the audio to Stereo(2 channels) and re-encode using LAME. Mixing audio is very straightforward with the new Audacity. Make sure that the lame is installed in the system so that the final mix can be encoded into mp3. 1. Open the audio file in Audacity. Notice it has more than 2 channels. 2. You want some tracks on the left channel and some on the right channel. To decide where to put each track is easy. Most probably it is already encoded into the file. Look at the top left corner of each track. The Mono channel appears in both channels (same sound is sent to both the ears.) Other tracks has Right or Left men

Run Quake III Arena in fullscreen 64 bit mode with DRI enabled in a Linux OS

Quake III Arena needs minimal OpenGL drivers. The requirements are a little different for each category of video cards. I would review them all. NVIDIA and ATi Quake runs stright out of the box with these cards in latest Ubuntu's because the 64-bit drivers are in-built  but there are some hiccups. 1. Quake might open in windowed mode (if the resolution is set to a lower one like 640). To fix that set "Sticky edges" to ON in the DISPLAYS (Type "displays" in the Lens to access it.). 2. Quake might open in a huge window with all letters going out of the screen   (if the resolution is set to a higher one like 1280) . Exit quake by using the arrow keys. One up key pressed after the Start game is highlighted takes the highlight to Exit(maybe outside the screen). Press enter once. Gives Yes/No menu with No highlighted  (may not be visible on screen) . Press left arrow key once to highlight Yes (may not be visible on screen) and press enter twice. You would be

Modify EXIF info or metadata of a picture

SOmetimes the metadata / EXIF information contained in a picture taken from a camera are wrong. It creates problems when pictures from multiple cameras are made into a collage and uploaded into Piacsa. Picasa is unable to correctly sort images according to the time taken if images form of the cameras have shifted times. The following procedure shifts the time on a bunch of image files all begining with DSC. Note : - Do no do a * in the or loop. It would shift the time on all the images. TO see the EXIF info exiv2 image.jpg File name       : image.JPG File size       : 3150838 Bytes MIME type       : image/jpeg Image size      : 2592 x 1944 Camera make     : SONY Camera model    : DSC-HX5V Image timestamp : 2012:04:29 17:11:21 Image number    : .............. exiv2  -a : edits the date  ad : performs the action Now, the real code to shift time. $ for image in DSC*; do exiv2 -a 15:00:00 ad  ${image}; done source :  http://nytefyre.net/2011/11/editing-imag

Add arXiv hyperlink to bibtex in under 1 seconds

Add hyperlinks of arXiv numbers to all the bibtex entries in a bib file in under 1 second. This is accomplished by a script.  The user only needs to have a bibtex file which already has the eprint entry for every bibtex item. The rest would be handled by the script. This procedure is not necessary for some packages and bst files. it becomes necessary when specialized citation packages, like natbib, are used. Natbib generally do not include the hyperlink to the  eprint  number and some bst files for natbib like pjgsm.bst would completely ignore the eprint field. The following script would amend this situation. It basically hard codes the hyperlinked arXiv number  into the journal entry. So hen the bibtex is run the journal entry would include the hyperlinked arXiv number. I wrote this script with bibtex from the NASA ADS server in mind. Bibtex from other sources might need some modification. Critical comments and suggested improvements are welcome. NOTE !!! I deliberately d

Split and merge files

source: http://linuxpoison.blogspot.com/2008/09/split-and-merge-large-files.html split --bytes=1024m bigfile.iso small_file_ That command will split bigfile.iso into files that are 1024 MB in size (1GB) and name the various parts small_file_aa, small_file_ab, etc. You can specify b for bytes, k for Kilobytes and m for Megabytes to specify sizes. To join the files back together on Linux: cat small_file_* > joined_file.iso If it was a video file and the file would not seek then VLC can fix the video index or even better use mencoder -idx inputfile.avi outpufile.avi to regenerate the avi index

Real time temperature monitor

CAUTION : The following script might damage/burn the laptop if used incorrectly. Requires : sensors-detect , gnuplot CAUTION : The following script might damage/burn the laptop if used incorrectly. An easier way would be to use Psensor http://www.ubuntugeek.com/psensor-a-graphical-temperature-monitor.html but I want to do this manually to have greater control. The temperature monitor script -------------------------------- #!/bin/bash # CPU temperature monitor script # do not have to edit beyond this line #------------------------------------------ if [ "$1" == "kill" ] then # if command line parameter is "kill" then kill all running instances of this script. nnn=`ps aux | grep $0 | tr -s " " | cut -d" " -f2 ` echo -e $$ "\n====" # prints PID of this instance of script. make sure not to kill itself. for ii in `echo $nnn` do if [ "$ii" -ne "$$" ] then echo "Killing PID:" $

Script to bind to slow routers by persistent requests to release DHCP information

This script is to persistently nag the router to release DHCP information. The script must be run as root. This is for slow routers or one which is overloaded with clients. Do not use for normal routers. Otherwise it could be misconstrued as a security threat. persistent bind connection DHCP script ------------------------- # script to persistently nag the router to release DHCP information : must be run as root # persistent bind connection DHCP script b=`expr 1` while [ $b -lt 2 ] do echo "Starting new DHCPREQUEST .... after 5 secs ... " sleep 5 /etc/init.d/networking restart echo -e "\n xxxxxxxxxxxxxxxxxxxx \n `tail -n 20 /var/log/syslog` \n xxxxxxxxxxxxxxxxxxxx \n" if [ "` tail -n 20 /var/log/syslog | grep "DHCPOFFER" | grep "of 192"`" ] ; then echo -e "\nExiting inf. loop .............\n" b=`expr 3` fi done

Fastest way to send multiple drafts from gmail

People claim that the fastest way to send multiple email drafts is to use Gmail IMAP with email client like Outlook or Evolution or Thunderbird. But I have found this is not true. Because Thunderbird and Evolution etc. email clients treats the drafts as emails still to be edited. So it is not just simple select all and hit send. Each email draft has to be opened and sent separately. That is a lot of clicks and mouse movements, wasting precious time and energy. I have a better solution which involves minimum keystrokes and mouse usage. Efficiency booster technique for sending emails. If someone is feeling adventurous and want to try it from the Gmail interface itself, here's how to do it in the fastest possible manner. It involves using the mouse once. Select the first draft. Gmail would open a new email box and put the cursor inside the box to write. Press TAB once to go the Send button. Press ENTER to send. Now Gmail sends it and the box is gone but the highlight goes to the last

How to play movies in PS3

PS3 supports a wide variety of video formats. But there are multiple caveats regarding the playback all relating to the licensing of propriety codecs. PS3 plays avi, mp4 etc. but only some codecs like xvid are playable. mkv files will not play. If it a direct presonal copy from a DVD VOB file it can play. Also, it refuses to play some formats from external media. In that case copying to the PS3 local disk might work. PS3 is not supposed to play single video files due to DRM(Digital Rights Management). However, if some personal video like a party video is concerned and someone want to play in on a bigger TV screen rather than a PC then it is understandable. If it is laptop it might have a HDMI output so no need to go through alll the hassle. but if there are no laptops then it makes sense to use the PS3 to view videos. To view videos in PS3 it is best to encode all videos with the xvid codec. This is easily acheived with mencoder. mencoder -idx inputfile.dat -ovc xvid -oac mp3lame -la