Setting up a local Drupal development environment on Ubuntu 12.10

I’ve recently started developing with the Drupal content management framework.  I did a lot of work with Drupal in the past, but haven’t done much work with the platform since Drupal 6.  While it still feels a bit strange coming from MVC frameworks and more expressive languages, it seems like Drupal and PHP have come a long way in offering a fluid development experience in the last few years.  This is how I set up my development environment in Ubuntu 12.10, though it probably works for newer releases of Ubuntu or other Debian-based Linuxes.

# Add the PHP5 PPA
sudo add-apt-repository ppa:ondrej/php5 
sudo apt-get update

# Install PHP5.  This will also install a recent version of Apache
sudo apt-get install php5

# Install PEAR, this will make it easier to install drush
sudo apt-get install php-pear

# Install drush via PEAR
pear channel-discover pear.drush.org
sudo pear channel-discover pear.drush.org
sudo pear install drush/drush

# HACK: The first time I ran drush it needed to install some dependencies via PEAR, 
# but I ran drush as my user so I didn't have permissions to write to the global PEAR
# directory.  Work around this by running drush with sudo and then chmoding your
# ~/.drush directory back to your own user.  You can probably just install the
# dependencies using PEAR.
sudo drush
sudo chown yourusername:yourgroupname -R ~/.drush

# For local development, I like using SQLite
sudo apt-get install php5-sqlite

# drush dl/en needs crul
sudo apt-get install php5-curl

# Drupal needs GD
sudo apt-get install php5-gd

Replacing hinge in plastic-framed glasses

Broken glasses hinge

I’ve broken numerous pairs of sunglasses at the hinge where the temples connect to the rest of the frame.  As frustrating as it was to just toss the otherwise useful glasses, it just seemed like too much hassle and expense to try to fix them.  The surfaces seemed too rough and small to solder the broken hinge pieces back together, and how could you replace the entire hinge when it’s embedded in plastic? A friend really liked the look of a cheap pair of sunglasses, so she had them converted to eyeglasses by an optician, an operation that was cheaper than normal frames, but expensive enough to warrant trying a little harder to break the broken hinges.

It turns out it was relatively painless to replace the broken hinge with one from an inexpensive pair of sunglasses.

What you’ll need

  • A broken or cheap pair of sunglasses from a thrift store, gas station, or a broken pair you have lying around.  Make sure that the way the hinges mount match the glasses you want to repair and that the size of the hinge matches the connector on temple piece.
  • Soldering iron machine
  • Metal tweezers
  • Small screwdriver

Step 1: Remove the temples from the donor glasses

Using the small screwdriver, remove the temple pieces from each side of the donor sunglasses. This will make it easier remove the hinges.  When doing this, try sliding the temple piece of the glasses you’re going to fix onto the hinge of the donor glasses, to make sure they’re compatible.

Step 2: Remove hinges from the donor glasses

We’ll repeat this process to remove the broken hinge from the glasses we want to fix, so this is a good chance to practice being steady with the soldering iron, applying the right amount of heat, and removing the hinge with minimum damage to the frame, before working with our good frames.  Hold the tip of the soldering iron to the hinge piece, being careful not to touch the plastic. With your other hand, grip the hinge with tweezers.  As the plastic around the hinge melts from the heat transfer, gently pull the hinge up and out of the frame, trying to pull as straight as possible.  I didn’t have to heat the hinge very long to melt the plastic enough to extract the hinge.

Removing the hinge from the donor glasses

Repeat this process with the other hinge to practice your technique and to have an extra part in case you drop and lose one hinge.

Step 3: Remove the hinge from the glasses you’re repairing

Remove the broken hinge from the glasses you’re repairing, using the same process that you used to remove the hinge from the donor glasses.

 

Removing hinge from glasses to be repaired

Broken glasses with hinge removed

Step 4: Replace the broken hinge

