AS3: Using BitmapData to hold integer data

BitmapData seems to be just a little bit faster than Array and ByteArray and uses much less memory so it’s a good candidate for holding large amounts of integer data.

There’s one thing to keep in mind though…

Read more

Google Chrome caching weirdness

If you find that your changes in code or server configuration have no effect, try clearing your chrome’s cache.

Read more

Django i18n not working?

If your django is not translating your stuff, check if your django/conf/locale directory exists and that it contains the needed locale.

This just wasted me a couple of hours… django.utils.translation.activate() worked on localhost but didn’t do anything on the production server.

Calling reverse in Django

The reusable-applications-convention says that you should provide a “success_url” parameter for your views so that you can override it from the urlconf.

The DRY principle says that you should always use reverse() instead of hard-coding URLs in your code.

The problem is that you can’t use reverse in your urlconf!

Read more

Making reusable applications in django

One of the key things to making things quickly is to write as little code as possible. You can’t do that if you’re creating everything from scratch all the time.

There’s nowhere near enough documentation on how to make reusable applications in django so here goes…

Read more

Usability tip when using SWFUpload

Please include both lowercase and uppercase versions of the allowed file types in your file_types setting!

My Nikon D60 saves images with uppercase extensions (.JPG) and I’m running Ubuntu linux where filenames are case-sensitive.

so… Please include both lowercase and uppercase versions of the allowed file types in your file_types setting!

Flex cast to ArrayCollection no worky for loaded XML

I just found out that you can’t cast only 1 XML node into an ArrayCollection in flex.
For example “somexml.feed.entry as ArrayCollection” won’t work if you only have 1 entry inside the feed element.

Wasted me a nice hour this thing >_<

Sending of executable files not allowed

I just tried to submit a school assignment ( a C application) via e-mail and gmail tells me that I can’t send my .zip because it contains an executable file.

I mean… WTF! >_<

Measures taken against viruses, hackers, spambots, robots, etc should _never_ get in the way of the legitimate user!

Being a website developer, I’m more-or-less up-to-date with different kinds of website security measures and I always try to make the every-day user suffer as little as possible because of whatever security systems I have implemented.

For example a captcha should never be something the user spends 5 minutes trying to pass.

Of course there are countless of other examples of these annoyance. I’d just like to point out our wonderful ID-card identify verification systems we have around here.
When trying to access my bank account via the internet I always spend 3-4 minutes restarting my browser and re-logging in because the damn this just doesn’t f******g work!

And of course I know MSN messenger doesn’t allow you to send exe files, and gmail has probably had this antifieature since the beginning of time, but.. I mean, anyone who runs the executable file he/she just received from an unknown source AND doesn’t have any kind of anti-virus software installed is f*****g moron anyway.

(yes I know that his/her computer getting infected with a spambot means bad things for everyone but does this really solve the problem?)

Please trim() your inputs

trim() in php (aka strip() in python… etc) is, I feel, a bit underused in today’s webapps.

If you’re expecting a type of input from the user where whitespace is not important, please throw trim() into your data validation algorithms.

For numerical values most number parsers (like intval()) usually can handle whitespace in the string but if you’re keeping the user input in string form… like for example when you’re expecting an id or code of some kind (‘1232-3442-232′, ‘ISAQ91009′, etc), then the input is likely to be copied and pasted from somewhere.

Today’s browsers and office suits tend to include a leading or a trailing space when you double click a word to select it – something which I find really annoying, and it gets even more annoying your uber cool website gives me crap because of it…

Long story short..

trim()

Can’t e-mail .png attachments

I just tried to send an e-mail with a png attachment and I received an automted response telling me that the delivery had failed.

The error message:
“PLEASE DO NOT SEND .PNG ATTACHMENTS RIGHT NOW! (state 18).”

lol!

My first day with Google App Engine

I got a chance to mess with Google App Engine today.

Google App Engine, as a web hosting platform, is quite different from what a typical PHP developer, such as me, usually comes across.

I was looking to develop a simple Django app onto the GAE platform.
Here are the main things I learned today. Read more

SQL – Selecting rows near a specific row

I moderately challenging problem I faced the other day.
Given a specific row inside a MySQL table, how can you fetch it along with the 5 rows preceding it and the 5 rows following it? So that you would get what’s like an excerpt of the table’s row listing.

The solution I came up with is having two queries and UNIONing them together. Read more

AS3 – Playing two sounds at the same time

In actionscript 3 there’s a slight delay between Sound.play() and when the sound actually starts playing so when you try to play multiple sounds at the exact same time using Sound.play() they will always be slightly offset from each other (which can be even measured in tenths of a second).

So how can you play multiple sounds exactly at the same time? Read more

AS3 Accidentally writing 2 decimal separators will make the code not compile with no errors

If you accidentally write ‘0.0.1′ instead of ‘0.1′ in actionscript 3 your code will not compile, but you’ll get no compiler errors either (strict mode an warnings mode enabled).

The same applies to ‘0..1‘ and ‘0.1..‘ (e.g. var foo:Number =0.0.1;).

Writing three decimal separators though will give you “1084: Syntax error: expecting identifier before semicolon.”.

AS3 – SoundChannel.position never reaches Sound.length

It appears that there are a lot of problems with playing sounds in flash and this is just one of them…

flash.media.SoundChannel.position never reaches flash.media.Sound.length, even on the SOUND_COMPLETE event. Read more

This banner takes up too much room

This banner takes up waay too much room!

telegraph.co.uk

telegraph.co.uk