Skip to content

Instantly share code, notes, and snippets.

View rawrjustin's full-sized avatar

Justin Huang rawrjustin

  • Snap, Inc.
  • Los Angeles
View GitHub Profile
// Swift Extension on MTLModel
extension MTLModel: Parseable {
public static func parseResponseObject(responseObject: AnyObject) throws -> AnyObject {
if let JSON = responseObject as? Array<AnyObject> {
do {
return try MTLJSONAdapter.modelsOfClass(self, fromJSONArray: JSON) as! [MTLModel]
} catch {
throw BridgeErrorType.Parsing
- (UIImage*)getImageFromURL {
NSURL *url = [NSURL URLWithString:@"http://storm8.com/image.png"];
return [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
}
- (void)saveImage: (UIImage*)image
{
if (image != nil)
{
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
@rawrjustin
rawrjustin / geometry3.h
Created March 15, 2012 10:03
asteroids
/**** Basic setup for defining and drawing objects ****/
// Moved to a header for the second and subsequent OpenGL programs
#ifndef __INCLUDEGEOMETRY
#define __INCLUDEGOEMETRY
const int numobjects = 2 ; // ** NEW ** number of objects for buffer
const int numperobj = 3 ;
const int ncolors = 4 ;
GLuint buffers[numperobj*numobjects+ncolors+1] ; // ** NEW ** List of buffers for geometric data
@rawrjustin
rawrjustin / features.rb
Created March 14, 2012 14:10
Framework to get started.
require "redis"
redis = Redis.new
INITIAL_FILE = ARGV[0] #the initial file
END_FILE = ARGV[1] #the end file
def listFriends(user, file)
key1 = file + ":" + user + ".to"
key2 = file + ":" + user + ".from"
return redis.sinter key1, key2
end