Skip to content

Instantly share code, notes, and snippets.

func tupleToArray<T, U>(var tuple: T, _ resultType: U.Type) -> [U] {
let count = sizeof(T) / sizeof(U)
return withUnsafePointer(&tuple) { ptr -> [U] in
let eltPtr = UnsafePointer<U>(ptr)
return Array(0..<count).map({ eltPtr[$0] })
}
}

Keybase proof

I hereby claim:

  • I am ttilley on github.
  • I am ttilley (https://keybase.io/ttilley) on keybase.
  • I have a public key whose fingerprint is 8D25 C7B4 214E EC23 EA0F 84EF D2DF 823B EB38 15AC

To claim this, I am signing this object:

@ttilley
ttilley / build-llvm-projects-mac.sh
Last active October 13, 2015 14:48
build llvm svn and friends on mac
#!/usr/bin/env bash
set -e
xcsel='xcode-select --print-path'
xcodepath="$($xcsel)"
platform='MacOSX'
export TRIPLE='x86_64-apple-darwin11'
export MACOSX_DEPLOYMENT_TARGET='10.7'
diff --git c/gc.c w/gc.c
index 861379b..2f4d596 100644
--- c/gc.c
+++ w/gc.c
@@ -86,11 +86,13 @@ void *alloca ();
#endif
#define HEAP_MIN_SLOTS 10000
#define FREE_MIN 4096
+#define HEAP_SLOTS_GROWTH_FACTOR 1.8
require 'eventmachine'
require 'digest/md5'
require 'fiber'
require 'thread'
unless defined?(ActiveSupport)
class String; def blank?; self !~ /[^[:space:]]/; end; end
class NilClass; def blank?; true; end; end
class Object; def blank?; false; end; end
@ttilley
ttilley / arris_password_of_the_day_brute_force.rb
Created September 7, 2012 07:57
attempt to brute force an arris "password of the day" algorithm seed
require 'date'
require 'time'
require 'uri'
require 'net/http'
require 'typhoeus'
class PasswordOfTheDay
TABLE1 = [
[15, 15, 24, 20, 24],
@ttilley
ttilley / Vagrantfile
Created July 9, 2012 16:26
stackato vagrant bootstrap
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
Vagrant::Config.run do |config|
config.package.name = 'vagrant-stackato.box'
config.vm.guest = :ubuntu
config.ssh.forward_agent = true
# config.vm.forward_port 80, 8080, :name => "nginx", :protocol => :tcp, :auto => true
# config.vm.forward_port 443, 8443, :name => "nginx ssl", :protocol => :tcp, :auto => true
@ttilley
ttilley / bdw-gc.rb
Created June 25, 2012 17:45
updated homebrew formula for Boehm-Demers-Weiser GC supporting building from head and passing in various options to the build
require 'formula'
class Formula
def configure_path_args(choices={})
vars = {
:prefix => self.prefix,
:'exec-prefix' => self.prefix,
:bindir => self.bin,
:sbindir => self.sbin,
:libexecdir => self.libexec,
@ttilley
ttilley / hello_world.txt
Created May 20, 2012 05:27
Peanut Butter Jelly Time brainfuck variant
#!/usr/bin/env PeanutButterJellyTime
# -----------------------------------------------------------------------------
# keyword => C equiv (description)
# -----------------------------------------------------------------------------
# peanut => ++*ptr (increase value of cell)
# PEANUT => ++ptr (move to next cell)
# butter => --*ptr (decrease value of cell)
# BUTTER => --ptr (move to previous cell)
# jelly => putchar(*ptr) (print character value of cell)
# JELLY => *ptr=getchar() (store numeric value of char input in cell)
top = this
top.logJPlayerCreate ?= true
top.logJPlayerPublishCreate ?= true
top.logAllJPlayerEvents ?= false
do ($ = jQuery) ->
if !$.subscribe
o = $({})
$.subscribe = ->