avatar

weekends are for leisure

Using eval for blazing JavaScript performance

June 5, 2013 · 1 minute read · Tags: node.js , programming

Great video. Blows my mind that string concatenation + eval is faster than object/hash creation + repeated modification. Now I see why. I’ve run an experiment here.
Continue reading

Don't trust your assumptions about yourself

January 31, 2013 · 1 minute read · Tags: programming , telecommuting , work

Don’t trust your assumptions about yourself, and don’t apply them to others. They’re probably wrong. – calinet6 on the Hacker News post, A (Short) Rant About Working Remotely
Continue reading

Problems Solved in 2012

January 3, 2013 · 3 minute read · Tags: aws , mysql , node.js , php , programming , redis , work

Wherein I recap the things I’ve done and learned this year as a software developer (mainly at work). I’ve fixed many bugs and uttered many curses. Through it all I’ve constantly strived to make the code a better place. Amazon Web Services Video encoding instances Launch/Start when there’s a backlog, and Stop/Terminate when there’s not. Said goodbye to Amazon SQS for job queues, and hello to Redis. Hello consistency and speed.
Continue reading

Android accelerometer, getting a wake lock while phone is asleep

July 6, 2012 · 1 minute read · Tags: android , gps , programming

There’s a quirk with Android that renders a partial wake lock useless if you want to poll the accelerometer while the screen is off. The workaround is to acquire a screen-dim + acquire-causes-wakeup wake lock. The screen turns on while you’re polling, but that’s the only solution I’ve found. I’ve implemented the workaround in my GPSing project. Hopefully this won’t cause a drastic change in battery usage.
Continue reading

Android GPSing

June 26, 2012 · 2 minute read · Tags: android , gps , programming

The data hoarder in me is making an appearance. Been tracking my GPS coordinates more consistently for the past few weeks, but InstaMapper on Android is less than ideal for the task. Geoloqi as well. They consume too much battery. I’d rather not have to turn them off when I’m going to stay put for a while – I don’t enjoy fiddling with my phone in public. Last weekend I began a project of my own that uses the accelerometer to determine when GPS should turn on.
Continue reading

Falsehoods programmers believe about time

June 19, 2012 · 1 minute read · Tags: programming

Writing code that works with time seems easy. But there are many time pitfalls. Non-coders can skip this article …
Continue reading

Tag stripping not sufficient to prevent JavaScript injections

March 28, 2012 · 2 minute read · Tags: javascript , php , programming

In the PHP world, solely relying upon PHP’s strip_tags() function to protect your web application from JavaScript injections is a bad idea. If you do, you may be vulnerable in even the most recent browsers (I tested in Chrome 17.0.963.83, Firefox 9.0.1 and Internet Explorer 9). There may be parallels in other languages too, so beware. You’ll be vulnerable if the following are true: You’ve got a webapp that accepts user input You use strip_tags() or similar to sanitize fields You don’t explicitly remove less-than or greater-than characters from those fields (PHP’s strip_tags won’t remove a partial “<script” tag) Values from two or more of these fields are printed close to each other in the output HTML, with little or no markup between them The fourth item is tricky … The markup between the field values must not contain any quotes (the quotes would prematurely close the script tag injection attempt).
Continue reading

How to GitHub: Fork, Branch, Track, Squash and Pull Request

March 28, 2012 · 1 minute read · Tags: git , github , programming

If you get confused by non-simple Git workflows, this howto on git forking, branching, etc should help. Oh thank god! Branching I understood, but was clueless when it came to pushing up a specific branch. Rebasing too … reminds me of how we badly need a separate dev environment at work. Ugh. In all, a wonderful tutorial that helps you play along with others while programming.
Continue reading

Character encodings in practice

November 3, 2011 · 3 minute read · Tags: mysql , programming

Building upon Joel’s post on Unicode, here are some real-world tips relating to character encodings. Use them by name Always explicitly specify which encoding you want (perhaps UTF-8). Don’t assume the language or library/tool you’re using will make the right decision for you. If you value your time, don’t ignore this recommendation, otherwise you’ll likely spend lots more time patching things up in the future. A tale to drive this home
Continue reading

node.js FTP server

September 28, 2011 · 3 minute read · Tags: javascript , node.js , programming

Got to use node.js for a work project recently. We needed an FTP server with special user authentication that would run custom code after a file was uploaded. There was one node.js FTP server implementation on github, so I forked it and started rounding out the basic functionality. My fork is here. The first significant change I made was to encapsulate the data connection logic. File lists and file contents are transferred over the data connection (FTP commands and responses over the control connection).
Continue reading
Prev Next

© 2024 - Released under the MIT licensePowered by Hugo with the Type Theme