We should work less, not more

I’m paraphrasing a recent Slashdot comment that really stuck a chord with me and galvanized some thoughts I’ve been having for a while.

We have the technology and resources so that people don’t need to work as much as they do, but instead we choose to continue with this outdated concept of “40 hours a week for everyone”. So, what do you do with all these people? Well, you make them spend exorbitant amounts of time in meetings generating data and reports to make them look productive. We are squandering the most glorious time in history in terms of energy resources, technology and machinery in order to maintain an out of date social construct.

  • So many are productive in today’s world, but doing what?
  • What are we producing and for who?
  • What bennefit do these products provide?

We should work and consume less and spend more time being creative.

Posted in environment, government, internet, jaded, life, world | Leave a comment

Working with Apache SOLR SynonymFilterFactory filter

I spent a bunch of time playing with Apache SOLR trying to get multiword synonyms to work. I have a very specific use case where the field I wanted to create synonyms for was a collection of tags applied to the document which could be multiword. I don’t believe this solution would work for an open text field but for replacing one tag for another appears to work perfectly. I had to play with the configuration quite a bit to get the replacement working for phrases of more then one word. So I’ve documented my solution below. Your mileage may very.

I added the filter on the query side of the field definition. If you want to use the filter at index time, you’ll have to use a slightly different syntax in the synonym file. One thing to mention is the use of the tokenizer factory property. You’ll need to set this to “solr.KeywordTokenizerFactory” to stop it from tokenizing the value before doing the synonym replacement. The KeywordTokenizerFactory is weirdly named as it doesn’t actually tokenize anything.

<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"

For the synonyms.txt file:

# List of synonyms need to be defined as below if the filter is defined at query time
# Searching for "Replaced Term" will yield documents that contain "Test" or "Two Words".  "Test" and "Two Words" will continue to work as well.
Test, Two Words => Replaced Term
Test => Replaced Term Two
# ....etc....

# List of synonyms need to be defined as below if the filter is defined at index time
# This is so that "Original Term" continues to work as a term
Original Term => Original Term, Test, Two Words

Some links to check out:

Hope this helps some one!

Posted in internet, programming | Tagged | 2 Comments

Programming the NS-500UR Led Sign

I recently purchased the NS-500UR Led Sign from an Amazon reseller for the PLOS Office. I wanted to have it display the latest 10 terms users have searched for given the search engine on our website. It was a bit of headache tracking down documentation on how to communicate to the sign, so I’m publishing my results below.

I did my work in java, code samples below are in java, you could probably however, adapt it to any language. Also note, that this is my no means comprehensive, there is a lot more you can do with this sign then I am going to cover below. All I cared about was display a bunch of short text messages.

First: I used the commapi library to abstract serial communications to java. On linux, this is the command you want to get the source, compile and install into your local java jre:

export CVSROOT=:pserver:anonymous@qbang.org:/var/cvs/cvsroot
cvs login
CVS password: (blank)
cvs checkout -r commapi-0-0-1 rxtx-devel
cd rxtx-devel
sudo make install

Once that is set up, you’ll need to figure out what port to use. Code below, compile and execute. It will tell you availible ports, and confirm the above library is working.

package org.plos.ledstatus.util.gnuio;

import gnu.io.CommPortIdentifier;
import gnu.io.PortInUseException;
import gnu.io.UnsupportedCommOperationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

public class SerialPort {
  private static final Logger log = LoggerFactory.getLogger(SerialPort.class);

