Opera UserJS competition

July 26, 2008 – 8:41 pm Tags:

Opera recently held a UserJS competition, where I participated with a script that makes Google Spreadsheets work in Opera, a script which improves Apache directory listings and a social bookmarking site toolbar.

Opera chose my Google Spreadsheets script as the winner of Site Fixes category, and I will be receiving a shiny new HTC Touch Diamond phone with Opera 9.5 preinstalled! :D

Head to UserJS contest winners post at myopera to see the other scripts that participated. I think especially History+ is a really cool idea and shows clever thinking and that you can actually do a lot more with UserJS than you might initially think.

On template “tag soup”

July 22, 2008 – 10:25 am Tags:

Jeff Atwood’s latest post (at the time of writing this) talks about mixing HTML markup and server-side code, àla

<table>
 <?php foreach($foo as $bar): ?>
  <tr>
   <td><?php echo $bar; ?></td>
  </tr>
 <?php endforeach; ?>
</table>

He also throws in the question: Is there a better way? - However, it seems there’s at least as many ideas of a better way as there are programmers…

Read the rest of this entry »

Is Smarty really obsolete?

July 19, 2008 – 2:28 pm Tags:

There was a short discussion on Zend Framework general mailing list about Smarty being obsolete. I decided to take my opinion here, since the discussion was getting quite off-topic…

Arguments against Smarty presented were mainly the facts that it is PHP4 and its no longer necessary in “modern” web development.

Read the rest of this entry »

How to make back, forward and reload work in Ajax-based apps

July 16, 2008 – 12:38 pm Tags: ,

With Ajax apps getting more and more popular, there’s often the question of the browsers own controls working or not in the app in question. If you hit reload, you might end up back on the start page of the application, if you hit back.. who knows.

I think this is especially an issue in applications, where you would work with something, such as files, and you would go between views, like directories, where you might want to go back to the index, previous view or such.

There is a way to do this, at least in some browsers. It’s called location.hash

Read the rest of this entry »

Does Google test with just IE and Firefox?

July 14, 2008 – 2:01 pm Tags: ,

Ever tried using Google Spreadsheets with something else than IE or Firefox? Yeah, it doesn’t work very well… Docs used to be the same, but at least something is getting better…

However, the issue in Spreadsheets that stops it from working in Opera 9.5 is ridiculously simple! The JavaScript function which tells you they only support IE and Firefox, and asks if you want to continue never returns the value of the confirmation box, so the result is always the same as clicking cancel.

Is Google purprosefully neglecting testing with other browsers, or was this bug left in intentionally?

PS: If you’re an Opera-user, you can grab my UserJS script that fixes Google Spreadsheets in Opera 9.5

Automating creation and caching of image thumbnails

July 8, 2008 – 6:13 pm Tags:

The other day I needed to create some thumbnail images. You know, the usual stuff: Admin uploads image, needs it resized to a smaller one for preview or such…

I thought, why bother with writing code manually in the admin to create the thumbnail? I mean, the requirements for its size might change, the path to thumbnails might change… The whole thumbnail might not even be used after some time!

I say this is a view matter. HTML has always provided the means to define image sizes, but as you hopefully know, sending bigger images than you need is a waste of bandwidth and slows things down unnecessarily.

So what about a class which you could easily use in your view layer to display thumbnails?

Read the rest of this entry »

Making working with DB records easier with a controller helper

July 5, 2008 – 10:27 pm Tags:

The other day I noticed a pattern that repeats quite much in my code:

  • Take a parameter from the request, such as id
  • Query the DB for a record that matches the param
  • Redirect or throw a 404 exception if record was not found

Why do all this, when it could be simply a helper call?

Read the rest of this entry »

Ideas for testing Zend Framework apps

July 3, 2008 – 6:52 pm Tags: ,

Here are some ideas I was thinking of for making testing Zend Framework (and Doctrine) based apps nice and easy.

Read the rest of this entry »

JavaScript Canvas charting/timeline example

June 30, 2008 – 4:46 pm Tags:

I was on holiday last week and haven’t been really able to think of anything really really interesting to write, so here’s something I made a while back: A Canvas-element powered chart/graph/timeline thing of my programming language skills, which I made as an excercise for making chart-type stuff with canvas.

I think the canvas element is starting to get quite feasible for charting, since it now works in Internet Explorer using the great ExplorerCanvas script.

Feel free to use/take apart/break/something the canvas script in the example if you like. It should work out of the box if you just provide it with some custom data in a similar format as seen in the code.

Simple Photoshop-style layers using JavaScript

June 23, 2008 – 7:18 pm Tags:

Today I wrote a small JavaScript class to display images layered on top of each other, in a similar manner as layers are shown in editors like Photoshop.

I wanted to show my Dwarf Fortress to someone, but I didn’t just want to stack screenshots below each other like you’d usually do. Since dwarf forts can span multiple depth levels, it would be pretty neat to be able to show the levels on top of each other, with transparency too.

See it in action here.

It’s relatively simple. You point it at a div which contains the images you want to make layers of, and a div where it should display the controls, and it does the rest.

If you want to use it, feel free. Just copy the script file and write some similar CSS and HTML as shown in the example page. You probably won’t need all of the CSS styles, just take note of the #controls .selected one, as “selected” is the class used for highlighting the selected layer. Note that you will need to link to the Yahoo UI libraries, as it is used in some places in the code.

You could probably use that for a JS based image editor, to name other uses than fortress showcases. :D