Skip to content

Instantly share code, notes, and snippets.

View hunterbridges's full-sized avatar

Hunter Bridges hunterbridges

View GitHub Profile
static inline CGRect CGRectBoundingRect(CGRect a, CGRect b) {
CGRect ret = {
.origin = {
MIN(CGRectGetMinX(a), CGRectGetMinX(b)),
MIN(CGRectGetMinY(a), CGRectGetMinY(b))
},
.size = {
MAX(CGRectGetMaxX(a), CGRectGetMaxX(b)) -
MIN(CGRectGetMinX(a), CGRectGetMinX(b)),
MAX(CGRectGetMaxY(a), CGRectGetMaxY(b)) -
#import "PFObject+SubclassInit.h"
@implementation PFObject (SubclassInit)
+ (instancetype)subclass
{
Class klass = self;
SEL selector = @selector(parseClassName);
if ([klass respondsToSelector:selector]) {
#pragma clang diagnostic push
@hunterbridges
hunterbridges / 0_reuse_code.js
Last active September 15, 2015 19:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hunterbridges
hunterbridges / binary_search.py
Created October 14, 2011 06:27
Binary search for michael
import math
def binary_search(needle, haystack):
search_index = int(math.floor(len(haystack) / 2))
test_item = haystack[search_index]
print "Searching for %d in %s" % (needle, haystack)
print "Haystack is %d long. First looking at index %d" % (len(haystack),
search_index)
print "Item at index %d is %d" % (search_index, haystack[search_index])
@hunterbridges
hunterbridges / install.log
Created October 31, 2011 20:03
Install.log for ruby thing
[2011-10-31 13:00:51] ./installer -a /Users/hbridges/.rvm/rubies/ree-1.8.7-2011.03 --no-tcmalloc --dont-install-useful-gems
Welcome to the Ruby Enterprise Edition installer
This installer will help you install Ruby Enterprise Edition 1.8.7-2011.03.
Don't worry, none of your system files will be touched if you don't want them
to, so there is no risk that things will screw up.
You can expect this from the installation process:
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
system.
@hunterbridges
hunterbridges / GolfballGrippies.h
Created December 24, 2011 21:38
Golfball Grippies
#import <UIKit/UIKit.h>
typedef enum {
kGolfballGrippiesAnimationNone = 0,
kGolfballGrippiesAnimationLeft,
kGolfballGrippiesAnimationRight
} GolfballGrippiesAnimation;
@interface GolfballGrippies : UIView {
GolfballGrippiesAnimation currentAnimation_;
@hunterbridges
hunterbridges / response.xml
Created January 27, 2012 01:01
Endicia response
<?xml version="1.0" encoding="UTF-8"?>
<StatusResponse>
<AccountID>804682</AccountID>
<ErrorMsg/>
<StatusList>
<PICNumber><Status>SORTING/PROCESSING COMPLETE (PC) at 08:38 AM on 01/26/2012 in NEW YORK NY 10040.</Status>
<StatusBreakdown>
<Status_1>Out for Delivery January 26 2012 8:48 am NEW YORK NY 10040</Status_1>
<Status_2>Sorting Complete January 26 2012 8:38 am NEW YORK NY 10040</Status_2>
<Status_3>Arrival at Post Office January 26 2012 5:11 am NEW YORK NY 10040</Status_3>
@hunterbridges
hunterbridges / ghetto.rb
Created February 24, 2012 22:03
ghetto.rb
def index
if admin?
@orders = Gift.available.redeemed
@orders = @orders.includes(:redemption_product => [:vendor], :redemption_shipping_address => [])
else
@orders = current_vendor.purchased_gifts
end
@orders = @orders.with_aging if params[:sort].present? and params[:sort] == 'aging'
@orders = @orders.order("#{params[:sort]} #{params[:dir]}") if params[:sort].present?
@hunterbridges
hunterbridges / gist:1904787
Created February 25, 2012 00:11
Command T style
filtered: function(q) {
q = q || this.query || '';
if (q === '') return this;
var chars = q.toLowerCase().replace(/[^0-9a-z]/,'').split('');
var searchFields = [
'order_number',
'vendor_name',
'product_name',
'redemption_shipping_label_tracking_number'
];
worker_processes 1;
error_log /usr/local/var/log/nginx.error.log;
events {
worker_connections 1024;
}
http {
include mime.types;