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
// Author: Marcus Zarra
// Source: http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/
#ifdef DEBUG
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
#define DLog(...) do { } while (0)
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
@mkhl
mkhl / maude
Created August 6, 2010 22:32
Wrapper script to run Maude from its directory tree.
#!/usr/bin/env bash
function search-prelude {
local prelude="prelude.maude"
for dir ; do
for file in "${dir}/${prelude}" "${dir}/maude/${prelude}" "${dir}/lib/maude/${prelude}" ; do
if [[ -f "${file}" ]]; then
echo -n "$(dirname "${file}")"
return 0
fi
@mkhl
mkhl / any2mp3
Created February 22, 2011 17:43
Convert media files to MP3 using ffmpeg and lame. With automatic tagging.
#!/usr/bin/env ruby
require 'tempfile'
opts = Hash[*%w[--tt title
--ta artist
--tl album
--ty year
--tc comment
@mkhl
mkhl / usage
Created February 22, 2011 22:52
Simple usage information for shell scripts
#!/bin/sh
# Usage documentation and program description go here,
# nicely formatted and laid out to fit 78 columns.
# NOTE: The blank line above is the end of the file comment header.
# Check command-line options
if true; then
# Display the file comment header.
sed -n '2,/^$/s/^# //p' "$0"
@mkhl
mkhl / ansicolor
Created February 23, 2011 21:35
Generate ANSI escape sequences.
#!/usr/bin/env ruby -w
# Usage: ansicolor attr... [-- string...]
# Generate ANSI escape sequences.
# With string arguments, print them on stdout,
# followed by a `clear' escape sequence.
begin
require 'term/ansicolor'
rescue LoadError
require 'rubygems'
@mkhl
mkhl / unicaps.py
Created June 3, 2011 22:25
Inspired by something Peter Hosey did. Converts text to small caps unicode glyphs.
#!/usr/bin/env python
import fileinput, unicodedata
def convert_char(char):
try:
name = unicodedata.name(char)
name = name.replace('LATIN SMALL LETTER', 'LATIN LETTER SMALL CAPITAL')
return unicodedata.lookup(name)
except KeyError:
walk "$@" |
sor 'file $file | grep -q Mach-O' |
sor 'otool -L $file | grep -q Cellar/readline/6.1'
@mkhl
mkhl / cdup.sh
Created December 13, 2011 22:19 — forked from ieure/cdup.sh
function cdup {
local dir=$PWD
local target=${*:-.git}
until [ -e "$dir/$target" -o "$dir" = "/" ]; do
dir="$(dirname "$dir")"
done
test -e "$dir/$target" && cd "$dir"
}
function catup {
@mkhl
mkhl / gist:1682605
Created January 26, 2012 12:42
Unix Exit Status Code Reference
0 # successful termination 64 # base value for error messages
64 # command line usage error
65 # data format error
66 # cannot open input
67 # addressee unknown
68 # host name unknown
69 # service unavailable
70 # internal software error
71 # system error (e.g., can't fork)
72 # critical OS file missing
Source: <http://enlivend.livejournal.com/36650.html>