Skip to content

Instantly share code, notes, and snippets.

View nuthatch's full-sized avatar

Stephen Ryner Jr. nuthatch

View GitHub Profile
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;{
CGFloat heightForRowAtIndexPath = 44.f;
NSString * cellID = [self cellIdForIndexPath:indexPath];
UITableViewCell <XXApplicationTableViewCellConfiguring> * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if([cell conformsToProtocol:@protocol(XXApplicationTableViewCellConfiguring)]) {
[cell configureCellWithApplicationModel:self.application];
[cell layoutSubviews];
heightForRowAtIndexPath = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
}
@kristopherjohnson
kristopherjohnson / psg.sh
Last active September 14, 2015 20:50
Bash function to print process info for matching process name
# psg NAME
function psg {
processes=$(pgrep $@)
if [ -z "$processes" ]; then
echo "No matches"
else
ps $processes
fi
}
-(IBAction)show:(id)sender{
CGRect frame = [aView frame];
frame.origin.y = [[self view] bounds].size.height;
[aView setFrame:frame];
[[self view] addSubview:aView];
[UIView beginAnimations:@"slide up" context:NULL];
frame.origin.y = [[self view] bounds].size.height - frame.size.height;
[aView setFrame:frame];
[UIView commitAnimations];
@soffes
soffes / betterway.m
Created September 13, 2010 19:57
Is there a better way?
// Original
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
static NSString *firstLaunchKey = @"firstLaunch";
// Register default defaults
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *defaultDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:YES], firstLaunchKey,
nil];
@zssz
zssz / gist:846696
Created February 27, 2011 23:33
Demo
//
// IZGoogleGeocoder.m
// JSON Google Geocoder
//
// Created by Zsombor Szabó on 2/11/11.
// Copyright 2011 IZE. All rights reserved.
//
#import "IZGoogleGeocoder.h"
@drance
drance / gist:4546014
Created January 16, 2013 09:57
Workaround to vanilla UICollectionView+UICollectionViewFlowLayout using non-integral origins, leading to blurry cells.
@implementation BHSCollectionViewFlowLayout
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *allAttrs = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *attributes in allAttrs) {
attributes.frame = CGRectIntegral(attributes.frame);
}
return allAttrs;
}
@Reefaq
Reefaq / Common.h
Created March 4, 2013 07:21
Useful Macro for almost every project - Gather from many sources and also included of own.
//
// Common.h
// Userful Macro
//
// Created by Reefaq on 06/12/12.
// Copyright (c) 2012 Reefaq. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@mchakravarty
mchakravarty / BezierVec.hs
Created July 18, 2013 03:14
Arbitrary-dimensional bezier curves with statically checked consistency of dimensions. This is a variant of https://github.com/hrldcpr/Bezier.hs using type-indexed lists (aka vectors) implemented with GADTs and data kinds.
{-# LANGUAGE GADTs, DataKinds, KindSignatures, StandaloneDeriving #-}
module BezierVec (bezier) where
infixr :::
-- encoding of natural numbers (zero and successor of a natural)
data Nat = Z | S Nat
-- indexed vectors are lists whose first type argument encodes the length of the list
anonymous
anonymous / Export iOS App Icons.jsx
Created August 23, 2013 20:05
Script for Adobe Photoshop CS5 that takes the currently open document and exports it in the standard iOS app icon sizes, including iOS 7 sizes.
// Export iOS App Icons
// by Lucius Kwok
// Takes the currently open document and exports it in the standard iOS app icon sizes.
// This script is designed for Photoshop CS5.
// To install, place this file in the /Applications/Adobe Photoshop CS5/Presets/Scripts/ folder.
try {
var doc = app.activeDocument;
var startState = doc.activeHistoryState;
var initialPrefs = app.preferences.rulerUnits;
@iamleeg
iamleeg / UIColor_literal.mm
Last active December 29, 2015 03:09
UIColor literals.
#import <UIKit/UIKit.h>
UIColor * operator"" _c(unsigned long long color)
{
unsigned long long redComponent = (color & 0xff0000 >> 16);
unsigned long long greenComponent = (color & 0x00ff00) >> 8;
unsigned long long blueComponent = color & 0xff;
float red = redComponent / 255.0;
float green = greenComponent / 255.0;
float blue = blueComponent / 255.0;