May 17, 2012

15 Segment ASCII Display Project

15seg 15 Segment ASCII Display ProjectWith the resurgence of interest in hobby electronics, I thought my readers might enjoy looking at the details of a simple project I did with cheap EBay-acquired parts. This was a fairly straightforward scrolling LED ascii display.

Goal

A simple-to-use Simstick display, capable of showing a reasonable subset of ASCII, utilizing cheap 15seg displays.

15 Seg Display

I chose to use LTP588G 15seg display, since it was cheaply available via EBay or surplus.

Segment Lettering

I could not find a “standard” segment-to-letter map for a 15 seg display, so I have extrapolated from the standard 7 seg layout:

15seg 15 Segment ASCII Display Project
[Read more...]

Ajax remoting for Invisible Castle

happy Ajax remoting for Invisible CastleI offer the code for my Invisible Castle site under a GPL license. However, it is not the easiest code in the world to get running. Plus, it is really overkill for most people. Most people who ask for the code really just want a die-roller with database lookup for their site. They aren’t really prepared to provide a working Python/Cheetah/MySql install. That’s fine, I could help them out and pick up a new skill in one fell swoop.

Ajax to the rescue

I quickly wrote a simple remote interface to the die-roller, and then used the Prototype library to implement an Ajax interface to it. Simple simple simple. It worked beautifully, with one problem, that pesky restriction agains cross-domain XMLHTTPRequests. So, I wrote a simple little PHP proxy page, and it works perfectly!

All together, this was a pretty nice payoff for a couple hours of work, including ramping up from zero about XMLHTTPRequest objects. I already have two remote client sites functioning happily using the script, which has a working demo with install instructions here.
[tags]javascript,Ajax,cross-site scripting,xss,xmlhttprequest,prototype[/tags]

Prototype modification to fvlogger

logger Prototype modification to fvloggerfvlogger.js is a fine logging system for Javascript, but when you are already using Prototype.js, it unnecessarily duplicates a lot of functionality. I’ve forked the original code to “fvlogger 1.0.proto”, removing this duplication. In addition, I’ve added a sweet “add the logger to the page” function to the script. The end result is much smaller and cleaner looking than the original, I think.

This script is based on fvlogger 1.0, available from Five Volt Logic. It requires prototype, and if you want to use its auto-insertion features, it requires Behaviour.js as well. If you aren’t already using the Behaviour library, you should. It will revolutionize your use of Javascript, fully separating user interaction from markup. Most times I use it, I never have to use a single line of inline javascript at all. That is incredibly liberating!

If you want to use Prototype 1.3.x, you will also need to load a few functions borrowed from “the future”, which I’ve helpfully included as “prototype_future.js”. Just look at the test page in the zip, and all should be clear.

Download protologger-1.0.zip and let me know what you think.

[tags]javascript,libraries,prototype,logging,fvlogger,behaviour[/tags]

AJAX goodness for Invisible Castle

I just rolled my first real AJAX application out to testing. My Invisible Castle site is a die-roller for online gaming. It lets uses roll dice, and it lets their game masters or fellow players go look them up later. Fairly simple, but it got over 150,000 rolls last year alone.

I like to use the site as a testbed for new technologies that I’m interested in learning or exercising. This has worked out really well for me, leading me to the excellent Cheetah Template page template system for Python. Last fall, I completed a major refactoring of the site, and moved it to Dreamhost. With Cheetah in place, and the code all clean and lovely, I am now finding it very simple to add new features.

AJAX, why?

Despite it being a testbed, I don’t like to add features for the sake of features. That’s just silly. I could “ajax-up” the site, making it prettier I suppose. Maybe I’ll do that as I work on the site, but for my first AJAX app, I wanted something more interesting. So, I decided to open up the site to remote calls.

I want remote gaming sites to be able to embed a tiny amount of well-written Javascript, and end up with the ability to roll “in place” for their users. This morning, with the aid of Prototype and Behaviour libraries, I whipped out a nice remoting system in just a couple hours.

Cross-site

The most annoying part of the whole mini-app was enabling the cross-site AJAX call. I solved it by writing a quick PHP script which simply uses curl in the background to call my site, passing along the parameters. That script gets installed on the site which wants to use my roller, and bang, instant on.

It was fun to write. Take a look at the remote test here and let me know what you think. Notice, not a single line of ugly in-line javascript. Behaviour is a wonderful library!

WordPress 2 multi-blogging made easy

I upgraded the site to WordPress 2 this morning. This wouldn’t be a bit deal, since the dev team has made it so easy to upgrade. What makes it interesting is that I read a tip on the WordPress forums and came up with a simple method to enable multiple domains using one blog installation on Linux/BSD systems.

1) Get WordPress 2.0 and unpack it to a master directory you’ll be symlinking later.

2) Copy wp-config.php to wp-config-orig.php.
3) edit wp-config.php, replacing the whole thing with:
<?php include($_SERVER['DOCUMENT_ROOT'] . '/config.php'); ?>
4) make the directory for your domain, for example:
mkdir coderseye.com
5) cd into the directory and symlink the contents of your master directory.
cd coderseye.com
ln -s /home/example/wordpress-master/* .

6) copy the original wordpress config file, naming it “config.php” and edit like you usually would for wp-config.
cp /home/example/wordpress-master/wp-config-orig.php config.php
7) Done! You’ve successfully linked another directory as a separate blog with the same base files.

Making it automatic

I’ve made a script which automates all of this, at least on Linux boxes. You just call it like so:
setup_multiblog.sh master slave
If “slave” directory exists, it will be backed up, and upgraded to work with the master as a slave-multi-blog.
If it doesn’t exist, it will be upgraded.
If the master doesn’t have the modifications I describe in step #3, the script will back up wp-config and make the modifications.

setup_multiblog.zip

Enjoy, let me know if it needs tweaks, it has a lot of self-checks built in, so hopefully it won’t trash anything. I’d backup first, just to be double-sure.

Technorati Tags: , , ,