  public static String[] getPorts() {
    List ports = new ArrayList();

    Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers();

    while(portIdentifiers.hasMoreElements()) {
      CommPortIdentifier pid = (CommPortIdentifier) portIdentifiers.nextElement();


    return ports.toArray(new String[ports.size()]);

Now that you have a list of ports, and you’ve plugged your sign into one of them. Here is a bit of code to open the port: (I placed this method in the above class)

  public static CommPortIdentifier getPort(String name) {
    CommPortIdentifier portId = null;  // will be set if port found
    Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers();

    while (portIdentifiers.hasMoreElements())
      CommPortIdentifier pid = (CommPortIdentifier) portIdentifiers.nextElement();

      log.info("PID: {}", pid.getName());
      log.info("PID Serial: {}", pid.getPortType() == CommPortIdentifier.PORT_SERIAL);

      if(pid.getPortType() == CommPortIdentifier.PORT_SERIAL && pid.getName().equals(name))
        portId = pid;

    return portId;

Pretty simple so far eh? This bit of code will send a string to the serial port. Again, I added this static to method to the same class

  public static void sendMessage(CommPortIdentifier portId, String message) {
    try {
      gnu.io.SerialPort port = (gnu.io.SerialPort) portId.open(
        "led-status", // Name of the application asking for the port
        10000   // Wait max. 10 sec. to acquire port

      port.setSerialPortParams(9600, gnu.io.SerialPort.DATABITS_8, gnu.io.SerialPort.STOPBITS_1, gnu.io.SerialPort.PARITY_NONE);

      log.debug("Sending message: {}", message);

      PrintStream ps = new PrintStream(port.getOutputStream(), true, "UTF-8");


    } catch(PortInUseException e) {
      throw new RuntimeException(e.getMessage(), e);
    } catch(UnsupportedCommOperationException e) {
      throw new RuntimeException(e.getMessage(), e);
    } catch(IOException e) {
      throw new RuntimeException(e.getMessage(), e);

Ok, so now we get to the LED specific sign language. There is a lot more here then I am covering, and your mileage may very pending your exact model and release date.

I had to reverse engineer a bit, but the language is quite simple and a message looks a bit like the following. Disclaimer, this was all totally guess work on my part, after watching how their window’s software behaves.


That will display one message with the text “test”. (/r represents a line feed)

    “~128~” Represents “begin message”

    “~f01″ Represents “Message 1″ (The unit has the ability to display multiple message sets)

    “N” is the transition type. More listed below

    “\Z5″ sets the transition speed (in seconds) values 1 to 8 are valid

    “\Y2″ sets the staytime of the message (in seconds) values 1 to 8 are valid

    “\s” sets the font size of the message valid values are “\s” or “\q” (for smaller)

    “\r\r” End of message

Now I was able to append multiple messages to a given set like so:

N\Z5\Y1\stest one/r
N\Z5\Y1\stest two/r
N\Z5\Y1\stest three/r

Here below are a list of available tranistions:

  • A – Cyclic
  • B – Immediate
  • C – Open from right
  • D – Open from left
  • E – Open from center
  • F – Open to center
  • G – Cover from center
  • H – Cover from right
  • I – Cover from left
  • J – Cover to center
  • K – Scroll up
  • L – Scroll down
  • M – Interlace to center
  • N – Interlace to cover?
  • O – Cover up
  • P – Cover down
  • Q – Scan line
  • R – Explode
  • S – Pacman (very cool!)
  • T – Fall and stack
  • U – Shoot
  • V – Flash
  • W – Random
  • X – Slide in

And that’s pretty much it! Here is a java enum of the transitions:

public enum TRANSITIONS {
    FLASH("V"), RANDOM("W"), SLIDE_IN("X");


  //Annoying: FLASH
  //Takes too long, but cool: SCAN_LINE, SHOOT, SLIDE_IN

  private final String stringValue;

  private TRANSITIONS(final String s) { stringValue = s; }

  public String toString() { return stringValue; }

And another helper class for building up a message to send to the serial port:

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Message {
  private List lines = new ArrayList();

  public static Message create() {
    return new Message();

  public Message addLine(String message, int speed, int staytime, boolean small) {
    TRANSITIONS t = TRANSITIONS.preferred[(new Random()).nextInt(TRANSITIONS.preferred.length)];

    this.lines.add(new MessageLine(message, speed, staytime, t, small));

    return this;

  public Message addLine(String message, int speed, int staytime, TRANSITIONS transition, boolean small) {
    this.lines.add(new MessageLine(message, speed, staytime, transition, small));

    return this;

  public Message addLine(String message, TRANSITIONS transition, boolean small) {
    this.lines.add(new MessageLine(message, 7, 6, transition, small));

    return this;

  public String render()
    StringBuilder s = new StringBuilder();

    //Only support one message for now

    for(MessageLine line : lines) {


    return s.toString();

  private class MessageLine {
    String message;
    int speed;
    int staytime;
    TRANSITIONS transition;
    boolean small;

    public MessageLine(String message, int speed, int staytime, TRANSITIONS transition, boolean small) {
      this.message = message;
      this.speed = speed;
      this.staytime = staytime;
      this.transition = transition;
      this.small = small;

    public String toString() {
      StringBuilder s = new StringBuilder();




      if(this.small) {
      } else {



      return s.toString();



Posted in programming, tech | 2 Comments


I created my first github project. Log4Couch. It’s an appender for log4j that will write logging messages directly to a couch server.


Posted in internet, programming, stoopid | Leave a comment

New map feature in iOS6

The new map feature in iOS6 while looking pretty awesome. Is pretty much DOA for me. (Dead on Arrival). I use maps for public transit information. The feature is only supported in the sense of “use this other application” for public transit information and linking to third party apps on their app store. Pretty big oversite here.

Apple, please fix. :-)

Posted in apple sux, internet | Tagged | Leave a comment

Using Java’s HttpClient to send a PUT

After a lot of searching the net, I wrote this method a few weeks back to write a string (or file) to a web server using Java’s HttpClient. It seemed ridiculous that I couldn’t find an example to cut and paste. So here it is for the next person.


public boolean store (final String file) {
HttpClient client = new HttpClient();
PutMethod method = new PutMethod("http://localhost:80");


try {
RequestEntity re = new RequestEntity() {
public boolean isRepeatable() {
return false;

public void writeRequest(OutputStream outputStream) throws IOException {
PrintWriter pr = new PrintWriter(outputStream);

public long getContentLength() {
return source.getBytes().length;

public String getContentType() {
return "application/json";


//Execute the method
int statusCode = client.executeMethod(method);

switch(statusCode) {
case HttpStatus.SC_CREATED:
return true;

log.error("Unhandeled result code {}", statusCode);
log.error(new String(method.getResponseBody()));

return false;
} catch (HttpException ex) {
log.error("Fatal protocol violation: {}", ex.getMessage());
log.error(ex.getMessage(), ex);
} catch (IOException ex) {
log.error("Fatal transport error: {}", ex.getMessage());
log.error(ex.getMessage(), ex);
} finally {
// Release the connection.

return false;

Posted in internet, programming | Tagged , | 1 Comment