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

 

Update: Don’t even bother reading this, its way way broken. Updated post here:

http://www.codemonkies.net/linux/index.php/2009/07/21/python-vnstat-offpeak-script-version-2/

 
#! /usr/bin/env python
 
import os
import time
 
hours=[]
totalrx=0
totaltx=0
onpeakrx=0
onpeaktx=0
currenttimehour=time.strftime("%H")
 
vnstat=os.popen('vnstat --dumpdb')
for line in vnstat:
    if line.split(';')[0] == 'h':
        hours.append(line.rstrip())
 
for hour in hours:
    totalrx+=int(hour.split(';')[3])
    totaltx+=int(hour.split(';')[4])
 
for onpeakhour in hours:
    print onpeakhour
    offpeakhours=range(2,8)
    #print(offpeakhours)
    #print onpeakhour.split(';')[1]
    if int(onpeakhour.split(';')[1]) not in offpeakhours:
        #print onpeakhour.split(';')[3]
        #print onpeakhour.split(';')[4]
        onpeakrx+=int(onpeakhour.split(';')[3])
        onpeaktx+=int(onpeakhour.split(';')[4])
        #print("Rx: ",onpeakrx)
        if onpeakhour.split(';')[1] == currenttimehour:
            #print 'Breaking'
            break
 
print "Today:"
print 'Rx: %dMB %dkB' % (totalrx/1024, totalrx)
print 'Tx: %dMB %dkB' % (totaltx/1024, totaltx)
print 'Total: %dMB %dkB' % ((totalrx+totaltx)/1024, totalrx+totaltx)
print "Todays Onpeak:"
print 'Onpeak Rx: %dMB %dkB' % (onpeakrx/1024, onpeakrx)
print 'Onpeak Tx: %dMB %dkB' % (onpeaktx/1024, onpeaktx)
print 'Onpeak Total: %dMB %dkB' % ((onpeakrx+onpeaktx)/1024, onpeakrx+onpeaktx)
 

A couple of years ago my family purchased a Canon MP150, a bog standard multifunction center. It was an impulse buy, so any concern that it may not work in Linux was easily brushed aside, especially since the rest of the family still heavily used Windows XP. And it didn’t work in Linux.

But with great fortune the gutenprint project now (well, really over a year ago, but after the initial searches I gave up looking) supports the Canon MP150 as well as a sizeable list of other Canon printers.

The OpenPrinting-gutenprint drivers in ubuntu do not yet have the Canon drivers so below is how I setup the Canon MP150 driver on Ubuntu Hardy.

Visit http://www.openprinting.org/show_printer.cgi?recnum=Canon-PIXMA_MP150 and download the package you need, rpm or deb, i386 or 64bit, depending on what distro and architechture you are running.

I downloaded the ‘x86 32 bit (DEB for LSB 3.2)’ package and installed it with dpkg:

sudo dpkg -i openprinting-gutenprint_5.2.2-1lsb3.2_i386.deb

The openprinting-guntenprint package installs with all the ppd files compressed with gunzip. I am not sure if this is how they are supposed to be, perhaps more current versions of cups/gnome printer config are able to use them compressed, but in hardy they couldn’t. Instead I uncompressed the driver I needed into the same folder and selected it in the gnome print config.

First find the driver you need in the openprinting-gutenprint driver folder, replace Canon with the folder of printer brand that you are looking for if it is not a Canon printer:

dean@subspace:/opt/OpenPrinting-Gutenprint/ppds/Canon$ ls | grep -i mp150
Canon-PIXMA_MP150-gutenprint.5.2-en.ppd.gz
Canon-PIXMA_MP150-gutenprint.5.2.sim-en.ppd.gz

Next, uncompress the two files with gunzip:

dean@subspace:/opt/OpenPrinting-Gutenprint/ppds/Canon$ sudo gunzip -d Canon-PIXMA_MP150-gutenprint.5.2.sim-en.ppd.gz
dean@subspace:/opt/OpenPrinting-Gutenprint/ppds/Canon$ sudo gunzip -d Canon-PIXMA_MP150-gutenprint.5.2-en.ppd.gz

Now plug the printer in and turn it on, and head to the gnome print config under System -> Administration -> Printing, click New Printer and hopefully it should be at least partially recognised as in the screenshot below.

In your case it may autodetect the driver, in my case it only found the Turboprint driver, ugh. Instead select the Provide PPD file radio button and click on the bar below it with the folder icon. Head to /opt/OpenPrinting-Gutenprint/ppds/Canon in the location bar, or click through the path and select Canon-PIXMA_MP150-gutenprint.5.2.sim-en.ppd, choose Open then Forward.

Give your printer a name, which will appear in any print dialogs for you to choose, and if you want to, describe it as well.

