having fun with code

Tag Archives: javascript

Link: Whirlpool JS

Whirlpool is a very strong hashing algorithm (one way encryption) that encodes any text into a 128 character string (popular md5 generates a 32 byte string). Looking for the JavaScript version, I had to search on my email inbox for an email I received back in October 2009 to found the link where to download [...]

Little tricks: repeating strings in Javascript & Python

How many times have you found yourself printing strings like “————-” or “===========”? I do that a lot when I have to do console.logs or if I’m working on a console application or script. Adding dividers to the output makes it more readable. Python has a very peculiar syntax for repeating strings, which consists in [...]

Little tricks: concatenating arrays in Javascript

It happens that when working with Javascript frameworks like MooTools for a long time, it’s easy to forget how to do things in plain/native Javascript. For example, concatenating arrays is an easy task thanks to the Function object method apply: var array1 = [1,2,3,4]; var array2 = [5,6,7]; array1.push.apply(array1, array2); // array1 = [1, 2, [...]

Titanium Developer: love and hate

I’ve been using Titanium Developer for a while now, since I installed it to do some mobile app research one or two months ago. But up until now I barely used it again other than to maintain a desktop app I created for a game, which thanks to Titanium runs in both Mac and PC. [...]

Little tricks: string padding in Javascript

I just found this little trick to zero pad numbers in Javascript. It is also applicable to padding with any character, not just zeros. var n = 123 String("00000" + n).slice(-5); // returns 00123 ("00000" + n).slice(-5); // returns 00123 ("     " + n).slice(-5); // returns "  123" (with two spaces) Found here.

Little tricks: editing strings by index in Javascript and Python

Editing strings by index maybe something that we don’t do all the time. But it’s one of these things that, coming from languages like C, one would assume is as trivial as assigning the value of an indexed position. Something like this: var a = "hello world" a[0] = "H" console.log(a) // outputs "hello world" [...]

More WebSockets, now with Python!

A couple of weeks ago, Tim and I worked on a little game/demo using WebSockets and C# (I haven’t been able to put it online since I do not have a Windows server). It was a lot of fun and we were able to see the potential of WebSockets and how much internet can will [...]

Performance matters

I just read this on an email from a Google’s Closure developer: Adding runtime checks for invalid usage is something we have policy against. It adds to the code size as well as to the runtime cost. I totally agree. Developers should be responsible for their usage of APIs or third party libraries, while these [...]

Interesting JSON vulnerability (old stuff)

Somebody at work passed this article about an interesting vulnerability in web APIs that use JSON. The exploit combines Cross Site Request Forgery (CSRF) with a JSON Array hack allowing an evil site to grab sensitive user data from an unsuspecting user. The hack involves redefining the Array constructor, which is totally legal in Javascript. http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx [...]

Mooml 1.2.3 – Bye, bye, with()

Mooml 1.1 was the first version of Mooml that didn’t rely on eval(), a javascript function that causes lot’s of problems when not used properly, but that also prevent minimizers and compilers like Closure to generate valid code. The new Mooml 1.2.3 release also gets rid of with(), which will no longer be used to [...]

About the blog

This is a blog about development, focused mainly on Javascript but also other languages like python, shell scripts and more.

About the author

Eneko Alonso is a software engineer and UI developer with more than eight years of experience in software and web development. He lives in San Luis Obispo, California and works at LEVEL Studios.

Contact Info

Contact Info