Skip to content

Instantly share code, notes, and snippets.

View random-circle.js
void setup() {
size(200, 200);
for (var i = 0; i < 10000; i++) {
var x = (Math.random() - 0.5) * 150;
var y = (Math.random() - 0.5) * 150;
if ((Math.sqrt((x * x) + (y * y))) > 75) continue;
point(x + 100, y + 100);
}
@dirk
dirk / UIColor-hex.swift
Created Oct 22, 2015 — forked from blixt/HexToUIColor.swift
Swift UIColor extension that parses a hexadecimal color string
View UIColor-hex.swift
extension UIColor {
enum Error: ErrorType {
case Parsing(String)
}
convenience init(hex input: String) throws {
let hex = input.stringByTrimmingCharactersInSet(NSCharacterSet.alphanumericCharacterSet().invertedSet)
var int = UInt32()
guard NSScanner(string: hex).scanHexInt(&int) else {
throw Error.Parsing("Unable to scan hexadecimal integer")
View cast.swift
import Foundation
// Must use <T> instead of <T: AnyObject> to be able to
// convert to structs (value types) like String.
func cast<T>(object: AnyObject) -> T? {
return object as? T
}
let string: String? = cast("i'm a string!")
View benchmark.rb
require 'rubygems'
require 'benchmark/ips'
require 'ruby-prof'
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
require 'jbuilder'
require 'jbuilder/jbuilder_template'
module Rails
def self.cache
View README.md

...

Read this first: Server setup and provisioning sucks donkey dick. Ansible sucks even more donkey dick. However, it sucks less donkey dick than any other tools out there for this god-forsaken fuck-fest they call "dev-ops". So let's use Ansible.

...

View weird.txt
fish:~ $ gobjdump -T /usr/lib/system/libsystem_c.dylib | grep rb
00000000000704b7 l 0e SECT 01 0000 [.text] _rb_tree_removal_rebalance
0000000000070602 l 0e SECT 01 0000 [.text] _rb_tree_reparent_nodes
00000000000907e8 l 0e SECT 0f 0000 [.bss] _sbrk_curbrk
00000000000910f0 l 0e SECT 0f 0000 [.bss] _nextcomp.lmsgverb
00000000000704a4 g 0f SECT 01 0000 [.text] _rb_tree_count
000000000006febe g 0f SECT 01 0000 [.text] _rb_tree_find_node
000000000006ff1a g 0f SECT 01 0000 [.text] _rb_tree_find_node_geq
000000000006ff85 g 0f SECT 01 0000 [.text] _rb_tree_find_node_leq
000000000006fe95 g 0f SECT 01 0000 [.text] _rb_tree_init
View gist:9401880
vhost.conf:
<VirtualHost *:80>
<Directory "/sites.../app">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/sites.../app/public"
ServerName app.dev
</VirtualHost>
View keybase.md

Keybase proof

I hereby claim:

  • I am dirk on github.
  • I am dirk (https://keybase.io/dirk) on keybase.
  • I have the public key with fingerprint 30B2 92C2 31E4 F85D 4B82  97CE DC57 4905 5034 B546

To claim this, I am signing this object:

View all_you_need_is_this.sh
# Pipe command to this to open in the browser (eg. bundle help install | pb)
alias pb="col -b | open -a /Applications/Chromium.app -f"
View gist:8669034
$('p').each(function() {
if($(this).html() == '' && $(this).text() == '') {
$(this).remove()
}
});
You can’t perform that action at this time.