Click Apply and you’re now done! You should see your printer in the list and be able to print a test page, or even try printing documents in all your favourite Linux applications.

 

If you are looking for an easy to use python script to convert your m4b audio files into ogg files, head over to Robert Penz blog where he has a great script to do exactly that.

Robert Penz Blog – Python m4b to ogg conversion script.

Thanks to Robert for the great script, I used it on a sizeable audio book file and it worked great.

 

I ended up moving my debian vmware guest folder into another partition as its original partition was nearly full. This lead to VMware prompting me with a dialog asking if I had moved or copied the folder, hinting that I should say it that I had copied it if I wasn’t sure.

Problem was that when I started up the debian guest image the network interface had gone. After a quick google I came to realise that the reason VMWare asks if the image was moved or copied is because it gives new hardware ID’s and MAC address if you’ve copied the image so the id’s do not clash if you run both the original and copied image.

The fix is to delete the MAC address from the udev config file for the network interface and after a quick restart the new MAC address was detected and the network interface was back.

udev network config file:

/etc/udev/rules.d/z25_persistent-net.rules

Many thanks to fileformat blog at wordpress.com.

 

I picked up a cheap Athlon XP cpu off trademe, not quite the best socket A cpu available as people still seem to be spending huge money on the 3000 and 3200+ barton core cpu’s, just over $100 NZ. I think it is crazy given for a little bit more you could buy an AMD X2 6000 CPU, but I guess that requires a complete platform upgrade. I settled on a way cheaper 2600+ chip and bought a $15 zalman CNPS6000-Cu heatsink which is a very pretty heatsink, fan controller, with an awkward but functional fan and rig to hold the fan above the heatsink using the PCI slot screws. It has lowered the PC temp greatly while idle, 8-10 degrees Celcius, and a reasonable amount while under load, roughly 5 degrees. I think I will leave it in ‘normal’ fan controller mode given that I’m unlikely to remember I’ve left it in silent and may not notice it running hot, but even at 2500 RPM/s its much quieter than the stock heatsink and fan.

Zalman CNPS6000-Cu heatsink installed
Zalman CNPS6000-Cu heatsink and fan installed.

 

I came across a handy blog post with a way to change your keyboard layout in X as XFCE doesn’t include any ability to natively do so. A major flaw of using X’s keyboard layout change is that it doesnt change the Control and Meta keys over to the new layout.

Which is a bit of a pain given it works changing layouts with setxkbmap on my debian + xfce ancient laptop and the Ctrl/Meta keys are for the new layout. Unfortunately while xfce works on my laptop, its a touch minimalistic for me to use on my PC, and really the fact that xfce is missing an applet to do this for you is all part of that.

Maybe when I become code-worthy I will hack up a language changing applet for xfce.. and modify all the other little things that annoy me. http://ubuntu.sabza.org/2006/10/13/xubuntu-easily-switch-keyboard-layout/

Edit:

Luckily Alexander Iliev has come along and written a very handy xfce panel app (based off earlier work of Gauvain Pocentek) that will allow you to easily add/remove and change keyboard layouts. I would have to say it was one of last remaining issues stopping me from using XFCE on my desktop and now that I’ve installed Debian on there I use XFCE instead of Gnome. Great stuff.

xfce4-xkb-plugin: http://goodies.xfce.org/projects/panel-plugins/xfce4-xkb-plugin

DV = dvorak keyboard layout

XFCE kb applet

 

I have moved the blog from my domain brokendream.net/wordpress to codemonkies.co.nz/linux .

Codemonkies.co.nz is a project my friend and I came up with, and so far I have been greatly lacking towards it so I thought moving the blog here was a better start, plus the domain is cool! Further, if I can create a good looking WordPress theme as planned, there would be no reason not to transfer it to the whole codemonkies webpage.

I also plan on making this a mostly linux and technical focused blog, so it fits closer with the cm (codemonkies) domain name. This also requires a name change, but am still thinking over different ideas so it may change a few times.

The next thing I need to do is an apache mod_rewrite to pass all of the brokendream.net/wordpress/* addresses to cm.co.nz/linux/ which shouldn’t be too hard, and will preserve all, even while minimal, search traffic to the blog.

 

Cleaning out my Opera tabs I came across two tabs that I had been meaning to post about while working on my last Web Programming assignment.

The first one is a very handy validator for validating XML against its DTD. If you’re writing a custom DTD file you will need to make sure the DTD file is uploaded somewhere on the web where the script can access it to compare against the XML, otherwise it should work against already publicly available DTDs.

http://www.stg.brown.edu/service/xmlvalid/

The second tab is simply a great XML and DTD reference website.

http://www.rpbourret.com/xml/xmldtd.htm

© 2012 Linux Sand Garden Suffusion theme by Sayontan Sinha