Skip to content

Instantly share code, notes, and snippets.

View soffes's full-sized avatar

Sam Soffes soffes

View GitHub Profile
@nathansmith
nathansmith / html_reset.css
Created January 28, 2010 00:02
Reset for HTML4 / HTML5
/* `XHTML, HTML4, HTML5 Reset
----------------------------------------------------------------------------------------------------*/
a,
abbr,
acronym,
address,
applet,
article,
aside,
# Apple Binary Property List serializer for Ruby 1.8.
require 'iconv'
module AppleBinaryPropertyList
MIME_TYPE = 'application/octet-stream' # Don't know what to use, so use a very generic type for now
CFData = Struct.new(:data) # For marking strings as binary data which will be decoded as a CFData object
//
// SSMapAnnotation.h
// Public Domain
//
// Created by Sam Soffes on 3/22/10.
// Copyright 2010 Sam Soffes. All rights reserved.
//
#import <MapKit/MapKit.h>
@mattorb
mattorb / gist:415172
Created May 26, 2010 22:31
discrete, custom timed (per frame) UIImageView Animation
// keyTimes = array floats for second [(NSNumber)1.2,(NSNumber)2.0] == 2 frames, 1.2 secs for first frame, 2.0 seconds for second frame
- (void) addDiscreteTimedImageAnimation:(NSString *)animationName view:(UIImageView *)imageView images:(NSArray *)images keyTimes:(NSArray *)keyTimes repeatCount:(float)repeatCount onDone:(SEL)callback {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:[images count]];
NSMutableArray *keyTimesAsPercent = [[NSMutableArray alloc] initWithCapacity:[keyTimes count]];
double totalDuration = 0.0;
for(UIImage *image in images) {
[values addObject:(id)(image.CGImage)];
}
window.onload = function () {
if (! document.querySelectorAll) { // Quick & Dirty way to tell the good browsers from the bad ones.
alert("Please upgrade your browser to view this site.");
}
};
@drnic
drnic / snippet.rb
Created July 12, 2010 23:27
Sometimes you just need to know if anyone has forked your project recently
#!/usr/bin/env ruby
#
# USAGE:
#
# ruby -rubygems -ropen-uri -e 'eval open("http://gist.github.com/raw/473222/snippet.rb").read' jbarnette dr-nic-magic-awesome
#
# Or locally:
#
# $ show_forks jbarnette dr-nic-magic-awesome
# jbarnette - 2008/06/05 15:54:29 -0700
@lukeredpath
lukeredpath / Rakefile
Created August 31, 2010 18:16
Rakefile.rb
require 'rake/tasklib'
TARGET_NAME = "libLROAuth2Client"
module XcodeBuild
class TaskBuilder < Rake::TaskLib
attr_accessor :target, :configuration
def initialize(name)
@name = name
@seangaffney
seangaffney / TextMate SASS Save to CSS
Created September 16, 2010 22:26
This TextMate command will export your SCSS files to CSS on save. Hotness. Requires HAML gem to be installed. It's really just a modified version of the LESS Save to CSS command. Be sure to check the screenshot in the comments for the rest of the config
#!/usr/bin/env ruby
file = STDIN.read[/sass: ([^*]+\.scss)/, 1] || ENV["TM_FILEPATH"]
file2 = file.sub(/\.scss/,'.css')
system("sass \"#{file}\":\"#{file2}\"")
@jakemarsh
jakemarsh / gist:592329
Created September 22, 2010 19:28
Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Your users will thank you. A lot.
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.view endEditing:YES];
}
//The endEditing: method on UIView comes to us from a category that UITextField adds to UIKit that makes the view or any subview that is the first responder resign (optionally force), that's what the "YES" bit is.

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";