Skip to content

Instantly share code, notes, and snippets.

Travis Swicegood is a professional programmer and owner of Domain51, a web development company with a focus on non-profits, NGOs, and online activists. He doesn't change the world, he supports those who do.
He has personal a focus on web applications, performance, and stability; is author of Pragmatic Version Control using Git; and working on his second book. He has been using PHP; since '99 and still remembers how revolutionary PHP 4 was, but can't remember why. He's a TDD, open-source, and open government advocate—sometimes called a zealot—and lurker on many an open-source project mailing list when not learning other programming; languages; for fun, exploring his surroundings on bike, or tasting his latest kitchen and home-brew creations.
button.red { height: 2.5em; padding: 0px 2em; padding-bottom: 2px;
color: #fff; font-size: 15px; font-family: "Lucida Grande",Helvetica,Arial,sans-serif; text-shadow: -1px -1px 0px #aaa; cursor: pointer;
background: #e22525; background: #e22525 -webkit-gradient(linear, left top, left bottom, from(#e22525), to(#e27676));
filter: progid:DXImageTransform.Microsoft.Gradient(startColorstr=#e22525, endColorstr=#e27676, gradientType=0);
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border: 2px solid #aaa; margin-left: auto; margin-right: auto; }
@mtabini
mtabini / Sample.xml
Created December 12, 2010 14:01
A simple use case for a search bar.
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1056</int>
<string key="IBDocument.SystemVersion">10H574</string>
<string key="IBDocument.InterfaceBuilderVersion">823</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
BOOL colorSimilarToColor(UIColor *left, UIColor *right) {
float tolerance = 0.05; // 5%
CGColorRef leftColor = [left CGColor];
CGColorRef rightColor = [right CGColor];
if (CGColorGetColorSpace(leftColor) != CGColorGetColorSpace(rightColor)) {
return FALSE;
}
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:feeds="services.feeds.*" addedToStage="getFeed()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function getFeed():void
{
- (void) imageLoaded:(NSData *) data {
// data contains the data loaded from the web,
// or Nil in the event of an error
}
+ (void) queueDownloadFromURL:(NSURL *) url
withHTTPParameters:(NSDictionary *) parameters
target:(id) target
selector:(SEL) selector
atTopOfQueue:(BOOL) atTopOfQueue;
protected function fitImagesInClientArea():void {
// Create the main bin
var bins:Array = [new Bin(width, 0)];
// Sort the images
boxes.sort(function(a:Box, b:Box):int {
if (a.width > b.width) {
protected var binContainer:Array = [];
protected function getBinContainerAtIndex(index:int):HBox {
while (index >= binContainer.length) {
var hbox:HBox = new HBox();
hbox.percentWidth = 100;
hbox.height = 150;
addChild(hbox);
@mtabini
mtabini / gist:602144
Created September 29, 2010 01:24
Packing algorithm #1
protected function fitImagesInClientArea():void {
// Create the main bin
var bins:Array = [new Bin(0, 0, width, height)];
// Sort the images
boxes.sort(function(a:Box, b:Box):int {
if (a.area > b.area) {