Skip to content

Instantly share code, notes, and snippets.

View jamesnesfield's full-sized avatar

James Nesfield jamesnesfield

View GitHub Profile
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
var mongoose = require('./db-connect'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
uuid = require('node-uuid'),
Validator = require('validator').Validator,
val = new Validator(),
bcrypt = require('bcrypt');
Validator.prototype.error = function(msg) { return false; };
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@jamesnesfield
jamesnesfield / UIImage+Screenshot.h
Created March 19, 2014 10:52
screenshots for iOS 7 as a UIImage category
@interface UIImage (Screenshot)
+ (UIImage *)screenshot;
@end
@jamesnesfield
jamesnesfield / appdelegate_macro
Created March 17, 2014 11:55
A macro for the appdelegate
#define APP_DELEGATE ((AppDelegate *)[[UIApplication sharedApplication] delegate])
@jamesnesfield
jamesnesfield / git submodules
Created March 2, 2014 12:30
clone and init all submodules.
git submodule update --init --recursive
@jamesnesfield
jamesnesfield / DebugLog
Created February 10, 2014 12:52
iOS debug-only logging
/* place in pch
from http://stackoverflow.com/questions/9621143/debuglog-format-string-is-not-a-string-literal
*/
#ifdef DEBUG
#define DebugLog(s, ...) NSLog(s, ##__VA_ARGS__)
#else
#define DebugLog(s, ...)
@jamesnesfield
jamesnesfield / singleton macro
Created February 7, 2014 14:39
singleton macro iOS
//from Urban Airship iOS SDK "1.1.2"
#define SINGLETON_INTERFACE(CLASSNAME) \
+ (CLASSNAME*)shared; \
#define SINGLETON_IMPLEMENTATION(CLASSNAME) \
\
static CLASSNAME* g_shared##CLASSNAME = nil; \
\
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
#define IS_OS_5_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0)
#define IS_OS_6_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
#define IS_OS_7_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
//http://stackoverflow.com/questions/15757872/manually-color-fading-from-one-uicolor-to-another
- (UIColor *)colorFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor amount:(float)amount // 0 < amount < 1
{
float dec = amount;
CGFloat fRed, fBlue, fGreen, fAlpha;
CGFloat tRed, tBlue, tGreen, tAlpha;
CGFloat red, green, blue, alpha;
if(CGColorGetNumberOfComponents(fromColor.CGColor) == 2) {
[fromColor getWhite:&fRed alpha:&fAlpha];