Skip to content

Instantly share code, notes, and snippets.

@mxcl
mxcl / tdb
Created June 22, 2010 10:25
Makes ADB logcat more readible (for me)
#!/usr/bin/ruby
RED = "\033[0;31m"
RESET = "\033[0m"
YELLOW = "\033[0;33m"
BLUE = "\033[0;35m"
GREY = "\033[0;34m"
trap("INT") { puts; exit! 127 }
@mxcl
mxcl / colbalt.xml
Created June 28, 2010 12:29
A nice color scheme for Java in IntelliJ.
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Colbalt" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CARET_COLOR" value="ffffff" />
<option name="CARET_ROW_COLOR" value="133d61" />
<option name="FOLDING_TREE_COLOR" value="466a8a" />
<option name="INDENT_GUIDE" value="123b5f" />
@mxcl
mxcl / NSURLRequest+mxcl.m
Created October 22, 2010 15:35
NSURLRequest+mxcl.m
#import <Foundation/Foundation.h>
@interface NSURLRequest (mxcl)
+ (id)requestWithURL:(NSURL *)url;
+ (id)requestWithURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutInterval;
+ (id)requestWithURLString:(NSString *)url; // for convenience
@end
@mxcl
mxcl / fizzbuzz.rb
Created November 27, 2010 11:53
Improve this Fizzbuzz!
#!/usr/bin/ruby
# The Ruby FizzBuzz with the best concision versus elegance compromise.
# Fork if you have better ideas.
1.upto 100 do |n|
puts [[:fizz][n%3], [:buzz][n%5]].join[/.+/m] || n
end
@mxcl
mxcl / gist:848410
Created March 1, 2011 01:14
C-string version of John Gruber’s URL Regex
#define TDURLRegularExpression "(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]))"
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@mxcl
mxcl / brew-foo.rb
Created August 4, 2012 21:24
Homebrew environment in new Ruby script
$:.unshift(`brew --prefix`.chomp+'/Library/Homebrew')
require 'global'
Formula.each do |f|
p f
end
@mxcl
mxcl / asdf.rb
Created September 3, 2012 02:53
#Add before any other code in `bin/brew`
module Kernel
alias_method :old_backtick, :`
alias_method :old_system, :system
def system *args
t = Time.now
old_system *args
puts "#{Time.now - t}: #{args*' '}"
end
#import "MBSQLite.h"
#import <sqlite3.h>
int sqlite3_exec_callback(void *userdata, int argc, char **argv, char **column) {
id aa = (__bridge NSMutableArray *)userdata;
while (argc--)
[aa insertObject:@(argv[argc]) atIndex:0];
return SQLITE_OK;
}
@mxcl
mxcl / hlink.c
Created November 23, 2012 15:11