Archive for » March, 2009 «

Tuesday, March 24th, 2009 | Author: viking

The default Dokuwiki template was frying my eyes, so I made a new one. I simply took the default template and substituted some colors.

desert

Download »

For instructions on installation, see Dokuwiki’s template page.

UPDATE (2009-04-09): Fixed code blocks showing as white.

Category: web design  | Tags: , ,  | Leave a Comment
Thursday, March 12th, 2009 | Author: viking

The HTML specification dictates that unchecked check boxes should not supply a value in a form submission, which can be problematic for applications wishing to set a flag in a database based on an unchecked check box. Rails gets around this by using a trick in the check_box helper. It places a hidden input tag with the requested default value directly after the check box tag.

The reason this works is because form parameters are sent in the order that they appear. This means the hidden input value is submitted after the check box value would be, and Rails gives precedence to parameters appearing earlier in the request.

I tried this in PHP, hoping it would behave the same way. It doesn’t. It turns out that PHP overwrites earlier variables in the request with later ones. This behavior is dictated by the request_order directive (as of PHP 5.3.0, which is still in beta at the time of this post). The fix is simply to place the hidden input tag before the check box tag.

Hopefully this helps someone avoid the moderate pain I went through figuring all this out.

Category: php, rails  | Tags: ,  | Leave a Comment
Thursday, March 05th, 2009 | Author: viking

Yesterday I scoured the web for an animated progress bar background. Not an animated progress bar, a background. I wanted the ability to control my progress bar length with CSS and Javascript. I found some stripey backgrounds and what not, but none of them were animated. Maybe my Google skills failed me, but I couldn’t find one for the life of me. So I decided to make my own in GIMP.

Progress bar

Once I figured out the steps, it was quite simple.

  1. Start with a long solid color bar (I used 1000×25, which is probably overkill)
  2. Add a transparent layer and fill it with the Warning pattern (yellow and black stripes)
  3. Remove the yellow stripes via select by color, then change the opacity to something low (like 15%)
  4. Add a third layer for a white gradient in the top half to make it shiny
  5. Change the canvas size to 300×25 and align the layer to the right
  6. Merge the three layers together
  7. Copy the layer, move it 1 pixel to the right
  8. Repeat until you have 20 layers, each 1 pixel further right than the previous one
  9. Run the animation optimization filter, then save as animated GIF using 50ms delay
  10. Drink a beer!

Here’s the GIMP file before merging layers, and here’s the one just before optimization. Please take them (or the image above) and do whatever the hell you want with them.

Here’s a German flag version for good measure.

Category: web design  | Tags: ,  | Leave a Comment