chrisspeck.com

Chris' random ramblings

Conditional Gallery2 Shopping Cart Block

I am in the process of developing a photography website, and for that purpose I am combining WordPress + Gallery2.

Gallery2 has a very neat shopping cart feature, which lets a viewer select images, and then purchase/download, order prints, email etc in one go.

Gallery2 comes with a “Shopping Cart Info” block (a design element) which shows the contents of the cart. If selected, this block will display itself, whether or not there is actually anything within the cart.

I thought it looked a little tacky for the site to show a shopping cart on the gallery, and sub-gallery pages when there is nothing in it.

My solution to this issue was to create a new block, called “Conditional Cart Info”, which invokes the original “Shopping Cart Info”, only if the contents of the cart is greater than 0.

It requires a modification to the file /modules/cart/templates/blocks/blocks.inc and the creation of a new file /modules/cart/templates/blocks/ConditionalCart.tpl.

You can download my modified files here or click through below to read the source code:
blocks.inc
ConditionalCart.tpl

 

Read more…

posted by specky in Downloads,Programming and have No Comments

BASH script to photocopy a page and scan to a PDF

I have been using an Epson TX110 for all of my at home printing needs for about three years. While its scanning function is good, I am absolutely sick of the way I need to keep on replacing colour cartridges even though I only ever print in black and white. My colour usage has, in fact, almost entirely been taken up by routing cleaning of the printer heads.

So, rather then spend another dollar on colour cartridges I will never use, I finally bit the bullet and purchased a laser printer.

Being a linux-geek, the first thing I did was connect it to my home server and share it with my laptop and desktop.

The next thing I wanted was the ability to link the scanner function on the Epson TX110 with the Brother laser printer, to be able to quickly photocopy a page. This is amazingly easy with bash and the right tools installed:-

#! /bin/bash
#Find the default printer, or set printer with a literal string e.g. PRINTER="HL2140"
PRINTER=`lpstat -d | awk '{print $NF}'`              
scanimage --mode gr --format tiff --resolution 300 -x 210 -y 290 | lpr -P$PRINTER -oscaling=100

All that remains is to have the ability to scan documents to PDFs…and again, bash and the command line comes to the rescue…you can download my scanpdf.bsh. It is designed for flatbed only scanners. Try running it with --help to see available options. You may click here to view the code.

posted by specky in Downloads,IT and have Comment (1)

Remember to check your Live CDs!

I was going to do a post about creating a rescue image of a Windows 7 install using OSS (Ubuntu 10.10 + PartImage) however I thought I’d post a warning about corrupted Live CDs instead.

Essentially, I tried unsuccessfully three times to install Ubuntu off a Live CD (it would always crash at the third step) before it occurred to me that I ought to check the CD for errors.

To do this you need to access the “hidden” boot menu on the Live CD, by pressing any key the following symbol comes up:

My check told me that it “found errors in 1 files!”. So I threw this CD out, burnt another Live CD (slowly – at 8 speed), checked it (“Check finished no errors found”) and low-and-behold it worked properly first time.

posted by specky in IT and have No Comments
Tags:

Remotely starting X11 apps on other displays

user@laptop:~$ ssh -X user@desktop
...
user@desktop:~$ printenv
...
DISPLAY=localhost:10.0
...
_=/usr/bin/printenv
user@desktop:~$

Take note of the “DISPLAY” variable, this is the local port (on the machine called “desktop”) which is forwarding X11 server commands to the X11 client running on the machine called “laptop”.

user@desktop:~$ export DISPLAY=:0.0
user@desktop:~$ vlc &

This sets the “DISPLAY” variable to the first screen on the desktop, and starts VLC as a background process. For this to work you must be logged into the server with the same user account, and have an X11 client running on the desktop.

user@server:~$ export DISPLAY=localhost:10.0
user@server:~$ gedit &

This sets the “DISPLAY” variable to the laptop, and starts Gedit on the server, but displaying it on the laptop.

posted by specky in IT and have No Comments

Batch application of filters in Gimp to make many old photos

I have bunch of files to which I want to apply the “Old Photos” GIMP filter.

For the uninitiated, Old Photos turns this:

into this:


This is a very simple script which will apply the Old Photos filter to every file matching the pattern you supply when you run GIMP. It has no “undo” function and it will save over the input files so be sure to make backups of the originals and only run this script on copies.

To call it you run:

gimp-2.6 -i -b "(many-old-photos \"*.jpg\")" -b "(gimp-quit 0)"

You can download make-many-old-photos.scm here or click here to view the code.

posted by specky in Downloads,IT and have No Comments