Skip to content

Instantly share code, notes, and snippets.

View wess's full-sized avatar
💭
When am I not writing code?

Wess Cope wess

💭
When am I not writing code?
View GitHub Profile
@wess
wess / gmail_to_post.py
Created December 8, 2011 20:45
Use python to read Gmail and post to a web service
#
# gmail_to_post.py
# FrenzyLabs, llc (@frenzylabs)
#
# Created by Wess Cope (@wesscope) on 2011-12-08.
# Copyright 2011 FrenzyLabs, llc. All rights reserved.
#
# Using:
# Python 2.7
# Requests: http://python-requests.org
@wess
wess / stackfile
Created January 6, 2012 15:32
Example of a Stackfile that has less, jquery and the less skeleton files
/***
* This is an example Stackfile
*/
/* PATHS */
var jsPath = "js",
cssPath = "css",
lessPath = "less";
/* PATHS */
@wess
wess / UIButton+Addition.h
Created January 21, 2012 16:00
added setBackground for event to UIButton
#import <UIKit/UIKit.h>
@interface UIButton(WCButton)
@property (nonatomic, retain) NSMutableDictionary *backgrounds;
- (void) setBackgroundColor:(UIColor *)bgColor forState:(UIControlState)state;
@end
@wess
wess / request.coffee
Created January 30, 2012 18:17
My quick Request class for CoffeeScript
# This is my first full blow coffeescript class Im working on
# thoughts?
class Request
constructor: ->
@xhrObjects = [
-> new XMLHttpRequest()
-> new ActiveXObject("Msxml2.XMLHTTP")
-> new ActiveXObject("Microsoft.XMLHTTP")
]
@wess
wess / request.coffee
Created February 6, 2012 17:06
Basic and Simple to Use Request Class for CoffeeScript
#
# request.coffee
#
# Created by Wess Cope on 2012-01-30.
#
# Just a start. The basics in place and working
# to expand as elements are needed.
#
class Request
@wess
wess / forms.coffee
Created February 8, 2012 14:57
Django like form generation and validation for client side (in CoffeeScript)
#
# forms.coffee
#
# Created by Wess Cope on 2012-02-07.
#
window.document.getValuesOfFormWithId = (id)->
tags = ['input', 'select', 'textarea']
nonTypes = ['reset', 'submit', 'button']
@wess
wess / gist:1847954
Created February 16, 2012 21:22
Drawing a complex-ish button with QuartzCore
// This is a bit messy right now, wanted to get it looking like i wanted before subclassing
// UIButton and making it proper like.
// Uses macros and categories from: http://github.com/wess/Additions
//
CGRect buttonFrame = CGRectInset(SCREEN_BOUNDS, 12.0f, 0.0f);
buttonFrame.size.height = 60.0f;
buttonFrame.origin.y = fieldFrame.size.height + fieldFrame.origin.y + 20.0f;
@wess
wess / gist:1935821
Created February 28, 2012 22:50
Scale UIImage
- (UIImage *)withNewSize:(CGSize)newSize
{
CGRect newRect = CGRectIntegral(CGRectMake(0.0f, 0.0f, newSize.width, newSize.height));
CGImageRef imageRef = self.CGImage;
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, newSize.height);
@wess
wess / gist:1949952
Created March 1, 2012 13:53
Macro for Singleton with GCD
#define SINGLETON(classname) \
+(classname *)instance { \
static dispatch_once_t onetime; \
static classname *shared = nil; \
dispatch_once(&onetime, ^{ \
shared = [[classname alloc] init]; \
}); \
return shared; \
}
@wess
wess / gist:1961452
Created March 2, 2012 21:13
BezierDammit
NSColor *topBorderColor = WHITE;
NSColor *btmBorderColor = HEX_COLOR(@"aaa");
NSBezierPath *topBorder = [NSBezierPath bezierPath];
[topBorder moveToPoint:CGPointMake(0.0f, 0.0f)];
[topBorder lineToPoint:CGPointMake(dirtyRect.size.width, 0.0f)];
[topBorder setLineWidth:1.0f];
[topBorderColor setStroke];
[topBorder stroke];