Skip to content

Instantly share code, notes, and snippets.

View mkhl's full-sized avatar
🖤
…at any cost

Martin Kühl mkhl

🖤
…at any cost
View GitHub Profile
#!/usr/bin/env ruby -wKU -rubygems
# http://www.stompy.org/2008/08/14/xcode-and-git-another-build-script/
# I saw the script from the above URL and thought it was unnecessarily complicated.
# So I uncomplicated it.
require 'osx/plist'
File.open(File.join(ENV['BUILT_PRODUCTS_DIR'], ENV['INFOPLIST_PATH']), 'r+') do |io|
plist, format = OSX::PropertyList.load(io, true)
@mkhl
mkhl / Ellipses.m
Created July 29, 2009 23:09
Replace triple dots with proper ellipses
// Replace triple dots with proper ellipses.
// Source: http://www.mikeabdullah.net/ellipses_and_sheepkit.html
- (BOOL)textView:(EweEyeTextView *)textView
shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)text
{
BOOL result = YES;
if ([text hasSuffix:@"."]) // Accounts for somehow entering ".."
{
@mkhl
mkhl / Makefile
Created July 31, 2009 21:44
Small and generic Makefile skeleton
PROJECT=foo
SOURCES=bar.c baz.c
LIBRARY=nope
INCPATHS=../some_other_project/
LIBPATHS=../yet_another_project/
LDFLAGS=-ldosomething
CFLAGS=-c -Wall
CC=gcc
# ------------ MAGIC BEGINS HERE -------------
@mkhl
mkhl / MyTestCase.m
Created August 1, 2009 16:18
Cocoa UI Unit Testing
// Cocoa UI Unit Testing
// Source: http://eschatologist.net/blog/?p=205
@interface MyTestCase : SenTestCase
@end
@implementation MyTestCase
/*! Tells whether the control sends the action to the target. */
- (BOOL)checkControl:(NSControl *)control
@mkhl
mkhl / chroma-hash.user.js
Created August 22, 2009 14:07
Userscript for Chroma-Hash password visualization.
// ==UserScript==
// @name Chroma-Hash password visualization
// @namespace http://purl.org/net/mkhl
// @description Add Chroma-Hash visualization to all password field inputs. Compatible with Greasemonkey and GreaseKit.
// @include *
// ==/UserScript==
// Many thanks to Henrik Nyh and Mattt Thompson for doing all the hard work!
(function() {
@mkhl
mkhl / snippet.sh
Created August 23, 2009 21:57
Git bundle "replacement"
#!/bin/bash
require_cmd gitx
gitx
# Input: None
# Output: Show as Tool Tip
# Key Equivalent: ⌃⇧G
@mkhl
mkhl / goog-xcode.yaml
Created January 18, 2010 13:16
Xcode defaults to comply with the Google ObjC style guide, in YAML
# Xcode defaults to comply with the Google ObjC style guide
com.apple.Xcode:
IndentWidth: 2
TabWidth: 2
PBXUsesTabs: NO
XCCodeSenseFormattingOptions:
PreMethodTypeSpacing: ' '
PreMethodDeclSpacing: ''
PreColonSpacing: ''
NSLog(@"Something happened in %@ at line %d", NSStringFromSelector(_cmd), __LINE__);
// Even more logging: http://developer.apple.com/mac/library/qa/qa2009/qa1669.html
# Print messages when a method is replaced.
# Source: http://blog.clickablebliss.com/2010/01/19/finding-colliding-category-methods/
OBJC_PRINT_REPLACED_METHODS=YES
@mkhl
mkhl / backup
Created March 4, 2010 08:48
Simple backup to an external volume with `bup`
#!/bin/bash
set -e
VOLUME=Tigh
function die {
echo "`basename -- "$0"`:" "$@" 1>&2
exit 1
}