Grip one of the hinges from the donor glasses with the tweezers and position it in the hole left where the broken hinge was removed.  Try to hold it as straight and flush with the rest of the frame as possible.

Inserting the replacement hinge

With your other hand, touch the hinge with the tip of the soldering iron until the plastic of the frame melts around the replacement hinge.  Be careful not to melt the plastic too much or push the hinge too deep into the frame. If needed, use the tweezers or the soldering iron tip to adjust the position of the hinge.

Positioning the replacement hinge

Step 5: Reattach the temple pieces

Using the small screwdriver, replace the temple piece. You’re done! You’ve just saved your favorite pair of glasses from the landfill.

Creating a video CD (VCD) from a YouTube video

As a Christmas gift for my father, I transferred a YouTube video of a public service announcement that he remembered fondly from his childhood to optical media so he could watch it on the television instead of on the computer.

There were some unique sets of constraints that made this an interesting project. First, I came to my parents’ house with only a Dell Mini netbook (with no optical drive) running Ubuntu Linux.  None of the computers had DVD writeable optical drives, but they could burn CDs.  My parents’ DVD player can play video CDs (VCDs) so I decided this would be a good option.

Capturing the video

I downloaded the YouTube video using the UnPlug extension for Firefox.  I chose to save the MP4 version of the video.

Transcoding the video

Since I would be burning the video on my mom’s notebook, I read the help documentation for the CD writing software to determine which video format the software needed to create a VCD.

VLC is usually my go-to tool for working with video, but I got errors about not having the correct codecs.  Rather than messing around, I wanted to just get the project done.  So, my next choice was FFmpeg.   It was a good choice because the software, though a command-line utility, has a preset for creating an mpeg file suitable for burning a VCD.

ffmpeg -i High\ Flight\ \(John\ Gillespie\ Magee\ Jr\ Poem\).mp4 -target ntsc-vcd high_flight.mpg

I was able to do this with the version of ffmpeg included with Ubuntu 10.04, but as ffmpeg is cross-platform it should be straightforward to do this on other platforms.

Burning the VCD

I copied the file to my Dropbox and downloaded it to my Mom’s computer using the services web interface.  Her burning software allowed me to just drag-and-drop the file into the burning program’s window.

Global hotkeys for VLC

For reporting, I often need to fill in my notes with a recording I made of an interview.  This means I need global hotkeys so I can start/stop the player while I’m in my word processor or note-taking program (tomboy or zotero).

VLC has native support for global hotkeys, but for whatever reason, I couldn’t get them to work to map ++ to play/pause with Ubuntu 9.10.

My workaround is based on VLC global hotkeys in Ubuntu with Compiz. But, I use VLC’s remote control interface to control the player instead of the HTTP interface as suggested in the howto.

  • Make sure netcat is installed. We’ll use this to send controls to the remote control interface of VLC.
    $ sudo apt-get install netcat
  • Open up the CompizConfig:
    $ ccsm 
  • Click the checkbox next to Commands and then click on Commands
  • In the Commands tab, type echo “pause” | nc localhost 7777 -q 1 in the Command line 0 field (or the first available field if you have other commands). This command tells the play to toggle pausing the playback.
  • In the Commands tab, type echo “rewind” | nc localhost 7777 -q 1 in the Command line 1 field (or the first available field if you have other commands). This causes the player to rewind playback a few seconds.
  • In the Key Bindings tab, click the Disabled button in the row labeled Run command 0 (or whatever command you specified in the previous steps) and set the hotkey to whatever you want (I use ++).
  • Repeat the previous step for the rewind command (I used ++ because ++ was a hotkey used by another program).
  • Close CompizConfig.

Then, if I run VLC with both the normal and remote control  control interfaces, setting up the remote control interface on port 7777 on my local machine, my global hotkey will work:

$ vlc --extraintf rc --rc-host localhost:7777

You might want to create an alias for running vlc with these options by editing ~/.bash_aliases or ~/.bashrc:

