Friday, September 28, 2007

Periodic Generator

A few years ago, I saw a t-shirt that spelled "WWU Chemistry" in the style of a periodic table. So, I decided to throw together a DHTML program to spell an arbitrary phrase this way. Today, I cleaned up the code a bit and added sample phrases. The algorithm prefers two-letter combinations to one letter. Unfortunately, a lot of common letters can't be done exactly, so I had to be a bit creative. Here's the link. 2012 Edit: In 2005, only IE could flip text, now Firefox can too, so I'm using css3-style rotation.


Monday, September 24, 2007

JavaScript and Logic

Two years ago, I was in a logic course at WWU. The class was interesting, but some of the assigned online work was a bit repetitive. I did enjoy proving theorems, but filling out the truth tables was not exciting.

So, after some thinking, I quickly wrote a script called "logic.js" which can evaluate prepositional logic. I thought of how to do this from scratch (looking back on it there are probably better ways to do evaluate infix notation). For compound expressions, the idea was to use regex to find the innermost operation and evaluate it, replacing it with the result. Then this process would be repeated until there was only one value.

I used the engine to Draw Truth Tables and Evaluate Logic.

For fun, I wrote a similar program for a ProbStat course, at around the same time, for Set Diagrams. None of these are "finished" finished, but they work well enough.

C# Is Useful

For throwing together a GUI app, C#.NET is actually pretty handy. Here is my demo proving that C# isn't all bad - that is pretty quick and effective. Note that you don't need to use the visual designer at all, and that is what I would do for a larger scale project.
For larger scale projects, XAML is pretty interesting too. I used it at work this summer.
Why I like it:
  • Compilation step isn't a hindrance - it is fast and catches many mistakes.
  • GUI designer is helpful but it's easy to code your own layout.
  • .NET library comes with a lot.
  • Sweet language features make it feel more flexible and fun than Java.

On the other hand, here are the reasons why I still believe .NET is not the answer:
  • Not really portable to Linux. (Yes, Mono, but still).
  • Requires a huge framework. There isn't a way to "static link" your programs. This means that Joe User might have to download lots of megabytes to even run your program, which I know I would be reluctant to do. And what if he is on dial-up?
  • Memory management and performance - it's pretty good, but watch out for certain things (GC, deep inheritance, reflection, and UI drawing). It is sometimes hard for me to accept that: "My C# program looks and behaves the same as one written in C++. But it is slower and takes more memory." The only answer is developer time. Of course, I am glad that there are simpler languages like C#, and they have benefited me, but this tradeoff is probably partially responsible for today's software bloat.

Thursday, September 20, 2007


Bored? Time for Tetris. 1990 Style.
High Score: 25,613 (good)
Favorite Move: The Spear (See it)
Windows Entertainment Pack Tetris is where it's at.

Wednesday, September 19, 2007

TweakUI, RTF

I used to Regedit most of my Windows customizations. But now, the TweakIU program provides a GUI for many common changes. Here are some of my favorites:
Read the "tips." There will be some handy keyboard shortcuts. (Did you know you can hold down Control to select many taskbar items? Also, when confirming file actions, Shift+No will mean "No to All."
Under Internet Explorer, you can set the loading-page animation, which I used to great effect. (When I use IE, now I have a running Mario icon when a page loads). I also changed a registry setting so that "Internet Explorer, brought to you by Mario" is in the title of each window.
Finally, under Templates you can edit the entries in the Windows "New file" menu. (This is under the file extension in HKEY_CLASSES_ROOT). I added a "Rich Text Document RTF" entry by pointing to a new .rtf file on my hard drive. Wordpad can be a good lightweight editor if you want simple formatted text. (And, you can use Paste Special/Unformatted to strip formatting). So I always associate .rtf files with Wordpad.
No, rtfm is not a manual in rtf format. It means something else.

Saturday, September 8, 2007


Facebook has a "Graffiti" application where you can draw pictures on a profile by clicking and dragging. Because art is not my forte, I decided to find a way to paste an actual bitmap image in the space.

First, I made a grayscale image of my face. I wrote a little Python script using the Python Imaging Library to make a list of all pixel coordinates that were white. I then wrote an AutoIt script to simulate mouse-clicks at all of those screen locations (hacktastic).

The results:
Not perfect, but still visible.
AutoIt is a pretty cool program for Windows automation. It can simulate keyboard and mouse events.

The actual reason I did this is that I wanted to learn about image processing in Python. It's usually not trivial in most languages / libraries to get pixel access of a PNG image, but PIL seems to do well. Stay tuned for my upcoming ultimate Image Processing lab.