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:4487285
Created January 8, 2013 19:49
My UICollectionViewLayout subclass
//
// BJUPortraitLayout.m
// BizjournalsUniversal
//
// Created by Wess Cope on 1/7/13.
// Copyright (c) 2013 ACBJ. All rights reserved.
//
#import "BJUPortraitLayout.h"
#import "Archimedes.h"
@wess
wess / gist:4484487
Created January 8, 2013 15:07
Wow, collectionview layout all wrong?
//
// BJUPortraitLayout.h
// BizjournalsUniversal
//
// Created by Wess Cope on 1/7/13.
// Copyright (c) 2013 ACBJ. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MyTableController : UITableViewController
@end
@interface MyTableController()
@property (strong, nonatomic) NSArray *myArray;
@end
@implementation
- (void)viewDidLoad
{
@wess
wess / gist:4236518
Created December 7, 2012 21:04
Wilde Readme

Wilde

Wilde, named after the author Oscar Wilde, is a helper class that eases the pain of creating and drawing attributed strings.

Getting started:

  • First grab the Wilde repository: git submodule add git://github.com:wess/Wilde.git

  • The grab Wilde's submodules: git submodule update --init --recursive

@wess
wess / gist:4236368
Created December 7, 2012 20:46
Link detection/getting in coretext based view
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self];
NSString *link = [attrString urlStringForTextAtPoint:location];
if(link)
NSLog(@"LINK: %@", link);
}
@wess
wess / gist:4228027
Created December 6, 2012 20:26
parsing HTML
NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedString alloc] initWithString:string attributes:self.attributes];
TFHpple *doc = [[TFHpple alloc] initWithHTMLData:[[string lowercaseString] dataUsingEncoding:NSUTF8StringEncoding]];
NSArray *elements = [doc searchWithXPathQuery:@"//b | //strong | //em | //i"];
[elements enumerateObjectsUsingBlock:^(TFHppleElement *element, NSUInteger idx, BOOL *stop) {
NSString *tagName = [element.tagName lowercaseString];
if([tagName isEqualToString:@"b"] || [tagName isEqualToString:@"strong"])
{
NSRange boldRange = [string rangeOfString:element.text];
#ifndef __WC__MACROS__
#define __WC__MACROS__
#define AND &&
#define OR ||
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define APP_EXECUTABLE [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]
#define APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]
#ifndef __WC__MACROS__
#define __WC__MACROS__
#define AND &&
#define OR ||
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
@wess
wess / gist:3894907
Created October 15, 2012 19:56
Survey example form file
// BJSignupForm.h
// Bizjournals
//
// Created by Wess Cope on 10/15/12.
// Copyright (c) 2012 ACBJ. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Survey/Survey.h>
@wess
wess / gist:3802994
Created September 29, 2012 02:52
objc shit
@protocol ClassADelegate;
@interface ClassA : NSObject
@property (strong, nonatomic) id<ClassADelegate>delegate;
- (void)letShitHappen;
@end
@protocol ClassADelegate <NSObject>
- (void)doSomeShit;