Skip to content

Instantly share code, notes, and snippets.

View PaulWoodIII's full-sized avatar

Paul Wood III PaulWoodIII

View GitHub Profile
@PaulWoodIII
PaulWoodIII / gist:4515120
Created January 12, 2013 00:12
Trivial case Login function for usergrid, using RestKit.
- (void)login{
NSURL *baseURL = [NSURL URLWithString:@"https://api.usergrid.com/[org]/[app]"];
AFHTTPClient* client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
[client setDefaultHeader:@"Accept" value:RKMIMETypeJSON];
[client registerHTTPOperationClass:[AFJSONRequestOperation class]];
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:
@"password",@"grant_type",
@"john.doe",@"username",
@"password",@"password",
nil];
#!/bin/bash
# <UDF name="ssh_key" Label="Paste in your public SSH key" default="" example="" optional="false" />
# root ssh keys
mkdir /root/.ssh
echo $SSH_KEY >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
# update to latest
@PaulWoodIII
PaulWoodIII / app.js
Last active December 11, 2015 05:48
Trying to get Gridform working but failed miserably: Gridform is here. http://aheckmann.github.com/gridform/ I need a form somewhere to make it easier to test on the browser. need a lot of modules in your project to get this to work in the first place winedb came from nodecellar code
var http = require('http');
var assert = require('assert');
var gridform = require('gridform');
var formidable = require('formidable');
var mongo = require('mongo')
, database = mongo.connect('mydb')
, collection = database.collection('fs');
// assuming you've already created a db instance and opened it
gridform.db = database;
@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});
@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
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 / 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 / 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 / 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 / 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