YouTube video to text
[manjaro] disable the screensaver temporarily
Problem
I have an old laptop connected to our TV that I use for watching downloaded movies / YouTube videos, etc. When watching YouTube videos for instance, the screensaver kicks in after a while. How to disable the screensaver temporarily?
Solution
The package “caffeine-systray
” solved the problem (available in AUR). It starts automatically and sits in the system tray. Right click on it and select “Disable Screensaver”. That’s all.
Update (20150130)
“caffeine-systray” seems to be deprecated. The up-to-date version is called “caffeine-ng”, so you should install that instead.
dropbox: command-line interface
Problem
I wanted to test the status of my Dropbox client from the terminal. Actually, I wanted to write a script that executes an action when my Dropbox folder is fully synced. So I wanted to test the status if it’s “working” or “synced”.
Solution
I found the solution here. It turned out that Dropbox has an official command-line script that can do this and much more. First, get it:
wget -O ~/dropbox.py https://www.dropbox.com/download?dl=packages/dropbox.py chmod u+x ~/dropbox.py ~/dropbox.py status
This is a Python script, written in Python 2, thus I modified the first line to be “#!/usr/bin/env python2
“.
This script can do several things for you:
$ dropbox.py Dropbox command-line interface commands: Note: use dropbox help to view usage for a specific command. status get current status of the dropboxd help provide help puburl get public url of a file in your dropbox stop stop dropboxd running return whether dropbox is running start start dropboxd filestatus get current sync status of one or more files ls list directory contents with current sync status autostart automatically start dropbox at login exclude ignores/excludes a directory from syncing lansync enables or disables LAN sync
Some years ago I wrote a simple script to get the public URL of a file in my Dropbox folder. This script can do that too with the “puburl” command.
reddit from the terminal
There is a command line interface for Reddit called “rtv” (reddit terminal viewer). It’s written in Python, so you can install it with pip
.
Here is a short youtube video on how to use it.
[manjaro] ping needs special privileges
Problem
$ ping -c 1 www.google.com ping: icmp open socket: Operation not permitted
Solution
$ sudo chmod u+s `which ping` $ ping -c 1 www.google.com PING www.google.com (173.194.65.104) 56(84) bytes of data. 64 bytes from ee-in-f104.1e100.net (173.194.65.104): icmp_seq=1 ttl=45 time=38.6 ms --- www.google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 38.681/38.681/38.681/0.000 ms
replace a string recursively in multiple files
Problem
In a folder I have lots of files, and the folder also has subdirectories with further files. I want to replace a string in all of them. I want to modify the files in place.
For instance, you want to update a bunch of Python scripts from version 2 to version 3, thus you want to modify the first lines from “#!/usr/bin/env python2
” to “#!/usr/bin/env python3
“.
Solution
I found the solution here:
grep -rli 'old-word' * | xargs -i@ sed -i 's/old-word/new-word/g' @
WARNING! Since it modifies the files in place, be very careful! First run just the beginning of the command above:
grep -rli 'old-word' *
Refine it if necessary. If it finds exactly what you need, then proceed.
check a new HDD for bad blocks
Problem
You buy/get a new HDD and you want to make sure that it has no bad sectors. How to check that?
Solution
I found a solution here. In short:
sudo badblocks -wvs /dev/sdx
where /dev/sdx
is the drive. WARNING! This is a destructive check, i.e. all data on the drive will be lost!
“The -w option tells badblocks to write a known pattern, then read back the data to make sure it matches the pattern. It does this 4 times, using the patterns 0xaa, 0x55, 0xff, and 0x00 (alternating 0’s and 1’s, then all 1’s, then all 0’s). Note that this will overwrite all data on the drive and wipe out all the partitions, as well.” (source)