Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tomconroy on github.
  • I am tomconroy (https://keybase.io/tomconroy) on keybase.
  • I have a public key whose fingerprint is 37C0 0637 8814 278E B2A6 62DF 029F E0AE AED1 EA5E

To claim this, I am signing this object:

func encode<T>(var value: T) -> NSData {
return withUnsafePointer(&value) { p in
NSData(bytes: p, length: sizeofValue(value))
}
}
func decode<T>(data: NSData) -> T {
let pointer = UnsafeMutablePointer<T>.alloc(sizeof(T))
data.getBytes(pointer, length: sizeof(T))
return pointer.move()
@tomconroy
tomconroy / headers.scss
Created September 23, 2014 16:40
Generate CSS Header sizes
$max: 32;
$min: 12;
@for $i from 1 through 6 {
h#{$i} {
font-size: #{$max - ($max - $min) * (($i - 1) / 5)}px;
}
}
@tomconroy
tomconroy / Event.swift
Last active December 22, 2016 20:57
A simple Event Emitter for swift (use EmitterKit for something more robust)
class Event <T:Any> {
var handlers = Array<(T) -> Void>()
func listen(handler: (T) -> Void) {
handlers.append(handler)
}
func emit(object: T) {
for handler in handlers {
handler(object)
# Usage:
# 1. Drop this file into lib/capistrano/submodule_strategy.rb
# 2. Add the following to your Capfile:
# require 'capistrano/git'
# require './lib/capistrano/submodule_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, SubmoduleStrategy
module SubmoduleStrategy
# do all the things a normal capistrano git session would do