Uncategorized

Lexmark Pinnacle Pro901 on Ubuntu 13.10

From Lexmark’s site, on the Downloads tab, under Drivers, select Linux, Ubuntu 12.04 and download “32-bit Postscript Printer Description (PPD) for CUPS-based and OpenOffice Printing with Debian-based packaging” and “Printer Utility for 32-bit Linux distributions with Debian-based packaging”.  Clicking on each file brings up Ubuntu Software Center.  Click the Install button.  There’s a complaint that the “package is of bad quality” because of file ownership.  Choose “Ignore and Install”.  Remember to install both packages. After installation, fix the problem:

$ cd /usr/local/lexmark/v3/bin
$ sudo chgrp bin printfilter
$ sudo chmod 755 printfilter lxusb

To set up Cups, run the Lexmark Print Utility. It will find the printer for you.

Uncategorized

Comments Off on Lexmark Pinnacle Pro901 on Ubuntu 13.10

Permalink

Cyanogenmod 10.2 Galaxy Nexus (Verizon) Installation

  1. Create a back up with Titanium Backup
  2. Perform a Nandroid backup
  3. Download Cyanogenmod to /sdcard/0 on the phone
  4. Download Google Apps to /sdcard/0 on the phone
  5. Boot into Recovery, perform a factory reset, then load Cyanogen and GApps from Zip
  6. Reboot
  7. Sign in to Google, then Cyanogenmod
  8. Restore data as needed from Titanium Backup

Uncategorized

Comments Off on Cyanogenmod 10.2 Galaxy Nexus (Verizon) Installation

Permalink

Ubuntu 13.10 Session Dialogs

The commands to bring up the log out and shut down dialogs have changed in Ubuntu 13. What used to be gnome-session-save is now gnome-session-quit. LinuxG.net has a summary of the commands. To attach these to a hot key, run System Settings, select Keyboard, and go to the Shortcuts tab. The log out and lock screen hot keys are under System. I set Lock Screen to Ctrl-Alt-L and Log Out to Ctrl-Alt-U. Under Custom Shortcuts, I add Shut Down, and set it to run gnome-session-quit --power-off when Ctrl-Alt-Del is pressed.

Uncategorized

Comments (0)

Permalink

Editing Grub in Ubuntu 13.10

Instructions:
http://ubuntuhandbook.org/index.php/2013/08/install-grub-customizer-ubuntu-13-10/

Uncategorized

Comments Off on Editing Grub in Ubuntu 13.10

Permalink

Mounting the NAS on Ubuntu 13.10

I installed an SSD, 2GB of RAM and an upgraded battery on my Thinkpad T60.  Rather than copy my old installations to the SSD, I installed Ubuntu 13.10 via USB drive.  It went off without a hitch and, boy, is the SSD fast!  The instructions in earlier posts cover everything I’ve done so far, but the old directions to connect to the NAS are kinda sketchy, so I’m updating them here.

Install support for CIFS. It’s in package cifs-utils.
In my home directory:
$ mkdir ds411p2
As root, add this to the end of /etc/fstab:
//ds411p2/home /home/me/ds411p2 cifs user,uid=me,gid=me,rw,suid,credentials=/home/me/.ds411p2pwd 0 0
Edit /home/me/.ds411p2pwd to look like this:
username=my NAS username
password=my NAS password

$ chmod 0600 ~/.ds411p2pwd
As root:
# mount ~/ds411p2
In /home/me, replace Documents, Lyrics, Music, Pictures, Videos and any other shared directories in home with soft links to the respective directory in ~/ds411p2.

I have some shared directories on the NAS that can be accessed by anyone in the group ps411p2. To mount them, edit /etc/fstab as root and add:
//ds411p2/video /mnt/ds411p2-public-video cifs rw,suid,gid=ds411p2,credentials=/etc/ds411p2pwd 0 0
//ds411p2/music /mnt/ds411p2-public-music cifs rw,suid,gid=ds411p2,credentials=/etc/ds411p2pwd 0 0
//ds411p2/photo /mnt/ds411p2-public-photo cifs rw,suid,gid=ds411p2,credentials=/etc/ds411p2pwd 0 0

Of course, add the group ds411p2 on the client and give it to the appropriate users. You can use gnome-system-tools to do this. (It’s not installed by default.) Also as root, create the directories in /mnt.
Edit /etc/ds411p2pwd as root to look like this:
username=NAS guest username
password=NAS guest password

As root:
# chmod 0600 /etc/ds411p2pwd
# mount -a

Make sure you can see the files as you.

Uncategorized

Comments Off on Mounting the NAS on Ubuntu 13.10

Permalink

Stubbing the Application Object in Android JUnit Testing

