Tag Archives: snippet

Play or open newest file from the linux command line

In some cases it is convenient to have a shortcut to open the newest file in a directory. Maybe the last show your dvr recorded, or the last file you bought from amazon.

For these cases I found this little bash snippet useful:

ls -tr | tail -n 1 | xargs -I FILE kde-open "FILE"
Posted in Computers | Tagged , | 2 Comments

ytplay – wrapper for youtube-dl.py

Due to my slightly outdated computer flash is a huge problem. So, for viewing youtube videos, youtube-dl.py is a great solution. However, I wanted something more comfortable.

ytplay wraps around youtube-dl.py, it searches for a video, orders youtube-dl to get it, and starts playing it in vlc.

Usage is simple:
> ytplay foobar
will search youtube for videos about foobar and play the first one found.

The code is still quite dirty, especially the subprocess part. However, it should work, have fun!

Posted in Computers, Internet | Tagged , , | Leave a comment

Deleting multiple tables with a common prefix

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
//Connect to the database server and select our database
$link = mysql_connect('rdbms.strato.de', 'UXXXX', 'epsilon eridani') 
	or die('Could not connect: ' . mysql_error());
mysql_select_db('DBXXXX') or die('Could not select database');
 
//get table list
$result = mysql_query("SHOW TABLES") or die(mysql_error());
 
//kill tables
$tokillprefix = "jos_";
while($row=mysql_fetch_array($result)){
 	if(substr($row[0],0,strlen($tokillprefix)) == $tokillprefix){
	 	echo "killing $row[0] <br>\n";
		mysql_query("DROP TABLE $row[0]") or die(mysql_error());
	}
}
 
?>done
Posted in Computers | Tagged , , | Leave a comment