Archive for the ‘Uncategorized’ Category


Resuming stalled or held CUPS print jobs…

I have a network printer, and it’s surprising how often I print a job and then find the printer is not switched on, and the print job gets put in HOLD state. Using “lpstat -l” one can view the print job status, and with the “lp” command can resume the print job. But I’m idle, so I created this very simple script to do it all in one command – I call it “lprel”.

# script to resume the top job on the default printer queue

j=`lpstat | head -1 | cut -d' ' -f1`
if [ "$j" = "" ]; then
  echo 1>&2 "No jobs in queue."
  exit 1
echo "releasing \"$j\"..."
lp -i "$j" -H resume
lpstat -l



Happy Thanksgiving!


Installing cssutils for Python and Run an Example

The goal of this guide is to show you how to install and run the example Python script for cssutils from start to finsih. This was created while running Ubuntu, but can be applied and modified to any distribution. Open up a terminal and let’s get to it!

Step 1: Install easy_install For Python

The easy_install binary is a Python package manager that makes it easy to install cssutils. The following steps will get this installed:

sudo apt-get install curl
curl -O
sudo python

Step 2: Install cssutils Python Package

Now we’ll install the cssutils package for Python using easy_install.

sudo easy_install cssutils

Step 3: Prepare cssutils Example

Next, you can copy/paste the following example into your favorite text editor and save it (I saved it as

import cssutils

css = u'''/* a comment with umlaut � */ 
     @namespace html "";
     @variables { BG: #fff }
     html|a { color:red; background: var(BG) }'''
sheet = cssutils.parseString(css)

for rule in sheet:
    if rule.type == rule.STYLE_RULE:
        # find property
        for property in
            if == 'color':
                property.value = 'green' 
                property.priority = 'IMPORTANT'
        # or simply:['margin'] = '01.0eM' # or: ('1em', 'important')

sheet.encoding = 'ascii'
sheet.namespaces['xhtml'] = ''
sheet.namespaces['atom'] = ''
sheet.add('atom|title {color: #000000 !important}')
sheet.add([email protected] "sheets/import.css";')

# cssutils.ser.prefs.resolveVariables == True since 0.9.7b2
print sheet.cssText

Step 4: Run cssutils Example

Finally, we can run the example.



I’m hoping this guide met the goal of teaching you how to install cssutils and run an example Python script to demonstrate some capabilities of cssutils. Feedback is welcomed and appreciated.


I’m Not Dead…

To my subscribers: I’m not dead. I’m just really busy livin’ part of life. I’ve gotten some material saved up, so now it’s just a matter of getting it polished for public consumption. I’ll get back in the game soon. 😉


Whew! Many Life Changes and Not So Many Updates

Just a quick note to all of the subscribers to this blog: I’m actually going through some life changes right now (new job, new location) and I haven’t had the time for a while to update the blog as regularly as I would like to. I felt as if dropping this line would be a courtesy. I’ll be back on the bandwagon within the next week or two. 😉


The Cardboard Computer [Old-School Learning]

I’d like to take a break from our regular content to (re)introduce the Cardiac Computer. This is an old school cardboard computer that taught how CPUs/computers actually function. I’d really enjoy getting my hands on one of these (apparently, you can still buy them)! Be sure to check out the wiki page for more information.

Bell Labs CARDIAC Paper Computer

More pictures here:


A Great Countdown Script Example

Somebody over at the website posted a really good countdown script that I’d like to share with you. Specify a date and time and the script will start and display the countdown. Take a look here:


Embedding Code in HTML Page

Here’s a method for embedding code in an HTML page using a quick and painless tool called code2html. code2html is available in most distribution repositories, so installing it is just a matter of calling your package manager like yum install code2html. After installing it, here’s an example of how to use it:

code2html -l plain -o html-nocolor myprogram.c > myprogram.c.html


cat myprogram.c | code2html -l plain -o html-nocolor - > myprogram.c.html

When finished, you can then copy/paste the contents into another webpage. In my example, I chose to have a plain conversion and no colors so that I can use the <pre> tag to make my output look like I want it to.

Be sure to check out the code2html man page for plenty of other examples and usage information.