...
alias vlctranscribe='vlc --extraintf rc --rc-host localhost:7777'
...

I’m not quite sure how all the remote control commands work.  For instance, I thought the rewind command would play backwards at the maximum rate, but instead it jumps playback back a few seconds.  I thought the fastforward command would do the opposite of rewind, but instead it slows down playback incrementally.  So, for now, I just have play/pause and jump backwards hotkeys, but that’s enough to make transcribing interview recordings much, much easier.

howto make a quarter sheet daily planner from an ical file in linux

My Planner

Update: Photos of my planner! Mine is on the left, next to a moleskin to give you an idea of the relative size.  Below is what each day looks like.

Inside of my planner

I use Sandy for most of my calendaring, but don’t have a PDA or mobile phone with a convenient calendar app (and can’t afford one).  So, I needed a paper daily planner that could be generated on a weekly basis from the events that I shoot into Sandy.  I find that it’s no too hard to do a daily paper->electronic sync to update my calendar in Sandy.  Sandy has an ics export which is really nice if I want to view my appointments along with appointments from my other calendars (like my work one, managed by Webcalendar).

What you need:

  • Calendar software that supports printing a daily view (I used KOrganizer)
  • psutils package

Import your remote calendar(s)

I first imported my calendar into KOrganizer (File->Import->Import Calendar and then entered the URL of my iCal feed in the Location field) .

Print the calendar to a postscript file

I printed a page for each day of my calendar with  File->Print and then chose Print Day for the Print Style.  I selected a month worth of dates for the Date & Time Range.  I clicked Print and chose the Print to File (Postscript) option for the printer Name.  The ability to print to a file came with my default KDE setup, but it shouldn’t be too hard to get this ability from whatever printing management system you’re using.

Make the postscript file 4up

I used the psnup program to put four days on one letter sized page.

 ghing@silvertongue:~/tmp$ psnup -pletter -b0.25in -4 planner.ps planner-up.ps

The above options say that the output paper size is letter, that there should be a .25 inch margin around each page (I did this to allow for a binding on the left hand side of the sheets), that there should be 4 pages from the file planner.ps combined into every one page in the output file planner-up.ps.

Open the postscript file and print it

I used evince to open and print my planner.

Cut the pages into quarters

I used a paper cutter to cut the printed pages into quarters.  Take care to keep track of the order of pages so it’s easier to assemble your calendar.

Find a cover and a binding

For mine, I used part of the cover of a notebook that I dumpstered in Bologna and held everything together with a butterfly clip that I got from the supply closet at work.  Be resourceful!

Xubuntu Gutsy Gibbon on Dell Latitude D810

I got Rich’s old notebook from work and installed Xubuntu 7.10 (Gutsy Gibbon) see update below on it. I’m tracking issues I’m having with the distro/platform here.

Spell Checking in OpenOffice Writer – FIXED

After having this machine for a while, I just noticed this issue.  I followed some instructions I found here and tried File > Wizards > Install New Dictionaries.

Update: Volume Control Widget – FIXED

My volume control widget up and disappeared.  This post made the suggestion that instead of clicking the ‘Add’ button from the widget list (accessed by right clicking on the taskbar and choosing ‘Add New Item’), you can drag the volume control widget from the list window onto the taskbar and it works.

Update: Upgraded to 8.04

I upgraded via package updates to 8.04 (Hardy Heron) without any problems.

Can’t lock screen – FIXED

I added the screen locking widget to my top panel, but clicking it didn’t do anything. I fixed this by installing the xlockmore-gl package.

Can’t suspend/hibernate – FIXED

When I try to use the buttons to suspend/hibernate (I think these are from some gnome program), the screen goes blank, but I’m not able to resume.

Link to launchpad bug report about this issue.

Apparently, others with this laptop were able to have success by using the uswsusp package. However, they were running Feisty, not Gutsy.

Link to userspace software suspend home page.

