Skip to content

Instantly share code, notes, and snippets.

View PaulWoodIII's full-sized avatar

Paul Wood III PaulWoodIII

View GitHub Profile
//
// TestSomethingCoolTests.m
// TestSomethingCoolTests
//
// Created by Paul Wood on 9/14/16.
// Copyright © 2016 Paul Wood. All rights reserved.
//
#import <XCTest/XCTest.h>
@PaulWoodIII
PaulWoodIII / timezones.swift
Created September 5, 2016 19:15
Get all NSTimeZones and turn it into a usable Dictionary
//: # TimeZones
import Foundation
let tzs = NSTimeZone.knownTimeZoneNames()
var seperated : [String:Array<String>] = [String:[String]]()
func addToSeperated(_ region : String,_ place:String) -> Void {
if let _ = seperated[region] {
@PaulWoodIII
PaulWoodIII / Serializable.swift
Last active February 3, 2016 19:26 — forked from anaimi/Serializable.swift
Serialize a Swift object to JSON or Dictionary, with selective properties.
/**
Purpose:
Convert (or Serialize) an object to a JSON String or Dictionary.
Usage:
Use 'Serialize.toJSON' on instances of classes that:
- Inherit from NSObject
- Implement 'Serializable' protocol
- Implement the property 'jsonProperties' and return an array of strings with names of all the properties to be serialized
Inspiration/Alternative:
https://gist.github.com/anaimi/ad336b44d718430195f8
@PaulWoodIII
PaulWoodIII / PersistedObjectResponse.swift
Created December 10, 2015 21:43
How to persist Objects with CoreStore, Alamofire, and SwiftyJSON
//
// PersistedObjectResponse.swift
// Hoozin-iOS
//
// Created by Paul Wood on 12/10/15.
// Copyright © 2015 Paul Wood. All rights reserved.
//
import Foundation
import Alamofire
@PaulWoodIII
PaulWoodIII / UIImage+Trim.m
Last active December 29, 2015 09:49 — forked from spinogrizz/UIImage+Trim.m
adjusted to scale
- (UIImage *) imageByTrimmingTransparentPixels {
//adjust to scale
int rows = self.size.height * self.scale;
int cols = self.size.width * self.scale;
int bytesPerRow = cols*sizeof(uint8_t);
if ( rows < 2 || cols < 2 ) {
return self;
}
@PaulWoodIII
PaulWoodIII / gist:5063620
Created March 1, 2013 09:51
was changing the cocos2d project matrix didn't work and this is fugly code
-(void) updateProjection{
CGSize size = [[CCDirector sharedDirector] winSizeInPixels];
CGSize sizePoint = [[CCDirector sharedDirector] winSize];
float zeye = [[CCDirector sharedDirector] getZEye];
kmMat4 matrixPerspective, matrixLookup;
float stringPerspective[16];
@PaulWoodIII
PaulWoodIII / postImage
Created February 8, 2013 09:45
A function to post an image onto ADN This does not work. Trying to figure out why
- (void)postImage{
// Get a ADN Token
NSString *access_token = @"foobar";
NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
[httpClient setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Bearer %@", access_token]];
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"bird.jpg"], 0.5);
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST"
path:@"/stream/0/files"
@PaulWoodIII
PaulWoodIII / server.js
Created January 25, 2013 04:30
I tried this to fix my routing errors. Adding routes after the server is created. This stackoverflow question gave me the inspiration: http://stackoverflow.com/questions/12714999/nodejs-express-redisstore-req-session-undefined It didn't work.
var express = require('express'),
path = require('path'),
http = require('http'),
wine = require('./routes/wines'),
cup = require('./routes/cups'),
imagepost = require('./routes/imageposts');
mongo = require('mongodb'),
Server = mongo.Server,
Db = mongo.Db,
GridStore = mongo.GridStore,
@PaulWoodIII
PaulWoodIII / request object is null bug
Created January 22, 2013 05:51
I had a bug using express.js and backbone.js. I thought it was backbone for the longest time. It wasn't I accidentally removed a key line of code for the configuration of my app.
//If you get an error in the console like this:
/*
TypeError: Cannot convert null to object
at exports.updateImagePost (/Projects/nodecellar_pw/routes/imageposts.js:160:12)
at callbacks (/Projects/nodecellar_pw/node_modules/express/lib/router/index.js:161:37)
at param (/Projects/nodecellar_pw/node_modules/express/lib/router/index.js:135:11)
at param (/Projects/nodecellar_pw/node_modules/express/lib/router/index.js:132:11)
at pass (/Projects/nodecellar_pw/node_modules/express/lib/router/index.js:142:5)
at Router._dispatch (/Projects/nodecellar_pw/node_modules/express/lib/router/index.js:170:5)
@PaulWoodIII
PaulWoodIII / server.js
Last active December 11, 2015 05:48
trying to a a /file-upload path to the node-cella example project to put images directly onto the mongodb, added modules "connect-multipart-gridform" "gridform" and "gridfs-stream"
var express = require('express'),
path = require('path'),
http = require('http'),
wine = require('./routes/wines'),
cup = require('./routes/cups');
var Grid = require('gridfs-stream');
var mongo = require('mongodb');
var Server = mongo.Server,
Db = mongo.Db;
var server = new Server('localhost', 27017, {auto_reconnect: true});