The web, with (your) Style

 

delorean_dmc-12_side
DeLorean DMC-12 (Credits: Photo by Kevin Abato, www.grenexmedia.com, edited by me.

While the web (besides time machines) is styled much nicer than ever, this does not always mean, it’s your style, nor that user experience is much better for you.

Two powerful tools, UserStyles and Greasemonkey (Tampermonkey for Chrome), come to help. They both inject additional functionality (CSS and/or JavaScript) into existing websites, allowing to transform or extend their use.

In my spare time, I have created some (hopefully) handy scripts and styles:

A slimmed down StackExchange

stackwatchersTo get rid of the distracting side bar on some of the StackExchange sites, I have created the StackWatchers user style. This also improves the reading experience on narrow windows.

Better UX with NxFilter

nxfilter_with_colorTo have a better visual distinction for blocked requests by the DNS filtering tool NxFilter, I have created NxFilterColorizer, a user script that colorizes the table row depending on the block indicator text. It also applies a CSS class that allows further styling with a user style.

Global wait indicator

Having a wait indicator is often useful. The waitin.user.js script gives you a global wait indicator for any website at once. (This is in ALPHA state, use with caution).

Installing the Samsung C480W printer on Ubuntu Linux

tl;dr; As Linux user, do yourself a favor and consider the Samsung C480W printer.

I wanted to get rid of my old HP PSC 1215 All-in-One Printer.

HP PSC 1215 All-in-One Printer
HP PSC 1215 All-in-One Printer

It served me well over all these years, both with Windows and Ubuntu Linux. But, getting tired of replacing empty or clogged ink cartridges all too often I considered buying a laser printer. I chose the Samsung Xpress C480W A4 Color Laser Printer.

Samsung Xpress C480W A4 Color Laser Printer
Samsung Xpress C480W A4 Color Laser Printer

Installing a printer on Linux – a nightmare. Or is it?

Not with this one, I can say. The “Easy printer installation” does not promise too much. Here’s what it took me:

  1. Attach the printer to the mains and the local LAN. Switch it on.
  2. Download the appropriate driver package from the Samsung setup page with the Linux box. The website presents the Linux driver package (probably guessed from the User Agent string) right away.
  3. Extract the package.
  4. Run sudo ./install.sh

    Installing the printer driver with the bash shell
    Installing the printer driver with the bash shell
  5. Accept the EULA (This is the most inconvenient part as you are required to accept it line by line…)
  6. Install the printer using the Ubuntu printer Dialog. It will automatically get recognized on the network.

    The Ubuntu 14.04 Add printer dialog
    The Ubuntu 14.04 Add printer dialog
  7. Done. Feel the relief and joy of printing and scanning using your favorite OS.

Here’s how my first test page looks – scanned with the same printer again. 🙂

Scanned Document
A scan of the first print test page.

 

 

Controlling a Playmobil® crane over ssh

One of my sons recently received this fine, Infrared (IR) remote controlled crane model as a gift. Would it be possible to rebuild the IR remote control with a Raspberry Pi?

Catching the signal

To build the IR-Transmitter I used the well-known LIRC library and this small IR receiver sensor from Adafruit. For emitting back the IR I just recycled an IR-Diode from an old JVC remote control unit and directly attached it to one of the GPIO ports the Raspberry Pi.

setup-caseopen-lq
Connecting an IR-LED and an IR-Sensor to the Raspberry Pi 2 Model B

To set up LIRC, test the sensor, record the IR signal and emit the code I mainly followed this excellent blog post about setting up LIRC by Alex Bain. I worked through all the relevant steps and finally got a working solution.

Gettin’ the codez

The Playmobil crane remote control seems to use none of the standard protocols like NEC or MD-5. It also has a long sequence, as the output of the raw recording shows.

sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0

The “Left Turn” button, when using channel “D”, gives:

space	4656873
pulse	5722
space	452
pulse	942
space	473
pulse	947
space	474
pulse	949
space	937
pulse	485
space	964
pulse	459
space	938
pulse	484
space	911
pulse	511
space	473
pulse	959
space	464
pulse	950
space	471
pulse	951
space	471
pulse	952
space	469
pulse	953
space	116727
pulse	5721
space	471
pulse	953
space	469
pulse	952
space	443
pulse	980
...

A quick analysis using a spreadsheet and a bar chart shows some interesting features. See below. The y-axis shows the numbers from the raw output as values.

Barchart for left turn on channel d
Barchart for left turn on channel D

There are 13 blocks, of which the later 12 are similar. A test showed that the signal consists of a first, single action code, followed by a repeated stop or terminating code. The clock seems to be at a value of about 473, which is the average duration for a pulse of basic width.

Getting a working lircd.conf file

Now the tricky part was creating the lircd.conf file with the irrecord application. The tool resorted to record what it calls a raw format. By following the on-screen instructions, I managed to get a working file, however, only with the action codes for each direction. I then manually created a stop code and added that to the end of the file.

Here’s the final configuration file, for use with channel D, which I contributed to the LIRC project’s sourceforge repository of remotes.

Invoking commands

With the correctly configured and running LIRC service, I now can control the crane using the simple LIRC irsend program.

irsend SEND_ONCE "playmobil" MOVE_LEFT

for a left turn, for example.

When sending the stop command right after the action command, the moves are a little shorter:

irsend SEND_ONCE "playmobil" MOVE_LEFT KEY_STOP

Build your own

Here’s the complete, minimum guide to rebuild the control (sending part only) for yourself.

  • Set the crane’s remote channel switch to position D.
  • Wire up the IR emitter diode between physical pin 15 (WiringPi Pin 3, BCM 22) and Ground.
  • Get the Raspberry Pi connected via ssh and follow the instructions in Paragraph “Setting up LIRC on the RaspberryPi” from Alex Bain’s Blog about setting up LIRC on the Raspberry Pi.
  • Run the following script. This will download and install the configuration file, for use with channel D, plus a simple controller bash script that you can use to control the crane with your keyboard.
    # Stop lirc to free up /dev/lirc0
    sudo /etc/init.d/lirc stop
     
    # Get the configuration file from sourceforge
    wget -qO- -O large-crane.lircd.conf 'https://sourceforge.net/p/lirc-remotes/code/ci/c1a9403dec74d2b3d90ff507d63a1cd7d8aa6a3b/tree/remotes/playmobil/large-crane.lircd.conf?format=raw'
     
    # Make a backup of the original lircd.conf file
    sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
     
    # Copy over your new configuration file
    sudo cp large-crane.lircd.conf /etc/lirc/lircd.conf
     
    # Start up lirc again
    sudo /etc/init.d/lirc start
     
    # Show the available codes
    irsend LIST "playmobil" ""
     
    # Get the bash control script for easy keyboard control
    wget -qO- -O tmp.zip 'https://qrys.ch/wp-content/uploads/2016/01/cranecontrol.sh_.zip' && unzip -o tmp.zip && rm tmp.zip
     
    # Start the control script
    bash cranecontrol.sh
    
    

    Watching

With the aid of a Raspberry camera module and the RPi-Cam-Web-Interface project, you can even watch your crane while it moves.

Running NxFilter on a headless Raspberry Pi

NxFilter is the best free solution for a self-hosted DNS server/filter I have found so far. Today I got my Raspberry Pi, so how about running NxFilter on a headless Raspberry Pi in a family’s home network?

Prerequisites

The current version of Raspbian, the default Debian-based Operating System for the Raspberry Pi already comes with all required packages (Java, unzip, wget)

  1. Install Raspbian on the Raspberry Pi. You can do this also headless, without an attached Keyboard and Screen, for example by following the official guide on how to install an Operating System on an SD card,  or this more generic guide for a fully automated, configured installation.
  2. Connect to your Raspberry via SSH, using the default (or configured) Username/Password.
  3. Optional: Update Raspbian to the latest version.
  4. Recommended: Change the default password.

Installing NxFilter

Note: This guide roughly follows the  the unix installation instructions from the NxFilter manual:

  1. Download the latest version of NxFilter with wget
    wget http://nxfilter.org/download/nxfilter-3.3.4.zip
  2. Unzip to the installation folder (requires root-access)
    sudo unzip nxfilter-3.3.4.zip -d /nxfilter
  3. Change to the installation folder
    cd /nxfilter/bin
  4. Make the necessary scripts executable
    sudo chmod +x *.sh

Manual Startup

  1. Run
    sudo ./startup.sh

Automatic Startup at each Raspberry boot

  1. Add the line /nxfilter/bin/startup.sh -d near the end of the file /etc/rc.local
    cd /etc
    sudo nano rc.local
    
  2. After doing so, the end of the file should look something like
    # NxFilter Autostart
    /nxfilter/bin/startup.sh -d
    exit 0
    
  3. Reboot
    sudo reboot

Configuration of NxFilter

  1. Using another machine with a browser, navigate to http://youripaddress/admin Default Username and Password is admin/admin.
  2. Change default password via “Config/Admin”
  3. See the manual for all configuration options.