This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Illustrates that not all causes of retain cycles are detected by clang. Compile with: | |
// clang -fobjc-arc -Wall -framework Foundation test-cycle-warnings.m && ./a.out | |
#import <Foundation/Foundation.h> | |
@interface Foo : NSObject | |
typedef void (^Block)(); | |
@property (readwrite, copy) Block asd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run with: | |
// clang -fobjc-arc -Wall -framework Foundation blockself.m && ./a.out | |
// Further reading: | |
// http://www.mikeash.com/pyblog/friday-qa-2009-08-14-practical-blocks.html | |
// http://clang.llvm.org/docs/AutomaticReferenceCounting.html#misc.blocks | |
// http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html | |
#import <Foundation/Foundation.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OCUnit/SenTestCase's vanilla testInvocations method does not produce a unique list of methods | |
// when you inherit from a common test base class. Currently it will call the same test methods | |
// multiple times, depending on the number of base classes. | |
// | |
// To prevent these duplicate test method calls, override testInvocations like this. | |
// | |
// Written in 2012 by Torsten Becker <torsten.becker@gmail.com> | |
@interface BetterTestCase : SenTestCase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: git.io GITHUB-URL | |
# Based on https://github.com/blog/985-git-io-github-url-shortener | |
__make_git_io() { | |
curl -i http://git.io -F "url=$1" | |
} | |
alias git.io=__make_git_io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile as: clang -O4 -framework Foundation property-access.m && ./a.out | |
#import <Foundation/Foundation.h> | |
// Performance timer, credit: Lars Schneider @kit3bus | |
#import <mach/mach_time.h> | |
#define MAKE_NSSTRING(str) (NSString *)CFSTR(#str) | |
#define START(name) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Self-contained ruby script & database to remember uncommon shell commands | |
# and search for them using the command line. | |
# | |
# Originally written by Torsten Becker <torsten.becker@gmail.com> in 2012. | |
# | |
# Usage: cheat.rb [SEARCHTERM] | |
# If SEARCHTERM is given, cheat.rb lists only cheats that contain this term. | |
# Otherwise lists all cheats. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]--> | |
<!--[if IE 7 ]> <html class="ie7"> <![endif]--> | |
<!--[if IE 8 ]> <html class="ie8"> <![endif]--> | |
<!--[if IE 9 ]> <html class="ie9"> <![endif]--> | |
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]--> | |
<head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prints a list of all committers in a subversion repository, | |
# sorted by number of commits. | |
# Written by Torsten Becker <torsten.becker@gmail.com> in 2011 | |
if [[ ! $1 ]]; then | |
echo "Usage: $0 SVN-REPO-URL" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def z_order(x, y): | |
"""Creates a z-order value from the 15 least significant bits of | |
the `int`s `x` and `y`. | |
http://en.wikipedia.org/wiki/Z-order_curve | |
""" | |
z = 0 | |
for bit_pos in range(15): | |
z |= (x & (1 << bit_pos)) << bit_pos | |
z |= (y & (1 << bit_pos)) << (bit_pos + 1) |