I have an Android app that I wrote to demonstrate unit testing techniques applied to Android code.  It has standalone JUnit tests for the code that is not dependent upon Android and Android JUnit tests for the code that is.  Dependency injection is used wherever possible.  Android code is harder to mock than other platforms, however, mostly because your Activity and Application are called by the OS and don’t support parameters in their constructors.  My first tactic to inject dependencies involved passing flags in the Activities’ Intents and having each Activity set up class factories with either the production classes or stubs, depending on the value of the flags.  This proved cumbersome.  For instance, if the factory has already been given an instantiation, say, from a different activity, should a request to set a new instantiation overwrite the old one?  My next try moved the factory set-up to the Application.  Since there is only one Application object per app, this solved the multiple Activity problem.  However, creation of the Application is done by the OS and the Application lifetime might span the lifetime of multiple Activities or test runs.  I was left with the same problem of determining whose factory initialization should be honored, either the Application’s or the Android JUnit Test Case’s.  In the end, the answer was simple and I’m surprised I didn’t think of it sooner.  All I needed was a link seam.  In the Android JUnit test project, I declared an Application class with the same name and package as specified in the Android manifest.  When the Android JUnit tests run, the stub Application is invoked and does nothing.  Here, I depend on each JUnit test to set up the factories with the stubs they need.  When the actual app runs, the real Application, that sets up the factories with production classes, is invoked.

Uncategorized

Comments (0)

Permalink

Monitoring a Shell Command for Differences in Output

A few weeks ago, we experienced some fluctuations in the electric power coming in to the house. Early in the morning on weekends, the line voltage dropped and recovered repeatedly, causing my two UPSs to freak out. They switched to battery and back over and over until the battery ran dead. The utility company has since corrected the problem, but they called to ask if I’ve seen any trouble since. I can see in logs on the NAS when the NAS’s UPS switches to battery and back, but the NAS doesn’t show the UPS’s voltage. The UPSs can report line voltage, but it doesn’t store that information. Momentary status is available by running apcaccess which sends status to standard output in a format containing one variable per line like this (non-relevant sections omitted):

APC : 001,035,0863
DATE : Sat Sep 28 08:06:36 EDT 2013

[…]
STATUS : ONLINE
LINEV : 120.0 Volts

[…]
END APC : Sat Sep 28 08:06:59 EDT 2013

This morning, I wanted to watch the voltage to see how much it’s changing. I can run watch, which will run a command repeatedly and show what values have changed since watch has been running, but it doesn’t show the history of those changes. A little Internet searching came up empty for a utility that will get this job done. So, I wrote this Bash script called watchdiff:

#!/bin/bash

COMMAND="$*"
LAST_COMMAND_OUTPUT="<none>"
THIS_COMMAND_OUTPUT=""
DASHES="=========="
while true; do
	THIS_COMMAND_OUTPUT="`eval ${COMMAND}`"
	if [ "${THIS_COMMAND_OUTPUT}" != "${LAST_COMMAND_OUTPUT}" ]; then
	    echo ${DASHES} $(date) ${DASHES}
	    echo "${THIS_COMMAND_OUTPUT}"
	    LAST_COMMAND_OUTPUT="${THIS_COMMAND_OUTPUT}"
	fi
	sleep 1
done

Since I’m looking for changes in the line voltage, I run it like this:
watchdiff 'apcaccess | grep LINEV'
The parameters need to be enclosed in quotes here because otherwise the shell will interpret that as (watchdiff apcaccess) | grep LINEV, which will run watchdiff over the entire output of apcaccess, then grep for LINEV. Since apcaccess includes time in its report, the output is always different.

Lastly, to record this data, I run the command thusly:
watchdiff 'apcaccess | grep LINEV' | tee nas-voltage-report.txt

Uncategorized

Comments (0)

Permalink

APC Back-UPS ES 500 with Synology NAS

The NAS is a Synology DS411+II. The UPS is an APC Back-UPS ES 500 connected to the NAS with the supplied USB cable.
With the UPS connected to the NAS, go to the NAS’ web page (port 5000). From the top left menu button, select “System Information”. On the General tab, under External Devices, you should see the UPS. From there, go to Control Panel, select Power, select the UPS tab and select Enable UPS support.

The following instructions are based on the Synology forum post “Success with DS-209 and APCupsd UPS Monitoring“. Although the NAS can see the UPS and gets status from it, I was unable to get apcupsd to work.

To install the monitoring deamon, log in to the NAS as root:
ipkg install apcupsd
Edit the file /opt/etc/apcupsd/apcupsd.conf.
If you have more than one UPS, set the UPSNAME to keep them straight. This is optional. Change UPSCABLE to usb. Change UPSTYPE to usb and set DEVICE to blank.
mkdir -p /opt/var/lock
mkdir -p /opt/var/log
touch /opt/var/log/apcupsd.events
touch /opt/var/log/apcupsd.status

To test: apcupsd -b -d5 -T -f /opt/etc/apcupsd/apcupsd.conf. Open another shell to the NAS ans root and run apctest.

Uncategorized

Comments (0)

Permalink

Using ipkg with Synology DSM 4

ipkg is available with version 4 of Synology DSM, it’s just in a different place. To use it, log in as root and edit /root/.profile. Add the following line at the end of the file:
PATH=/opt/bin:/opt/sbin:$PATH
You don’t need to export the path as that’s done earlier in the script.

Uncategorized

Comments (0)

Permalink

Viewing Canon RAW Files in Image Viewer

The Ubuntu 10.04 Image Viewer can display Canon RAW image (.CR2) files, however, when viewing one, it doesn’t recognize other CR2 files in that directory for the purposes of displaying the next image. It does do this for other image types, such as JPEG. There is a workaround for this problem. Select all the CR2 files in Nautilus, right click one and select “Open with Image Viewer.”

Uncategorized

Comments (0)

Permalink