FINALE: a falling block game

For my final AP Computer Science project in June 2008, I worked with Brandon Liu and Yuzhi Zheng to develop FINALE, a falling block game based on the PSP game Lumines. The object of the game is to match colored blocks into squares, which are cleared away when the “time bar” passes them. Clearing more squares in each pass of the time bar gives an exponentially larger number of points.

Here are some screenshots. (I’m happy to say our graphical presentation was spectacular, with all graphics, backgrounds, and game pieces custom designed in Inkscape.)

Continue reading

Notes: Getting suEXEC execution for PHP under Virtualmin GPL

(On Debian 5.0. May be slightly different on other distros)

Create files in /etc/skel/:

$ cd /etc/skel
$ mkdir -P etc/php5
$ cp /etc/php5/apache2/php.ini /etc/skel/etc/php5/php.ini
$ mkdir fcgi-bin
$ vi fcgi-bin/php5.fcgi

Paste the following:


export PHPRC=$PWD/../etc/php5
umask 022
exec /usr/bin/php-cgi

Then, in Virtualmin > System Settings > Server Templates > Default Settings > Apache website > Directives and settings:

ServerName ${DOM}
ServerAlias www.${DOM}
DocumentRoot ${HOME}/public_html
ErrorLog /var/log/virtualmin/${DOM}_error_log
CustomLog /var/log/virtualmin/${DOM}_access_log combined
DirectoryIndex index.html index.htm index.php index.php4 index.php5

Options -Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All

AddHandler fcgid-script .php
FCGIWrapper ${HOME}/fcgi-bin/php5.fcgi .php

AddHandler cgi-script cgi

Important notes:

  • ExecCGI is required! Otherwise, 403 Forbidden errors will occur.
  • The wrapper script and php files must not be group/world-writable!
  • Look in /var/log/apache2/suexec.log for hints if you’re having trouble.

Sony VAIO Power Management as a Limited User

I recently switched to running XP as a limited user after getting a virus. However, I soon realized that I couldn’t use my Sony VAIO S260’s power management features anymore. When I went into the VAIO Power Management tab, everything was grayed out. Logging in as Administrator, I could create profiles, but then I wouldn’t be able to see them in a regular user. Here’s the solution:

  1. Allow the limited user account (LUA) to change power options. This will let you change the Windows built-in options, but not the VAIO-specific options.
  2. Temporarily make your LUA administrator either manually (requires logout/login) or using MakeMeAdmin.
  3. Open up the Power Options control panel (powercfg.cpl).
  4. Set up your power profiles as you want them, using the VAIO Power Management tab. These will be visible since they’re created in your own user account, rather than Administrator’s.
  5. Now you’ll be able to switch between profiles without using MakeMeAdmin–just click the battery icon in the notification area. Changing the VAIO-specific options of profiles still requires MakeMeAdmin though.

Using Charts in LaTeX

Finding out how to get my charts into LaTeX took way longer than it should have. First, I tried pasting it into a Writer document and then using Save As Picture, but its EPS output resulted in 0-byte files, SVG output was broken, and raster images came out at screen resolution. (I couldn’t find a way to export higher-resolution charts in Excel either!) So here’s how I finally did it:

  1. Copy and paste the chart from Calc into Draw.
  2. Export the drawing as PDF.
  3. Use pdfcrop <image.pdf> (provided in the texlive-extra-utils package on Ubuntu 8.10) to crop out the whitespace
  4. Now just use the image with includegraphics{image-crop.pdf}.

The results are crisp and clean. Amazing!

Cryptic errors from mod_fcgid and Perl

For future reference, the cryptic error from mod_fcgid:

[Thu Feb 12 22:10:27 2009] [warn] (104)Connection reset by peer:
    mod_fcgid: read data from fastcgi server error.
[Thu Feb 12 22:10:27 2009] [error] [client X.X.X.X] Premature end of
    script headers: dispatch.fcgi

means that dispatch.fcgi failed to start. Possible reasons are:

  1. Missing Perl modules. Unfortunately, I don’t know where the stderr output ends up. Try running the script directly; e.g. perl dispatch.fcgi.
  2. Missing Perl modules that you installed locally (e.g. local::lib) but Apache doesn’t have it in $PERL5LIB.

Remember that the folder must not be group-writable, and that any executable must be run from the directory root that suEXEC was compiled for! These will fail with a more useful error though, complaining of “suexec policy violation: see suexec log for more details” (the log is at /var/log/httpd/suexec.log for CentOS systems).