This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <picker> | |
| <code>00000001</code> | |
| <created-at type="datetime">2012-02-24T19:57:17Z</created-at> | |
| <dob type="date" nil="true"></dob> | |
| <first-name>andy</first-name> | |
| <id type="integer">12</id> | |
| <last-name>smith</last-name> | |
| <mail-address nil="true"></mail-address> | |
| <mail-city nil="true"></mail-city> | |
| <mail-state nil="true"></mail-state> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this is really useful for collecting record counts into discrete buckets for visualization | |
| (1..6).collect {|n| Query.where(['created_at > ?',Date.today-n.months]).where(['created_at < ?',Date.today-(n-1).months]).count} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Model: | |
| # | |
| # class Example < ActiveRecord::Base | |
| # end | |
| # | |
| # Controller: | |
| # | |
| # class ExamplesController < ActionController::Base | |
| # def index | |
| # @examples = Example.filtered_scope(params[:filter]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // GCD | |
| #define async_main(aBlock) dispatch_async(dispatch_get_main_queue(), aBlock) | |
| #define async_global(aBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), aBlock) | |
| // UIKit | |
| #define Alert(aTitle,aMessage) [[[[UIAlertView alloc] initWithTitle:aTitle message:aMessage delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK",nil] autorelease] show] | |
| #define NetworkAlert Alert(@"Network error",@"Please check your network connection.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CSV.open("users.csv","wb") {|csv| User.all.each {|user| csv << [user.email, "#{user.first_name} #{user.last_name}"]}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // if you don't know why this doesn't compile, find another job | |
| int tBrains = 9; | |
| if( tBrains<10 ) { | |
| int tZombies = 1; | |
| } | |
| tZombies += tBrains; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* say you have a process driven by the main thread, such as | |
| * a UI control, and you want the process to execute on a | |
| * background thread, but once it's done, you want to update | |
| * some UI element. that must happen on the main thread, so | |
| * here's an example of how you might do that | |
| */ | |
| - (IBAction)buttonClicked | |
| { | |
| dispatch_async(backgroundProcessingQueue, ^{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSArray* set1 = [NSArray arrayWithObjects:@"one",@"two",@"three",nil]; | |
| NSArray* set2 = [NSArray arrayWithObjects:@"two",@"three",@"four",nil]; | |
| NSMutableArray* set3 = [NSMutableArray arrayWithCapacity:MIN(set1.count,set2.count)]; | |
| for (NSString* element in set1) { | |
| if( [set2 containsObject:element] ) { | |
| [set3 addObject:element]; | |
| } | |
| } |
NewerOlder