Debian has a newer version of the uswsusp package, so I tried installing that because I found what appeared to be thorough docs on using the 0.7 version. Things still didn’t work.

I found another post on the ubuntu forums that aggregated a bunch of information about this issue. link.

I removed the fglrx video driver (a non-free driver) as this was mentioned as causing problems. After removing this driver, suspend to ram didn’t work, but hibernate did using the default login,shutdown,etc. menu. Using the s2ram program from the command line also worked!

Update: If I want to lock the screen on resuming from suspension, I use

s2ram; xlock&

Trackpad is slow

The trackpad seems to move extremely slowly. I can configure the eraserhead using the Mouse Settings panel, but this doesn’t effect the trackpad.

EVDO Card – FIXED

This was the most straightfoward thing so far. This forum thread helped my get my PC5750 EVDO card working just fine with pppd and wvdial.

Playing Encrypted DVDs

Add the following line to /etc/apt/sources.list

deb http://packages.medibuntu.org/ gutsy free non-free

Then run

sudo apt-get install libdvdcss2

Function Keys on Keyboard

These are the keys on the keyboard with additional functionality (written in blue on the keys and accessed by holding down the Fn key to the right of the left-hand-side Ctrl key) that do things like switch between CRT/LCD, eject CD media, change volume or brightness, etc.

vim cheatsheet

Extracting from a vimball

From http://vim.sourceforge.net/scripts/script.php?script_id=1502

Users of a vimball archive simply need to

:vim something.vba
:so %

and the contents of the vimball will be extracted and placed into the proper directories, no matter where the user opened up the vimball. Furthermore, the helptags command will be automatically and transparently used to make any doc/*.txt files’ contents available by the Vim help system.

Getting the filename of the currently edited file

From http://rayninfo.co.uk/vimtips.html:

:!echo %:p                        : full path & file name
:!echo %:p:h                      : full path only
:!echo %:t                        : filename only

Removing empty lines

From Vim Tip 72:

 :g/^$/d

Converting select text to lowercase

In visual mode, select text.  Then type the u key.


Fixing annoying behavior in various Linux desktop appss

I finally got off my butt and fixed a few things that had been driving me nuts with the settings on my workstation.

Weird KDE copy/select behavior

First, I use KDE, and the copy and paste behavior was driving me nuts.  If I copied text in an application with ctrl-c and then selected text with the mouse, my copied text would get clobbered by the selected text.  It turns out that the culprit was Klipper.   I made the functionality the way I wanted it by checking the ignore selection option in the Klipper configuration window (right click on Klipper icon in tray -> Conrigure Klipper).

Klipper Configuration

Default Browser for Tomboy

I like the Tomboy note taking program.  However, it was opening URLs in notes in Epiphany instead of Firefox.  Even though I run KDE for my desktop environment, since Tomboy is a Gnome app, I have to set the default browser for Gnome apps.  You can do this with the  gnome-default-applications-properties command.

ssh cheatsheat

Port forwarding

from http://www.openssh.com/faq.html#2.11

$ ssh -f -L 1234:server.example.com:6667 server.example.com sleep 10

Backing up files over SSH

$ ssh remote_host "tar -zc -C /path/to/parent/directory -f - some_directory" | cat > some_directory-`datestr`.tar.gz

Backing up a postgres database over SSH

$ ssh remote_host "pg_dump --username=db_user db_name" | gzip  > db_name-`datestr`.sql.gz

screen cheatsheet

I’ve been using the unix screen command a lot lately, and enough to want to learn more.

I used to just scroll through windows with CTRL-a n and CTRL-a p, but now I have a ton of windows in my screen session, so I want to be able to navigate easier.

According to the manpage, you can automatically set the title of a window, but I think it’s nice to do it interactively because the general task that will identify the window’s functionality might not easily be reflected in a path or command.

You can also use screen to copy/paste text between windows:

  • Enter copy mode: CTRL-a [
  • Start/End selecting text to copy: SPACE
  • Paste text CTRL-a ]