Skip to content

Instantly share code, notes, and snippets.

View twobitlabs's full-sized avatar

Two Bit Labs twobitlabs

View GitHub Profile
@twobitlabs
twobitlabs / gist:1504661
Created December 21, 2011 05:03
git apply-stash
apply-stash = "!bash -c 'git stash list | grep $0 && git stash apply `git stash list | grep $0 | cut -d : -f 1`'"
@twobitlabs
twobitlabs / NSURLConnection+Timeout.m
Created April 30, 2012 17:55
Synchronous NSURLConnection timeout
@implementation NSURLConnection (Timeout)
+ (dispatch_queue_t)timeoutLockQueue {
static dispatch_queue_t queue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
queue = dispatch_queue_create("timeout lock queue", DISPATCH_QUEUE_SERIAL);
});
return queue;
}
@twobitlabs
twobitlabs / gist:4226365
Created December 6, 2012 17:35
Blocks cheat sheet
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
@twobitlabs
twobitlabs / gist:5121054
Created March 8, 2013 23:38
Sample UIKit layout code
-(void)contentUpdated {
CGFloat outsidePadding = 10;
CGFloat paddingBetweenElements = 5;
CGFloat maxHeadlineHeight = 200;
self.thumbnail.frame = (CGRect){(CGPoint){outsidePadding, outsidePadding}, self.thumbnail.image.size};
CGFloat headlineWidth = WIDTH(self) - (RIGHT(self.thumbnail) + paddingBetweenElements + outsidePadding);
CGFloat headlineHeight = [self.headline.text sizeWithFont:self.headline.font
constrainedToSize:CGSizeMake(headlineWidth, maxHeadlineHeight)].height;
@twobitlabs
twobitlabs / gist:6817817
Last active December 24, 2015 15:09
Redirect stderr from iOS simulator to a file. Add this to your main.m. Then you can filter the output with tail -f /tmp/myapp.log | grep "foo"
#warning Don't commit me
NSString *logPath = @"/tmp/myapp.log";
freopen([logPath fileSystemRepresentation], "a", stderr);
@twobitlabs
twobitlabs / gist:561a86f06be21370a9d4
Last active August 29, 2015 14:22
search diff commits
git-search-diffs() {
if [ -z "$2" ]
then
echo "Use git-search-diffs to search for commits where the diff includes the search term"
echo "Usage: git-search-diffs <path> <search term>"
return
fi
git log -p $1 | egrep -i "^commit|^[-+].*$2" | egrep -B1 ^[+-]
}
//
// HudlHlsAvPlayerCache.m
// Hudl
//
// Created by Brian Clymer on 3/6/15.
// Copyright (c) 2015 Agile Sports Technologies, Inc. All rights reserved.
//
#import "HudlHlsAvPlayerCache.h"
diff --git a/tags.json b/tags.json
index cfe769d..d8a9b43 100644
--- a/tags.json
+++ b/tags.json
@@ -1,5 +1,5 @@
{
- "last_published": "2017-04-19 20:42:30 +0000",
+ "last_published": "2017-04-20 00:22:44 +0000",
"root": {
"children": [
{
"id": 21640,
"leagueScoresWidget": {
"games": []
},
"live_update": true,
"metadata_type": "permanent",
"name": "nfl_ts",
"native_next_game_widget": null,
"published_at": "2016-04-22T05:22:15Z",
{
"items": [
{
"color1": "911919",
"color2": "202020",
"commentary": {
"description": "",
"title": ""
},
"featured": false,