Skip to content

Instantly share code, notes, and snippets.

View monkeydom's full-sized avatar

Dominik Wagner monkeydom

View GitHub Profile
@monkeydom
monkeydom / gist:881313
Created March 22, 2011 14:43
Simple Binary / List to lowercase hex functions using binary comprehensions
to_hex(List) when is_list(List) ->
to_hex(iolist_to_binary(List));
to_hex(Binary) when is_binary(Binary) ->
<< <<(to_digit(Nibble1)):8,(to_digit(Nibble2)):8>> || <<Nibble1:4,Nibble2:4>> <= Binary >>.
to_digit(N) when N < 10 -> $0 + N;
to_digit(N) -> $a + N-10.
@monkeydom
monkeydom / applestorede.sh
Created March 24, 2011 21:02
Apple store is down script
#!/bin/bash
WaitForDown=true
while true; do
StoreUp=`curl -s http://store.apple.com/de | grep "Mac kaufen" | wc -l`
if [ $StoreUp -eq 0 ]; then
if $WaitForDown; then
@monkeydom
monkeydom / CompareMacro.h
Created August 24, 2011 10:33
Objective-C Compare Macro for your convenience
#if !defined(COMPARE)
#define COMPARE(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? NSOrderedAscending : (__a > __b ? NSOrderedDescending : NSOrderedSame); })
#endif
@monkeydom
monkeydom / UUIDString_Category_ARC.m
Created August 31, 2011 16:45
ARC UUIDString generation method.
+ (NSString *)UUIDString {
CFUUIDRef myUUID = CFUUIDCreate(NULL);
NSString *myUUIDString = CFBridgingRelease(CFUUIDCreateString(NULL, myUUID));
CFRelease(myUUID);
return myUUIDString;
}
@monkeydom
monkeydom / blinkenproxy.rb
Created December 26, 2011 23:03
Ruby script to read blinkenlights protocol streams from proxies
#!/usr/bin/env ruby
# == Synopsis
# blinkenpackets listens on a port for blinkenpackets and prints out verbose descriptions for them
# == Examples
# blinkenpackets.rb -p 2323
#
# Other examples:
# blinkenpackets.rb proxy.blinkenlights.net:4244
# blinkenpackets.rb proxy.blinkenlights.net:4245
@monkeydom
monkeydom / EraseAndCreateBuildDisk.sh
Created February 8, 2012 12:19
Script to create build ramdisk on mac os x
#!/bin/sh
diskutil erasevolume HFS+ "BuildDisk" `hdiutil attach -nomount ram://9323440`
@monkeydom
monkeydom / WEBrickNow.rb
Last active October 9, 2015 02:27
Start Webrick in current directory, port 9090 - added option for bonjour annoucement so it works via back to my mac!
#!/usr/bin/env ruby
require 'webrick'
require 'optparse'
include WEBrick
options = {:Port => 9090,
:DocumentRoot => './',
:Bonjour => false}
optparser=OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
@monkeydom
monkeydom / EraseAndCreateBuildDisk.sh
Created March 5, 2013 11:32
A ram disk to build in to reduce tear on the SSDS
#!/bin/sh
rmdir /Volumes/BuildDisk
diskutil erasevolume HFS+ "BuildDisk" `hdiutil attach -nomount ram://4661720`
while true; do curl -sS http://store.apple.com/de/iphone | grep "back soon" || (terminal-notifier -message "buy it" -title "Good news everyone" -open http://store.apple.com/de/iphone && say buy now && sleep 3600); sleep 10; done
@monkeydom
monkeydom / MIN_MAX_NEW.m
Last active December 24, 2015 17:19
MIN and MAX definitions starting with iOS 7
#if __clang__
#define __NSX_PASTE__(A,B) A##B
#if !defined(MIN)
#define __NSMIN_IMPL__(A,B,L) ({ __typeof__(A) __NSX_PASTE__(__a,L) = (A); __typeof__(B) __NSX_PASTE__(__b,L) = (B); (__NSX_PASTE__(__a,L) < __NSX_PASTE__(__b,L)) ? __NSX_PASTE__(__a,L) : __NSX_PASTE__(__b,L); })
#define MIN(A,B) __NSMIN_IMPL__(A,B,__COUNTER__)
#endif
#if !defined(MAX)