Archive

Archive for September, 2015

YouTube video to text

September 28, 2015 Leave a comment

[manjaro] disable the screensaver temporarily

September 12, 2015 Leave a comment

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.

Categories: manjaro Tags: , ,

dropbox: command-line interface

September 12, 2015 Leave a comment

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.

Categories: bash, python Tags: , ,

reddit from the terminal

September 7, 2015 Leave a comment

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.

Categories: bash, linux, python Tags: , ,

[windows 10] hide the update icon

September 6, 2015 Leave a comment

How to hide the Windows 10 update icon on the system tray: http://lifehacker.com/how-to-hide-the-get-windows-10-icon-from-your-taskbar-1708536452 . In short: click the little “up” arrow on your system tray and select Customize. “From there, change GWX’s dropdown to “Only show notifications”. It’ll still show up in your pop-up system tray, but not on the taskbar itself…” (source)

Categories: windows 10 Tags: , , ,

[manjaro] ping needs special privileges

September 5, 2015 Leave a comment

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
Categories: bash Tags: , ,

replace a string recursively in multiple files

September 4, 2015 Leave a comment

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.

Categories: bash Tags: , , ,

check a new HDD for bad blocks

September 1, 2015 Leave a comment

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)

Categories: bash, linux Tags: , ,