JavaScript

Photo Wall that Scrolls Forever Loading New Photos at Bottom

I was reading the code at iworkfortheinternet.org and learned how to do this "scrolling forever wall" effect. It's clever.

Comparison Shopping for Toilet Paper, in multiple computer languages.

It's hard to concentrate when you're tired and cranky, so I wasted some time writing a simple calculator in several different languages.

Javascript Delayed Hiding of an Element, Delayed Function Calls in Different Contexts

So I'm working on a small "speech bubble" library, and needed to delay hiding of the bubble. It's not that it was required, but it was a pain in the butt figuring out how to arrange the event handlers on the different elements so that you don't end up with a situation where you get a flickering bubble because you hide the bubble, and that fires a mouseover event that, in turn, displays the bubble again. That fires a mouseout event that causes the bubble to be hidden.

Learning the Facebook API

For the past few months I've been working on web apps. The first was a mobile site based on jQuery Mobile. While it was "cool", it quickly dawned on me that it wouldn't get any significant usership. For one, it was like a clone of 4square and Scvngr - and who really uses that? I'd peer into the lists of checkins, and it wasn't looking too encouraging. People use it when they're bored and alone, and my scenario didn't involve either of those situations.

Generate a Page of Random Passwords with Javascript

The attached HTML page is a password generator that creates a page of random 10-character passwords. It helps you manage one password per website, so a password leaked for one site doesn't get used on other sites. To use it, click and view the file.

A Demo of Transmitting Passwords Encrypted

This is a demo of a technique to transmit password encrypted. It's not a perfect solution yet, but it's getting there.

Interstitial Ad in jQuery

Normally, you should use canned Javascript or canned PHP modules to implement web features, but sometimes, that can suck. Typically, these products, if they're popular, start to suffer from feature bloat. Such was the case with some code for "interstitials", which are those ads that pop up on some web pages, interrupting your reading. Popups have been around a long time, and the drop-in code is just really huge.

Loop Faster

nzakas has a great presentation about speeding up Javascript loops but it applies to any language that uses C-like loop structures.

Caching Data for AJAX with Javascript

Here's a way to cache data on the client side, via javascript. This was tested on Firefox 3.6.3 on Ubuntu.

The idea is to convert your data into Javascript, and then load it with the SCRIPT tag. You then use the Expires HTTP header to tell the client how long to cache the data. Finally, you use some Javascript code to display the data.

Strip Non-Numeric Characters from Data

This Javascript widget strips non-numeric characters from the input. The result will be a space-separated list of numbers.

Dusting Off Coroutines

Coroutines are back! They never really left, but, it looks like different languages are adding native support for coroutines.

Javascript Functions and Closures for Private Properties

A JavaScript Module Pattern is a fantastic example of how to use closures.

Javascript Closures has more detailed information.

Douglas Crockford brought the style over to JS, and his site has a lot of important articles about Javascript hacking (as a functional language).

Hispanic Surname Extraction with Regular Expressions

The challenge with these names is twofold. For one, they follow a European convention of using "of" to denote the family, e.g. De La Cruz. This is like the Irish O'Connor or Italian del Vecchio. Secondarily, some people use their Catholic-style names, where the maternal name is combined with the paternal name, e.g. Lucy Lopez Valdez.

Terse Javascript Alternations, and the Frameworks' Problem with SQL

Cool

Here's a snippet of javascript that breaks up a phone number into its parts, if it's formatted in the common formats.

    var cell = namesArray[rownum]['Cell'];
    (cell_parts = /\((\d\d\d)\) (\d\d\d)-(\d\d\d\d)/.exec(cell)) ||
    (cell_parts = /(\d\d\d)-(\d\d\d)-(\d\d\d\d)/.exec(cell))     ||
    (cell_parts = /(\d\d\d)(\d\d\d)(\d\d\d\d)/.exec(cell))       ||
    (cell_parts = ['','','',''])

It's pretty short, no?

What's nice about it is that it parses several formats, but doesn't collapse all these possibilities into a single regex.

How Much Money Can You Save on Gas by Riding the Bus?

This is a javascript calculator that will estimate if taking a bus will cost less than what you pay in gasoline. Surprisingly, for short commutes, commuting by car is cheaper than getting a bus pass. (Calculator is on the full article.) You can get prices at Gas Buddy.
Syndicate content