Skip to content

Instantly share code, notes, and snippets.

View timothy1ee's full-sized avatar

Timothy Lee timothy1ee

View GitHub Profile
@timothy1ee
timothy1ee / miso_api_demo.rb
Created December 21, 2010 00:15
Miso API Demo Application
# miso_api_demo.rb
# To start the app:
# $ ruby miso_api_demo.rb
# Visit http://localhost:4567
require 'rubygems'
require 'sinatra'
require 'oauth'
require 'json'
@timothy1ee
timothy1ee / 4steps.md
Created January 17, 2011 21:52
Notes on Four Steps to the Epiphany

Notes on Four Steps to the Epiphany

The Hero's Journey

A startup is not unlike a hero's journey; there's a vision or goal, and a journey filled with obstacles. Just as the hero's story has archetypal patterns, successful startups share the same outline. I.e., there is a true and repeatable path that eliminates or mitigates the most egregious risks and allows the company to grow into a large, successful enterprise. Not only that, but the successful path is nearly completely different from traditional "Product Development" processes and methodologies; Steve Blank calls this path "Customer Development". This book describes the "Customer Development" model.

Winners and Losers

Essentially, the criteria for success is simple: products developed with constant contact with customers win; products that aren't, lose.

# Returns a hash based representation of any data object given ejs template block
# object_to_hash(@user) { attribute :full_name } => { ... }
# object_to_hash(@user, :source => "...") { attribute :full_name } => { ... }
def object_to_hash(object, options={}, &block)
return object unless is_record?(object) || object.respond_to?(:each)
object = { data_object(object) => data_name(object) } if object.is_a?(Hash) && object.keys.first.is_a?(Symbol)
engine_options = { :format => "hash", :root => (options[:root] || false) }
Rabl::Engine.new(options[:source], engine_options).render(@_scope, :object => object, &block)
end
@timothy1ee
timothy1ee / gist:1161664
Created August 22, 2011 04:35
Vendor tasklist notes
Basic demo application
======================
- Build a sample project/workspace
- Add all commonly used iOS libraries
Sample Folder structure
=======================
- demo_project
- demo_project.pbxproj
- multiple targets
@timothy1ee
timothy1ee / checkin.json
Created December 20, 2012 22:32
Response for: GET '/api/oauth/v1/checkins/<id>.json
{ "checkin" : { "badges" : [ ],
"comment" : "Blabla",
"created_at" : "2012-11-27T01:54:16Z",
"episode_airdate" : "2012-11-25",
"episode_label" : "S02E09",
"episode_num" : 9,
"episode_poster_url" : "http://gomiso.com/uploads/BAhbCFsHOgZmIigyMDEyLzExLzE5LzA2LzM3LzUxLzg5Mi~DrW5kaWNlLmpwZ1sHOgZlOghqcGdbCDoGcDoKdGh1bWIiDjE4MHgxMDAjbg.jpg",
"episode_poster_url_small" : "http://gomiso.com/uploads/BAhbCFsHOgZmIigyMDEyLzExLzE5LzA2LzM3LzUxLzg5Mi~DrW5kaWNlLmpwZ1sHOgZlOghqcGdbCDoGcDoKdGh1bWIiDTEyNXg3NSNu.jpg",
"episode_season_num" : 2,
"episode_title" : "Two Hats",
@timothy1ee
timothy1ee / LoginActivity.java
Created June 15, 2013 23:05
Sample login activity incorporating Facebook Android SDK
import java.util.Arrays;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import com.facebook.Request;
import com.facebook.Response;
POST /v2/blog/timothy1ee.tumblr.com/post HTTP/1.1
Authorization: OAuth oauth_signature="YhcFwLZ0A08kF8XXDceuIlN8G3Y%3D", oauth_version="1.0", oauth_nonce="221227710", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="BcnUeYPIxBaVCz5sYcs4SkytRqM8azgLclb1PUpeFcknic9RYY", oauth_timestamp="1372109208", oauth_token="RCC7HW8BEWeXWCTR0UVTF4R2JRIn1Mba0N9PmcNpIa3FATNFsR"
Content-Length: 272570
Content-Type: application/x-www-form-urlencoded
Host: api.tumblr.com
Connection: Keep-Alive
User-Agent: android-async-http/1.4.1 (http://loopj.com/android-async-http)
Accept-Encoding: gzip
api_key=BcnUeYPIxBaVCz5sYcs4SkytRqM8azgLclb1PUpeFcknic9RYY&data=%25EF%25BF%25BDPNG%250D%250A%251A%250A%2500%2500%2500%250DIHDR%2500%2500%2500x%2500%2500%2500x%2508%2502%2500%2500%2500%25EF%25BF%25BD%2506%25EF%25BF%25BD%25EF%25BF%25BD%2500%2500%2500%2503sBIT%2508%2508%2508%25EF%25BF%25BD%25EF%25BF%25BDO%25EF%25BF%25BD%2500%2500%2B%2500IDATx%25EF%25BF%25BDL%25EF%25BF%25BD%25EF%25BF%25BD%255Dgu%25EF%25BF%25BD%25EF%25BF%25BD%25EF%25BF%25BD%
@timothy1ee
timothy1ee / 1_tip_calculator_overview.md
Last active December 30, 2015 00:09
Creating the Tip Calculator

Creating the Tip Calculator

Before you get started, download XCode 6 from the Mac App Store. You can buy an iOS Developer Program for $99, but it's not required at this stage.

Start reading about Objective-C. Here's a good quick overview. A more complete primer from Apple is here. If you prefer to learn by video, Lynda has a good overview, it's about 6 hours.

Follow the tip calculator video walkthrough to get the basic tip calculator functionality. After you finish the walkthrough, follow the hints below to add a settings page.

@timothy1ee
timothy1ee / gist:8308396
Last active January 2, 2016 13:09
Objective C Rotten Tomatoes snippet
NSString *url = @"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?apikey=dagqdghwaq3e3mxyrp7kmmj5&limit=20&country=us";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
id object = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"%@", object);
}];
@timothy1ee
timothy1ee / gist:8393719
Created January 13, 2014 02:20
Example of using prepareForSegue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
UITableViewCell *selectedCell = (UITableViewCell *)sender;
NSIndexPath *indexPath = [self.tableView indexPathForCell:selectedCell];
Movie *movie = self.movies[indexPath.row];
MovieViewController *movieViewController = (MovieViewController *)segue.destinationViewController;
movieViewController.movie = movie;
}