Category: web

OCT 29 2011

Using Javascript Timeouts for Performance

Wait, what? Doesn't setting timeouts in Javascript delay a piece of code from being run for an X amount of time, so how could it possibly help with performance? Imagine writing a Javascript app that is doing some large, computationally-expensive task like adding a five thousand elements to the DOM:...
JUL 30 2011

Ajax Partial Loading

In today's applications, it's common to use AJAX to load dynamic parts of a website without having to do a full page refresh. With Rails, it's easy to template these changes instead of using Javascript to update the DOM structure manually. Imagine you have some portion of the page (say,...
JUL 10 2011

Rails Authlogic Conditional Validations

When building a web app, one of the first features you usually add is the ability for users to register and log in to see their data linked with their personal account. And most of the time, you will be using validations on your User model to ensure that the...
MAY 26 2011

Paperclip + S3 with Rails

When I revamped my portfolio, one of the major changes I did was to change my attachment process to upload files (screenshots of my projects, etc) to Amazon S3 instead of to the local filesystem. ## Why S3? Putting large media files on S3 (aka "content storage/distribution") is a great...
JAN 31 2011

Rails exception_notification Setup

With any launched web app, it's a _very_ good idea to set up some kind of exception notification - in fact, it's on my [top 3 "Launch Checklist"](/my-launch-checklist/). Exception Notification is a handy service that plugs into your existing app and sends you an email if (when) any exceptions are...
JAN 27 2011

JQuery Autocomplete with hidden data

This is a problem that I've encountered many times before when building Rails apps, but didn't know how to solve elegantly until one of my friends pointed out the solution was directly in the JQuery Autocomplete documentation (in my defense, it was at the _very_ bottom). Imagine you have an...
DEC 22 2010

Dynamic Stylesheet/Javascript Loading in Rails

Sometimes when I'm coding Rails applications, it's useful to split up CSS and Javascript files by controller/views to prevent loading a huge CSS or Javascript file (containing all of the styles and code for the entire application) on every single page of the application when you only really need it...
SEP 02 2010

Reversing Text with CSS

A couple of days ago, I saw one of the coolest CSS tricks I've seen in a really long time. You know how people usually put their email as "amber DOT feng AT gmail DOT com" or something to that effect in an attempt to foil bots from spamming their...
AUG 16 2010

Storing Arrays in a Database Field w/ Rails ActiveRecord

When I first started writing [Expendite](http://expenses.amberfeng.com), an expense sharing web application targeted toward apartment-mates, I barely knew Rails. For each expense, I needed a way to record which users were involved as parties. Basically I needed a many-to-many association with a join table, though I didn't know it at the...
AUG 03 2010

JQuery Draggable and Droppable

On a whim, I recently whipped together and launched [REOrganize](http://reorganize.amberfeng.com), a small JavaScript application that lets users simulate arranging furniture around in a room via dragging and dropping. To build this quickly, I utilized [JQuery's fantastic UI library](http://jqueryui.com/) full of ready-made effects and widgets. To take advantage of these effects...
JUL 23 2010

Setting Cookies with JQuery

I've never really used or dealt with browser cookies before because I felt like it was some complicated, advanced technique that required intricate knowledge of how browsers and sessions work. Today at work, I was given a task that involved setting, checking, and removing cookies for our web application, but...
JUL 22 2010

Detecting Mobile Devices for Web Applications

As mobile devices become a bigger and bigger platform for viewing web pages, web application developers need to start paying attention to making their websites mobile-friendly. Have you ever visited a website from a smartphone that was obviously not mobile optimized? It's not a great experience, having to zoom in...
JUL 21 2010

IDs vs. Classes?

IDs should generally be used when the element is unique, whereas classes should be used when there are a lot of similar elements that need the same styling. It would be perfectly legal to use IDs for every single element on a page (if they are unique, of course), but...
JUL 13 2010

Basic (CSS) JQuery Selectors

I love JQuery. Oh so easy to use, excellent documentation, and an abundance of third-party plugins and widgets ready made for almost anything you could ever need. Of course, one of the most important parts of the library are JQuery's selectors, easy CSS-like syntax to select specific DOM elements to...
JUN 29 2010

JQTouch Animation Flicker Bug Fix

I've been working with the [jQTouch](http://www.jqtouch.com/) (a jQuery plugin for mobile development that imitates much of iPhone's UI and animation features) for quite some time now at work. It's pretty great, but I've been running into small little glitches like animation flickering for 'slide' animations that do not have fantastic...
MAY 24 2010

Rails: Starting RSpec

This is basically the same deal as the Restful Authentication post below. I've used RSpec in the past (these quick start-up guides are not for beginners), I just need somewhere to quickly reference the beginning commands/code snippets to start my Rails applications. Here it goes! ## Installing RSpec and RSpec...
MAY 23 2010

Rails: Restful Authentication Quick Start

I almost always use Restful Authentication for my Rails applications. (For those of you who don't know what Restful Authentication is, it's a widely used Rails plugin for managing user authentication. In short, it's a plugin/gem that easily allows you to have users logins/etc on your application without the hassle...