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: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>
@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 / WCMacros.h
Created January 15, 2013 16:19
My Macros
//
// WCMacros.h
// WessCioe
//
// Created by Wess Cope on 10/9/12.
// Copyright (c) 2012 WessCope. All rights reserved.
//
#ifndef __WC__MACROS__
#define __WC__MACROS__
@wess
wess / gist:4665164
Created January 29, 2013 15:37
A little function to create an HTTP query from an NSPredicate
NSMutableDictionary *generateQueryPartForPredicate(NSPredicate *predicate)
{
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
if([predicate isKindOfClass:[NSCompoundPredicate class]])
{
NSCompoundPredicate *compoundPredicate = (NSCompoundPredicate *)predicate;
for(NSComparisonPredicate *comparison in compoundPredicate.subpredicates)
[params setValue:comparison.rightExpression.constantValue forKey:comparison.leftExpression.keyPath];
@wess
wess / gist:5161817
Last active December 13, 2019 17:33
Getting visible range of text for a UITextView
@implementation UITextView (Annex)
@dynamic visibleTextRange;
- (NSRange)visibleTextRange
{
CGRect bounds = self.bounds;
CGSize textSize = [self.text sizeWithFont:self.font constrainedToSize:bounds.size];
UITextPosition *start = [self characterRangeAtPoint:bounds.origin].start;
@wess
wess / gist:5405425
Last active December 16, 2015 08:19
Get ride of those ghost processes XCode and the Simulator leave behind with this simple awk/bash script
ps aux | grep \(YOUR_APP_NAME_HERE\) | awk '{print "kill -9 " $2}' | sh
@wess
wess / RESTFolder.js
Last active December 20, 2015 04:59
A quick Node script to stub out RESTful webservices
// The MIT License (MIT)
//
// Copyright (c) 2013 Wess Cope
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
static AnnexEasingBlock AnnexEaseInQuad = ^CGFloat(AnnexEasingProperty property) {
CGFloat t = property.time,
b = property.start,
c = property.delta,
d = property.duration;
return c * (t /= d) * (t + b);
};
UIView *view = [[UIView alloc] initWithFrame:({
//do some calculations if needed to create your frame.
CGRect frame = CGRectZero;
frame.origin.x = 123.0f;
frame.origin.y = 12.0f;
frame.size.width = 100.0f;
frame.size.height = 100.0f;
@wess
wess / gist:9602507
Created March 17, 2014 16:19
keybase.md
### Keybase proof
I hereby claim:
* I am wess on github.
* I am wess (https://keybase.io/wess) on keybase.
* I have a public key whose fingerprint is 37EF CD5E 6CA3 1720 4420 B656 BBFD AE20 EBFF 3CFA
To claim this, I am signing this object: