Occasionally I need to extract a source tarball to a subdirectory without its leading path directory and every time I need it I forget the necessary GNU tar switches, so here is todays lesson in the two tar switches required.

tar --strip-components 1 -xvf package_1.1.tar.bz2 -C package

“–strip-components 1″ will strip off the first (1) folder of the archives path. Replacing 1 with 2 will do the obvious and strip off 2 folders/preceding path components.

“-C package” is nice and simple, it will extract the archive into the folder package. You could be fancy and do “-C ~/source/package” and extract the archive anywhere you fancy.

 

A really simple guide to ripping the audio out of a DVD using transcode to wav or mp3.

http://www.ubuntugeek.com/how-to-rip-dvd-audio-to-mp3-or-ogg.html

 

After a boring moment and coming across a little guide video on youtube that used Windows 7 with the rotating desktop wallpapers, I decided to see if I could make rotating wallpapers work in XFCE. A quick google search later and I came across this simple guide: http://www.linuxjournal.com/content/creating-slide-show-backgrounds-xfce

I only had to tweak the cron job line to stop the command output going to system mail every time it ran, and it all worked as expected.

My crontab line: */5 * * * * /usr/bin/xfdesktop –display=:0.0 –reload >/dev/null 2>&1

Another interesting way that doesn’t use cron is described here:

http://rockhopper.dk/linux/software/xfce/xfce-auto-rotate-wallpaper-without-cron/

 

If you have to install CentOS, or you just want to have a nosey, the best way to install it is using the Netinstall CD.

I followed this little guide: http://www.chrisgountanis.com/technical/45-centos-netinstall.html, and it worked out great.

I chose the raw base system install in the graphical installer. It downloaded about 400-500mb of data, installed the packages and after a quick reboot left me with a console screen in vmware, exactly what I wanted.

The only trick was to make sure I was pointing to the right folder in the mirror’s ftp/http directory.

 


When a member of an irc channel I lurk in talked about signing up to the Palm Developer forum this sparked my curiosity about the Palm Pre Developers Kit. So I had a little nosey around the Palm website to see if they had a Linux version of the SDK, which they do. Palm use virtualbox as the virtual machine which is easy to install as well as providing an Ubuntu package for the Pre image. While packaged for Ubuntu also installs with no trouble on Debian squeeze.

The last required package is novacom, the debug/control server required to control the Pre virtual image and let you install any applications you write for the Pre onto the virtual image. This package unfortunately takes advantage of Ubuntu using the Upstart init system instead of init.d as in Debian so does not install cleanly. One option you could take is to uncompress the package and manually install/run the novacom binaries. I chose however to write a simple replacement startup script for init.d, which hopefully is fully functional, and repackage it following this blog post:

http://binaryunit.blogspot.com/2008/01/dist-upgrade-goes-segmentation-fault.html

The Debian package starts novacomd with the init script exactly as the Palm package does using Upstart but also cleanly stops novacomd and should purge the init.d script when purging the config during package removal.

Grab the package here: palm-novacom_0.3-svn177284-hud9_debian_i386

Edit: This package badly fails Lintain and the packaging guidelines, I will try and clean that up and post a more clean package soon fingers crossed.

Edit: Fixed! Mostly ;)

 

Rxvt is a great terminal. When I needed a light weight terminal that supported unicode on my ye olde laptop, rxvt was the answer.

When combined with the font Terminus it quickly became my terminal of choice on the PC as well, but back to the topic at hand. Using a large monitor resolution leaves alot of unused screen real estate and one of the common action I would do with my terminal windows was to tile them, lining each terminal window up against the edge of the screen, and then dragging them half way.

This quickly becomes rediculous manually adjusting windows each time you boot. I searched for ways of tiling windows in XFCE a number of times but either came across posts about using applications to do the tiling or going the the whole way and using a tiling window manager like awsome.

Fortunately last week while exploring the vast rxvt-unicode documentation, trying to solve another issue I came across the geometry command line option.

My terminal tiling is simply two terminals taking up half the desktop each and I use a seperate shortcut for the tiled windows and a generic window, with XFCE’s window management nicely placing the two terminals side by side.

