Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / gist:360525
Created April 8, 2010 20:52
Make your Xcode templates less rubbish
def inreplace path, before=nil, after=nil
[*path].each do |path|
f = File.open path, 'r'
s = f.read.gsub before, after
f.reopen(path, 'w').write s
f.close
end
end
require 'pathname'
@mxcl
mxcl / install_homebrew.markdown
Created March 6, 2010 15:14
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
@mxcl
mxcl / HeinleinQuote.md
Created February 24, 2010 17:34
Robert A. Heinlein Quote

“A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”

I think it's from “The moon is a harsh mistress”