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 / gist:2413505
Created April 18, 2012 13:18
CORETEXT Layout
#define ARTICLE_IMAGE_BORDER_SIZE 4.0f
@implementation LOArticleContentView
@synthesize text = _text;
@synthesize image = _image;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
@wess
wess / WCAttributedString.h
Created March 29, 2012 21:18
Content View using core text with 1 embedded image
//
// WCAttributedString.h
// iOS
//
// Created by Wess Cope on 3/19/12.
//
// Special Thanks to Erica Sadun's Cookbook For the following, updated just a bit.
//
#import <Foundation/Foundation.h>
@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];
@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: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: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 / 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 / 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 / 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 / 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