jQuery – test if element is in viewport (visible on screen)

/UPDATE: the most recent version of this plugin is now available on github: https://github.com/moagrius/isOnScreen. Forks (and hopefully improvements) welcome. /UPDATE: if you’re looking for a how-to on lazy-loading content, images, or event effects, there’s a simple outline using this plugin available here. /UPDATE: this is probably all you need. Original Version returns true if any […]

jQuery – copy style (copyCSS)

UPDATE: this is now available on github per requests – forks welcome. Added some options for white- and black-lists as well. https://github.com/moagrius/copycss UPDATE: update to address reported problems with Opera (thanks Vincent). Method to copy all styles (inherited, native, descended, inline, etc) from the @param source element, to the invoking element:

Understanding Easing (Explaining Penner’s equations) – JavaScript and ActionScript

Despite the commonality of the classic easing equations, largely attributed to Penner, there doesn’t seem to be the in-depth examination of “how it works” that a lot of code is subject to nowadays. First, a quick clarification on the most popular easing Classes. The “standard” easing classes (that provide predictable inertia), are Linear, Quad, Cubic, […]

CodeIgniter – AJAX + Session bug fix

If you’ve used AJAX-heavy web apps built on a CI backend, you might have noticed premature session expiration, even if you’re expiration was set to never expire ($config[‘sess_expiration’] = 0; in application/config/config.php) This was apparently due to AJAX requests not regenerating sessions, and apparent collisions. Long story short, last month there was a patch introduced […]

PHP – really simple linkify

we all know that it’s impossible to perfectly match URLs from human input… but i spent a little time compiling various solutions on the boards and have ended up with this (note – this is largely pieced together from other sources – I’m not claiming original work):

The more difficult part was differentiating what […]

20 Tips to Optimize your ActionScript

Update 09/29/12 This article was written several years ago for Experts Exchange, and has proven to be a little more controversial than I expected or intended, mostly due to the (admittedly vague) reference to what I call AS3’s “fake” lazy evaluation, which happened to be (rather randomly) listed as the first tip. I’m removing that […]

(Really) Simple JavaScript Inheritance

There are several approaches to forcing JavaScript inheritance to behave like other, more natively-OOP languages, from Dean Edwards Base.js, to John Resig’s take on it, to the approaches used by Prototype.js and MooTools (my personal recommendation). This is something jQuery doesn’t even attempt (although some less impressive plugins are available), which is one reason I […]

CSS – Horizontally center a row of floated elements

Despite the boards being full of people insisting it’s impossible, you can center a row of floated elements even with fluid (unknown) width. The process is: 1. Wrap the container in an element with:

2. On the main container, add the following:

That’s really all there is too it. An example might look […]

PHP – seriously simple Router

/UPDATE I’ve come to prefer (the very similar) RegexRouter. I’m increasingly uncomfortable with the string replacement in the route method. My upshot of PHP routers (inspired by the various micro-frameworks, like Slim, Silex, F3, Laravel, Tonic, Flight, Klein, etc).


JavaScript RegExp to remove comments

UPDATE 02/16/13 As the gentleman in the comments pointed out, it’s (practically) impossible to use a single regular expression to appropriately remove all comments from javascript (or any construct with strings), and I’d assume virtually impossible to do so even with a series of patterns. I suspect a full-fledged (but simple) parser is required, so […]