Here is my tiled rxvt command line options from my terminal shortcut:

rxvt-unicode -bg black -fg white -vb -sl 10000 -fn "xft:Terminus" -geometry 102x62

 

As I have mentioned in other posts the ISP plan I have features a higher cost per GB than their regular pay as you go plan, but gives 75 gigabytes free transfer during the offpeak times of 2am-8am. This generally end up working out really well cost wise for me, but most of the traffic measuring tools measure on a day by day basis. Given my delirious state at the time, my previous little vnstat python script was appalling, and doesn’t even work. So here is the new improved version.

'''
VNStat Onpeak/Offpeak calculator
Author: Nameeater
Url: http://www.codemonkies.net/linux
Use: Calculates the data usage during Onpeak, 8am-2am,
     and Offpeak, 2am-8am, using vnstat.
'''
 
#! /usr/bin/env python
 
import os
import time
 
 
totalrx=0
totaltx=0
onpeakrx=0
onpeaktx=0
offpeakrx=0
offpeaktx=0
current_hour=time.localtime()[3]
hour_data=[]
 
vnstat=os.popen('vnstat --dumpdb')
data=vnstat.read()
 
for lines in data.split('\n'):
    if "h;" in lines:
        hour_data.append(lines)
 
for i in hour_data:
    h=i.split(';')
    if int(h[1]) > current_hour:
        break
    if int(h[1]) not in range(2,8):
        #debug print h[1], h[3], h[4]
        onpeakrx+=int(h[3])
        onpeaktx+=int(h[4])
    elif int(h[1]) in range(2,8):
        offpeakrx+=int(h[3])
        offpeaktx+=int(h[4])
 
print time.ctime()
print "-"*6
print "Offpeak Rx: ",offpeakrx/1024, "MB."
print "Offpeak Tx: ",offpeaktx/1024, "MB."
print "-"*6
print "Onpeak Rx: ",onpeakrx/1024, "MB."
print "Onpeak Tx: ",onpeaktx/1024, "MB."
print "-"*6
print "Total Onpeak: ", (onpeakrx+onpeaktx)/1024, "MB."
print "-"*6
 

You can either check if a variable has been defined through exceptions, such as:

try:
    myVariable
except NameError:
    print "myVariable has not been defined."

Or use the locals() and globals() functions to check if the variable has been defined in the matching scope.

if 'myVariable' in locals():
    print "myVariable has been defined."
 
if 'myVariable' in globals():
   print "myVariable has been defined."

This took a little searching to find, but I found the answer over at stackoverflow:

http://stackoverflow.com/questions/843277/python-checking-variable-existing.

 

Given my limited budget for broadband it was great news when my ISP offered a plan with free offpeak traffic up to 75 gigs a month. I already left my gateway server up overnight so it was easy to setup anything I may download as a scheduled download using the at command and a cron job to killall any application left downloading when the offpeak time ends at 8am.

One of the biggest thing I needed to download during offpeak was debian packages for my desktop, either for upgrade/dist-upgrade’s or installing sizable packages like OpenOffice.org. I needed to be able to download those packages on my gateway box, so I poked around with apt’s man page and came across –print-uris. This lead to the following little snippet to generate a file of url’s to point at wget or aria2 to download:

sudo apt-get -y --print-uris update | grep 'http://' | awk '{print $1}' | sed "s/'//g" > filename.txt

Note: I had to use –force-yes when running dist-upgrade on lenny.

 

Recently an FTP server I connect to enabled SSL access which is great, FTP needs any extra protection you can give it.

Unfortunately lftp started to hang on ‘FEAT negotiation…’ when non-SSL connections were disabled while ftp:ssl-force was set in ~/.lftp/rc. After doing a little searching on google the I found the extremely simple answer that you need to connect to your SSL enabled ftp servers as

ftps://ftp.domain.com:21

so update your bookmark file (~/.lftp/bookmarks) and get connecting.

Answer found here: http://www.mail-archive.com/lftp@uniyar.ac.ru/msg02576.html

© 2012 Linux Sand Garden Suffusion theme by Sayontan Sinha