Appcelerator Event Garbage Collection

As you apply API level event listeners throughout your application you must remember to remove the event when you are done with it, usually when the window is closed. Otherwise your events will end up firing multiple times and things can get messy. Especially if a sql query is part of the call. These stray event listeners are also known as “zombie event listeners”.

The object below can help you manage your events and you will never have to worry about removing them. Any event listener you add with this wrapper will automatically get removed when the window is closed. It is essentially a wrapper for Ti.API.addEventListener and allows you to assign an event to a specific window.

This is a basic commonjs module.

Usage:

Screen Shot 2012-05-24 at 3.07.58 PM

Modest Maps Wax Zoomer

Wax is an extension for Modest Maps and other various JavaScript based mapping libraries. One of the utilities offered is the Zoomer. Out of the box it just has basic zoom in and out buttons which is great, but often a zoom scale is required. Here is an extended Zoomer with a Google-style scale. I have applied a bit of styling to it so it is visible but it requires nothing but the Wax library. Style and use how you please.

ExampleGithub

Peach Database Migration

A cute javascript app to safely migrate a database with serialized PHP objects.

At work we have a shell script to handle the migration from to dev to staging to production and so on. The script properly converts the serialized objects containing the domain name and replacing the old one. It works great, however, it’s a shell script. I wanted something faster, easier, and something I could use from any computer, anywhere. So I wrote peach. Also, this doesn’t have to be WordPress site, it will handle ANY standard mysql dump. And I named it Peach. Enjoy.

Feel free to clone it on github.

Custom Mapping API’s

Google Maps is a great library but it only offers so much out of the box when it comes to customization. I compiled a list of API’s for creating custom “slippy maps“.

These maps require tiles. Preferably a tile server will generate these so you don’t have create your own massive directory tree containing all of the tiles. Below are options.

Oh yeah, and of course, these are all JavaScript based. This is the first of many posts to come about custom mapping.

SVG to JSON

I’ve been making a lot of map based applications lately using primarily Raphaël.js. Using the method below I can easily convert any svg exported from Illustrator to json. I find this to be a much better solution than parsing SVG with javascript for performance reasons. I will be building this class up a bit as I go and create a Github repo eventually, but I just wanted to get this out in the world to maybe help someone else doing the same thing.
Continue reading

Animation Stepping with jQuery

If all you need is great JavaScript animation and tweening I recommend using Shifty or one of the other great libraries on MicroJS. They are small, efficient and optimized for high performance. However, if your project is already using jQuery and you want a basic low-level tweening method there is no need to re-create the wheel or import any other library. Everyone is familiar with the jQuery animation method. It goes a little something like this:

It is commonly used for tweening powered by css. This is all well and good, but what if you want to tween a dom element attribute such as viewBox on a SVG element? Well, the animation method can handle that as well. Take a look.

Also, see a working example here. (Works in all modern browsers)

The “duration” is the amount of milliseconds the tween will last. “step” will be called at every step of the tween which is where you will put your animation logic of course, and finally “complete” will be called once the tween if finished. Tween on.

whattheeff

Personal Project: EFF & APR Calculator

This app distinguishes itself in it’s ease of use by instantly calculating rates without having to press extraneous buttons. When negotiating a loan, this can be useful on both sides of the table by allowing the users to convert from APR to Effective rate and back seamlessly and effortlessly.

What The EFF is a simple JavaScript & HTML5 powered converter. This is not the first APR/EFF converter, but it’s definitely the most intuitive. The app makes use of HTML5 caching (you can use it offline), Jasmine testing suite and Shifty. I developed this app specifically for Webkit browser; Chrome & Safari.

Check it out here.

Facebook Sharing Using Open Graph

People like having a convenient Facebook share link on their website. Facebook allows you to do this by passing a few arguments to their sharer.php script. Like so:

<a href="https://www.facebook.com/sharer/sharer.php?u=http://example.com/stuff/11/2200&t=Some text about the shared item.">Share!</a>
  1. The u argument is the url that you are sharing.
  2. The t argument should be the descriptive text that goes along with the post. However this is deprecated and no longer works. Awesome, thanks Facebook.

Facebook now uses the new Open Graph mata tags to read in the information about the page. This is good because it allows you to be specific about what gets shared and how it’s displayed. Although, you can not share items differently that reside on the same page. This is more common with JavaScript driven sites that make use of lightboxes and auto-scrollers. These type of sites use the hash tag to distinguish sections but all share the same meta tags, which means each page will be shared the exact same. To get around this I created a share page that is simply for sharing.
Continue reading

rye

Introduction to Rye

Rye is a professional and bone dry WordPress starter theme that I have been working on. Assuming you are quite familiar with the almighty Loop, it is not included. Along with all of the other mumbojumbo you either end up stripping out or let take up lines in your code. With the default WordPress themes I find much of my time is used removing unwanted code, deleting files and re-writing code from previous sites. Rye aims to correct these issues by giving a solid site foundation with out a specific theme in mind. The heart of Rye is the beautiful functions.php file.

Check it out on GitHub or Download it