I struggled with this for a while, and I think the main trouble I had was with selecting the correct PPD file for CUPS. These commands mainly came from this Ubuntu-fr guide.

  • Get the Linux drivers from Canon. (These are for LBP7010C.)
  • Extract the archive:
$ tar xvzf Linux_CAPT_PrinterDriver_V270_uk_EN.tar.gz
  • The guide mentioned above suggests that Glade is a dependency:
$ sudo apt-get install libglade2-0
  • Before installing the drivers, install these 32-bit packages:
$ sudo apt-get install libatk1.0-0:i386 libcairo2:i386 libgtk2.0-0:i386 libpango1.0-0:i386 libstdc++6:i386 libxml2:i386 libpopt0:i386
  • Navigate to the folder containing the Debian package (64-bit in my case) and install the common and capt drivers:
$ sudo dpkg -i cndrvcups-common_3.20-1_amd64.deb cndrvcups-capt_2.70-1_amd64.deb
  • Now install the driver in CUPS:
$ sudo /usr/sbin/lpadmin -p LBP7010C-7018C -m CNCUPSLBP7010CCAPTJ.ppd -v ccp://localhost:59787 -E

Note that I’m using the CAPTJ driver rather than the CAPTK (CNCUPSLBP7018CCAPTK.ppd) driver recommended in the Canon README file - it refused to work when I tried the CAPTK driver. * Now add the printer to ccpd (the printer daemon for CUPS):

$ sudo /usr/sbin/ccpdadmin -p LBP7010C-7018C -o /dev/usb/lp2

You’ll need to check the USB connection to the printer before running this:

$ lsusb

to make sure it is connected, and:

$ ls -l /dev/usb/lp* /dev/bus/usb/*/*

you can also check if CUPS detects the printer:

lpinfo -v
  • The guide also suggests the following addition to /etc/init.d/ccpd directly after the first two lines:
### BEGIN INIT INFO
# Provides: ccpd
# Required-Start: $ local_fs remote_fs $ $ $ $ network syslog named
# Should-Start: $ ALL
# Required-Stop: $ syslog $ remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start Canon Printer Daemon for CUPS
### END INIT INFO
  • It is also worth checking that the device path is correctly defined in /etc/ccpd.conf:
<Printer LBP7010C-7018C>
DevicePath /dev/usb/lp2
</Printer>
  • And that ccpdadmin has correctly verified the record:
$ sudo ccpdadmin
  • Finish by starting ccpd:
$ sudo ccpd service start
  • You can check the status of the printer using:
$ captstatusui -P LBP7010C-7018C

It is also worth noting that the USB connection to my printer only works when I restart the printer (i.e. if the printer is on and the computer is restarted the USB connection to the printer is not picked up).

Another one I always forget - how to create a new Postgres database and user for a new Django app. This is possible in one step as long as your Postgres configuration allows you to connect as the ‘postgres’ user:

$ createdb -Upostgres name-of-database

Mine does not so I first switch to the ‘postgres’ user and run the following:

$ sudo -i -u postgres

Then use the ‘createdb’ and ‘createuser’ commands:

$ createdb name-of-database
$ createuser -P name-of-user

Then start psql and grant privileges to the user:

$ psql
postgres=# GRANT ALL PRIVILEGES ON DATABASE name-of-database TO name-of-user;

I’m documenting this because I always forget. To use psql (the postgresql command line tool) you will first need to log in as the postgres user. There is a nice tutorial here.

To change to the postgres user:

$ sudo -i -u postgres

Start psql:

$ psql

In one step:

$ sudo -u postgres psql

The context for this is testing in Django, where a test database needs to be created. A permission denied error can occur if the user (not OS user) that owns the database does not have permission to create databases (I created the database and user via psql). Firstly log in as the postgres user (i.e. with the username ‘postgres’) and then use psql to alter the database ower.

To give the postgres user permission:

postgres=# ALTER USER username CREATEDB;

Don’t forget the trailing semi-colon.

On a couple of occassions I’ve found myself needing to set an active selector on a nav bar item using Javascript; this post documents how this was done. I have used this technique in both a straight-forward side-bar nav and on a Bootstrap styled nav bar for a Django app.

It is simply done using a bit of Jquery and works as follows:

In the case of a simple nav bar (made of <a> tags inside <li> tags)

$(document).ready(function() {
	$(".sidebar [href]").each(function() {
		if (this.href == window.location.href) {
			console.log(this)
		    $(this).addClass("active");
	    }
	});
});

In the case of a Bootstrap navbar it is also necessary to take care of click events

// add 'current' to <li> tag
$('.main-nav ul li a').each(function() {
  if (this.href == window.location.href) {
      $(this).closest('li').addClass('current');
  }
});

// respond to click events
$('.main-nav ul li a').click(function() {
    $('ul li.current').removeClass('current');
    $(this).closest('li').addClass('current');
});