Skip to main content

Posts

List files with absolute pathname in linux

ls -d $PWD/* $PWD/* expands the absolute path of the present working directory and appends the directory listing of * to it. ls displays that list while -d prevents ls from going into each directory in that list and recursively listing all sub-directories. We can also print filelist of all sub-directories relative to current directory. find . -type f

Ripping videos from DVD using Handbrake

We will use Handbrake to save DVD videos on an external hard disk. A smart TV can play the videos when the hard disk is connected via the USB port. A word of caution - only output to mp4 format. TVs usually do not support many formats but most of them support mp4. Here is the procedure to rip the DVD videos. 1. Insert DVD 2. Open Handbrake and Select "Source"  3. Select the DVD disc Handbrake will start analyzing the DVD file for video content. If it doesn't’ (sometimes it takes a few tries) then repeat above step and select the DVD drive as source again. It will look like this while it is scanning  Once it is done scanning we will begin the process of extracting the videos (titles). Now this DVD has 6 episodes. We will select each track, apply a video profile to it, and then enqueue it to the encoding queue. The video profile selects the encoding parameters which produce the optimal video file of the smallest size without compromising on the quality. Wh...

Use apple DVD drive (superdrive) in Linux

Attach DVD drive See if it is recognized $ dmesg | tail [357251.566256] scsi 8:0:0:0: CD-ROM            Apple    SuperDrive       2.00 PQ: 0 ANSI: 0 [357251.594859] sr 8:0:0:0: [sr0] scsi3-mmc drive: 24x/24x writer cd/rw xa/form2 cdda tray [357251.594867] cdrom: Uniform CD-ROM driver Revision: 3.20 [357251.595222] sr 8:0:0:0: Attached scsi CD-ROM sr0 [357251.595424] sr 8:0:0:0: Attached scsi generic sg1 type 5 Now check the dev folder to see what device id is assigned to the apple drive $ cd /dev/ $ ls -l sr* brw-rw----+ 1 root cdrom 11, 0 May 22 20:49 sr0 See if the device showed up as sr0. If the drive is identified as sr1 (in case you have another DVD drive plugged in already) then replace sr0 by sr1 in the following commands. Make sure sg_raw is installed ($ which sg_raw). If it is not installed then install it first by $ sudo apt-get install sg3-utils Use the following command to send bytes to ...

Print chess board in command line

The following bash one-liner will print a chess board in a terminal (the script works for the shells bash and ksh only) for (( i = 1; i <= 8 ; i++ )); do for (( j = 1 ; j <= 8; j++ )); do tot=`expr $i + $j`; tmp=`expr $tot % 2`; if [ $tmp -eq 0 ]; then echo -e -n "\033[47m  ";  else echo -e -n "\033[49m  ";  fi;   done; echo -e -n "\033[49m"; echo "" ; done; echo -e -n "\033[49m \n"                                                                                                                                

Chrome (hidden) useful settings

1. Override software rendering list  Overrides the built-in software rendering list and enables GPU-acceleration on unsupported system configurations. #ignore-gpu-blacklist When is this needed? When Chrome is not using hardware acceleration To verify if Chrome is using hardware acceleration type in chrome://gpu/. If it says  Canvas: Software only, hardware acceleration unavailable Then is clear that Chrome is not using hardware acceleration. To enable hardware acceleration  Search for "hardware" and tick the checkbox for "Use hardware acceleration..." in chrome://settings Enable "Override software rendering list" in chrome://flags/ Source: https://ubuntuforums.org/showthread.php?t=2259882 Relaunch Chrome. type in chrome://gpu/. If the message has changed to Canvas: Hardware accelerated Then Chrome is using hardware acceleration. 2. Fast tab/window close Enables fast tab/window closing - runs a tab's onu...

ttf-mscorefonts-installer error from update notifier

Error message at login: Failure to download extra data files The following packages requested additional data downloads after package installation, but the data could not be downloaded or could not be processed. ttf-mscorefonts-installer Solution: 1. Purge ttf - mscorefonts -installer $ sudo apt-get remove --purge ttf-mscorefonts-installer 2. Remove the partial folder containing partial download in /var/lib/ $ cd /var/lib/update-notifier/package-data-downloads $ sudo rm -rf partial 3. Install ttf-mscorefonts-installer and make sure to select “YES” to the EULA $ sudo apt-get install ttf-mscorefonts-installer

Removing audio noise from a video

The basic steps are to extract the audio, remove noise, and then re-insert the noise-free audio back into the video wrapper. Step I: Extract the noisy audio 1. Open Audacity 2. Open the video file in Audacity 3. Select a region of pure background noise (which should be periods of silence). Then use the Audacity menu to select Effects -> Noise reduction 4. Select Get Noise Profile (Important: don’t click ok) 5. Then go back to the waveform and select the entire waveform 6. Again select Effects -> Noise reduction 7. But this time just click ok 8. Audacity will work on the file to reduce the noise. Check the region selected before to see if noise is removed/reduced 9. Repeat the steps #3 to #7 as many times as necessary till all noise is gone 10. Now Export the file to mp3. Make to change the extension as Audacity uses “aiff” even when the file type is selected to be mp3. Step II: Remove audio from video file 1. Go to the folder containing th...
dpkg: error: duplicate file trigger interest for filename `/usr/lib/gio/modules' and package `libglib2.0-0:i386' The dpkg trigger file has duplicates. We would need to manually remove all of them. $ cd /var/lib/dpkg/triggers/ $ sudo vim File /usr/share/octave/packages octave /usr/lib/libreoffice/share/extensions libreoffice-common /usr/lib/x86_64-linux-gnu/gio/modules libglib2.0-0 /usr/lib/gio/modules libglib2.0-0 /usr/share/glib-2.0/schemas libglib2.0-0 /usr/lib/i386-linux-gnu/gio/modules libglib2.0-0:i386 /usr/lib/gio/modules libglib2.0-0:i386 /usr/share/glib-2.0/schemas libglib2.0-0:i386 /etc/dbus-1/system.d dbus/noawait /usr/share/dbus-1/system-services dbus/noawait /usr/lib/vlc/plugins vlc-nox/noawait Notice the duplicates in bold. Remove them manually. If there are many duplicates then a quick way to see the duplicates is to run $ cat File | cut -d " " -f 2 | uniq -c 1 octave 1 libreoffice-common 3 libglib2.0-0 3 ...

Common questions on climate change

1.  Are renewable energy systems even viable or are they just an Utopian dream of impractical scientists? And even if they are viable wouldn’t it cost an arm and a leg to make them viable? Among the multitude of scientific journal articles, which answers both these questions separately, one article answers both these questions succinctly in a single paper. In 2011 Jacobson et al. proposed a 100% WWS (wind, water, solar) energy system which can supplant the current fossil fuel industry. They found that production cost of WWS is exactly same as current fossil fuel-derived energy systems and that includes costs of production, storing, and transmission (with transmission losses). Their conclusion is that “ … barriers to a 100% conversion to WWS power worldwide are primarily social and political, not technological or even economic.” 2. Which countries invest the most in renewables? The current standing (May, 2017) is: www.businessinsider.com/top-renewable-energy-inv...

Command-line password generator for Linux

Linux has its own cryptographic generator which can easily be harnessed by the common user to generate extremely strong passwords. This password generator can be found at /dev/random. /dev/random generates pseudorandom numbers based on the available entropy of the system (see wiki page ). A derivate of /dev/random called /dev/urandom does the same thing but it is more accessible while being slightly (theoretically) less secure. So what stops us from grabbing outout from /dev/urandom using cat ? An output of the content of /dev/urandom will demonstrate that it is practically gibberish with very few usable random characters. The output of cat / dev / urandom should convince the user.  However, it is possible to trim out the unwanted characters and only keep alphabets, numbers, and special characters with a simple filtering by the tr command. cat / dev / urandom | head - c 10 | tr - dc "A-Za-z0-9_!" This command will produce the desired output but it w...