Aztekera

January 15, 2010

Reading a USB Stamps.com scale

Filed under: Hardware, Linuxy, Programming, Standards — Administrator @ 8:18 pm

I got suckered into one of those hard-to-cancel Stamps.com trials. The upside is that they give you a $10 USB 5 lb. scale to use with their software. The downside is that they want you to only use it with their software, and the company that makes the scale has since taken down their free USB-scale program.

The good news, as Nicholas Piasecki and some Linux users figured out, is that the USB scale conforms to the USB HID specifications, which helpfully standardize how USB scales should work (no joke).

So, I hacked together a Perl script (what else?) to read from this scale by accessing the hidraw# interface that Linux provides. In my case, I have hidraw4 hard-coded into the script itself. Basically, it loops until it reads a good value from the scale, at which point it prints out the weight and exits.

Edit: This code is now a Gist on GitHub.

(more…)

April 2, 2009

Google Summer of Code 2009: WordPress proposal

Filed under: Internets, Programming — Administrator @ 2:33 pm

Objective: Create a single-file PHP installer for WordPress that will automate the downloading, unpacking, and setup of a WordPress blog.

Reason: As of right now, setting up a WordPress blog involves a lot of fiddling with files. The user must download the archive, unzip it on their computer, open a ftp connection to their server, upload all of the contents, hope that all the permissions are right, and navigate to the right directory. Since WordPress is such a popular blogging software, many people (most of whom are not familiar with a Unix shell or do not have access to one) would benefit from a single-file installer.

Deliverable: One (1) PHP file. No other files can be included with this (unless embedded), since this would void much of the advantage of such a single-file installer.

Basic procedure (a rough plan):

  1. Instruct the user on the requirements of WordPress (needs hosting with PHP, etc.).
  2. Instruct the user on downloading and uploading this installer, and subsequently running it.
  3. Check the server environment for required components, correct permissions, etc.
  4. Give the user some options on name, location, etc. and solicit other options like database credentials.
  5. Download the latest WordPress distribution.
  6. Unpack the distribution to the right place.
  7. Proceed more-or-less with the “usual” install.

April 30, 2008

Constructor Chaining in Java

Filed under: Programming — Administrator @ 12:38 pm

When you have a class that extends another class in Java, initializing that child class will first call the parent’s initializer, and then the child’s. So if you have:

public class Base {
    public Base() {
        System.out.print("Base  ");
    }
}
public class Derived extends Base {
    public Derived() {
        System.out.print("Derived");
    }
}

The code Derived d1 = new Derived(); will print Base Derived.

Powered by WordPress