Skip to main content

Posts

Convert file listing to database format

Let us say we have a collection of ebooks or papers/articles sorted in various folders and we want to create a database (or spreadsheet) of those papers or books so that we can add comments or notes next to them.

For example, let us say we have a file structure like (find . type f)

./entanglement-entropy-holography/1006.1263.pdf
./entanglement-entropy-holography/0912.1877.pdf
./entanglement-entropy-holography/0911.3160v2.pdf
./entanglement-entropy-holography/0912.1877v2.pdf
./entanglement-entropy-holography/1010.1682.pdf
./graviton-propagator/zee-1979-PhysRevLett.42.417.pdf ./graviton-propagator/dewitt-3-PhysRev.162.1239.pdf ./graviton-propagator/dewitt-2-PhysRev.162.1195.pdf ./graviton-propagator/dewitt-1-PhysRev.160.1113.pdf ./SUSY/Piguet-9710095v1.pdf ./SUSY/Olive_susy_9911307v1.pdf ./SUSY/sohnius-introducing-susy-1985.pdf ./SUSY/khare-cooper-susy-qm-phys.rept-1995.pdf ./SUSY/Instantons Versus Supersymmetry9902018v2.pdf
and we want this list to be converted to a database format.

Ar…
Recent 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.
When extracting f…

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 the drive which will initialize it.

$ sg_raw /dev/sr0 EA 00 00 00 00 00 01

Insert a di…

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 onunload js handler independently of the GUI.
3. Smooth …

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