Skip to content

Instantly share code, notes, and snippets.

View jkubicek's full-sized avatar

Jim Kubicek jkubicek

View GitHub Profile
@jkubicek
jkubicek / gist:4569613
Last active December 11, 2015 07:58
How big is a UIView?
UIView *view = [[UIView alloc] init];
NSData *objData = [NSData dataWithBytes:(__bridge const void *)(view) length:malloc_size(view)];
NSLog(@"Object contains %@", objData);
/*
Code via http://mikeash.com/pyblog/friday-qa-2009-03-13-intro-to-the-objective-c-runtime.html
Output:
Object contains <bc8d7f00 603f6507 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 200000c0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000>
@jkubicek
jkubicek / gho
Created January 3, 2013 07:43
Oneliner bash command for opening the current git repo in github
git config --get remote.origin.url | sed 's#^[^:]*.\([^.]*\)\.git#http://github.com/\1#' | xargs open
@jkubicek
jkubicek / gist:3759637
Created September 21, 2012 03:54
Sort Obj-C properties and methods
#!/usr/bin/ruby
def sortProperties(lines)
props = Hash.new
lines.each {|line|
props[line.gsub(/@.+?(\w+?);[^;]*?$/, "\\1")] = line
}
sortedKeys = props.keys.sort
@jkubicek
jkubicek / gist:2960126
Created June 20, 2012 14:19 — forked from cliss/gist:2959813
2012 MacBook Options on $2700 Budget
+---------------+--------------------------+-------------------------+------------------------+
| | 13" MacBook Air | 15" MacBook Pro | 15" Retina MacBook Pro |
| | $2450 | $2790 | $2750 |
+===============+==========================+=========================+========================+
| CPU | 2.0 Dual Core i7 $1500 | 2.3 Quad Core i7 $1800 | 2.3 Quad Core i7 $2200 |
+---------------+--------------------------+-------------------------+------------------------+
| RAM | 8 GB $100 | 16 GB (OWC) $170 | 16 GB $200 |
+---------------+--------------------------+-------------------------+------------------------+
| HD Size/Style | 512 GB SSD $500 | 120 GB SSD (OWC) $140 | 256 GB SSD |
| | | 750 GB 7200 RPM $150 | |
#!/usr/bin/ruby
# First we save our current branch to a dummy branch
# Just in case something goes awry.
`git branch -f git-squish-backup`
branches = `git branch`
curr_branch = /^\*.+/.match(branches)[0]
curr_branch.sub!(/^\*./, '')
#include <sys/time.h>
#import <Foundation/Foundation.h>
int
timeval_subtract (result, x, y)
struct timeval *result, *x, *y;
{
/* Perform the carry for the later subtraction by updating y. */
if (x->tv_usec < y->tv_usec) {
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
@jkubicek
jkubicek / build and deploy
Created February 7, 2012 15:59
iOS build script
#!/bin/sh
WORKSPACE="$(pwd)/XXXXX.xcodeproj/project.xcworkspace"
CONFIG="Release"
SCHEME="Release"
SDK="iphoneos5.0"
TARGET="XXXXX"
BUILDDIR="$(pwd)/build/Release-iphoneos"
APPNAME="XXXXX"
DEVELOPER_NAME="iPhone Distribution: XXXXX"
@jkubicek
jkubicek / .vimrc
Created January 7, 2012 04:48
My .vimrc
set nocompatible " choose no compatibility with legacy vi
syntax enable
set encoding=utf-8
set showcmd " display incomplete commands
filetype plugin indent on " load file type plugins + indentation
set relativenumber " line numbers start from 0 at current line
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
@jkubicek
jkubicek / gist:1503941
Created December 21, 2011 00:24
Lorem ipsum generator for Obj-C
#import <Foundation/Foundation.h>
#define DEBUG
//#undef DEBUG
//>>>>> snip
#ifdef DEBUG
static inline NSString * GenerateLorumStringCharCount(NSUInteger count)
{
NSString *lorum = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ";
@jkubicek
jkubicek / gist:1503874
Created December 20, 2011 23:59
Have CodeRunner use clang for compilation
Open "/Users/<UserName>/Library/Application Support/CodeRunner/Languages/5/compile.sh"
Change this line:
gcc "$1" -o "$compname" -finput-charset=${enc[$2]} -ObjC $3
to
clang "$1" -o "$compname" -finput-charset=${enc[$2]} -ObjC $3