Skip to content

Instantly share code, notes, and snippets.

View kespindler's full-sized avatar

Kurt Spindler kespindler

View GitHub Profile
@kespindler
kespindler / gist:1155771
Created August 19, 2011 01:18
View entire uiview hierarchy.
Easy Way to Debug UIView Hierarchy
Do you want to see complete view hierarchy for debugging purposes? There is an easy way to do it, provided by Apple - totally unofficially!
Actually official documentation says it's undocumented and not supported. No problem with that. Very kind of Apple, good developer service!
Found this in Technical Note TN2239 "iOS Debugging Magic", section "Cocoa and Cocoa Touch - UIKit":
UIView implements a useful description method. In addition, it implements a recursiveDescription method that you can call to get a summary of an entire view hierarchy.
Therefore I could have saved lots of time and effort in How to Find MFMailComposeViewController Email Addresses with a single line of code. Just to verify that it's not possioble to find recipient email addresses by digging deep into view hierarchy I could have used this:
NSLog(@"%@", [controller.view recursiveDescription]);
@kespindler
kespindler / get_page_with_cookiejar.py
Created October 1, 2011 11:23 — forked from jabbalaci/get_page_with_cookiejar.py
download a cookie-protected page using cookielib
#!/usr/bin/env python
import os
import sqlite3
import cookielib
import urllib2
COOKIE_DB = "{home}/.mozilla/firefox/cookies.sqlite".format(home=os.path.expanduser('~'))
CONTENTS = "host, path, isSecure, expiry, name, value"
COOKIEFILE = 'cookies.lwp' # the path and filename that you want to use to save your cookies in
@kespindler
kespindler / gist:1365673
Created November 15, 2011 00:20
Javascript structs
function makeStruct(names) {
var names = names.split(' ');
var count = names.length;
function constructor() {
for (var i = 0; i < count; i++) {
this[names[i]] = arguments[i];
}
}
return constructor;
}
@kespindler
kespindler / gist:1381454
Created November 21, 2011 02:44
Count sloc in project
find . -type f -name '*.[hm]' -exec cat {} \; | sed '/^\s*#/d;/^\s*$/d;/^\s*\/\//d' | wc -l
@kespindler
kespindler / import_cards.js
Created November 24, 2011 17:40
Trello: Add multiple cards bookmarklet
(function () {
var body = document.getElementsByTagName("body")[0];
var bg = document.createElement("div");
bg.setAttribute("style", "position: absolute; z-index: 1000; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0, 0, 0, 0.5)");
var form = document.createElement("div");
form.setAttribute("style", "margin: 0 auto; height: 100%; width: 800px; padding: 50px; background: rgb(200, 200, 220);");
form.appendChild(document.createTextNode("Board: "));
var list_select = document.createElement("select");
var lists = boardView.model.listList.models;
@kespindler
kespindler / gist:1401553
Created November 28, 2011 19:04
Find the tags that are used in a view hierarchy so you don't interfere with existing tags!
- (NSMutableSet *)recurIntoView:(UIView *)v {
NSMutableSet *s = [NSMutableSet set];
for (UIView *sv in v.subviews) {
[s addObject:[NSNumber numberWithInt:sv.tag]];
[s unionSet:[self recurIntoView:sv]];
}
return s;
}
@kespindler
kespindler / gist:1628187
Created January 17, 2012 19:07
List of all files touched by a selection of commits
echo 'fef15b2286372c87679fcbd9a38b9e6f0a740765
2ce3225d49680b7e64a83eb75229ebed8da33c74
045e7e049c22c186de21eb719417f713062250ae
9f5e6fc83bd9a28800180d7540c7f7f7f10e6c38
a0de8e3fc009851dda39c82d2aeba6499a7e3bf9
b80e4c0599beb28b93dd3b56414993024eb2c7c6 4b6e941673093657b7e751e3282d6ea155e54c5d
77978e50d2f57061f0a76803f9ec91513e2122f0
a47c4071ec93cb848c9d23aba77a6b4df9d0100a
78219d437a5e7b34d43e1fc62b96b8a87b3e32cf' | xargs git show --pretty="format:" --name-only | uniq
@kespindler
kespindler / gist:1933962
Created February 28, 2012 17:52
Python Null object, behaves like nil in Objective-C
## {{{ http://code.activestate.com/recipes/68205/ (r1)
#!/user/bin/env python
"""null.py
This is a sample implementation of the 'Null Object' design pattern.
Roughly, the goal with Null objects is to provide an 'intelligent'
replacement for the often used primitive data type None in Python or
Null (or Null pointers) in other languages. These are used for many
@kespindler
kespindler / gist:2339324
Created April 8, 2012 19:10
first tesseract attempt
G 8 O . wrfles (D anmes nouns
\3H?m, iegui, 2\_2 Ewing‘? 1 u§: E2 ;~f¢u?~
1>>>>>>>>>>>> _
\‘\\1\,u\;\;\_
4c'\a1
A Bad Ha VCJ
ACarCras'\
AC'\eaa Molefl
A Fmflre
A F.HMoo1
@kespindler
kespindler / gist:2415840
Created April 18, 2012 19:10
Directory push/pull with python fabric
from fabric.api import *
from fabric.contrib import project as project
SYNC_DIR = 'MY_DIRECTORY'
def push():
local('rsync -avz --exclude fabfile.py --exclude fabfile.pyc . %s' % SYNC_DIR)
def pull():
local('rsync -avz --exclude fabfile.py --exclude fabfile.pyc %s .' % SYNC_DIR)