Skip to content

Instantly share code, notes, and snippets.

View zacclark's full-sized avatar

Zac Clark zacclark

View GitHub Profile
@zacclark
zacclark / 01_completion.swift
Last active January 15, 2017 05:32
Lightweight forced completion block calling
struct CompletionBlock {
private let storedBlock: () -> Swift.Void
init(_ c: @escaping () -> Swift.Void) {
storedBlock = c
}
func call() -> Called {
storedBlock()
return Called()
@zacclark
zacclark / 01_pop.swift
Last active January 9, 2017 23:42
Simple pop operation to simplify a common setup
func pop<T>(
_ maybeValue: inout T?,
_ block: ((T) -> Void)
) {
guard let value = maybeValue else { return }
maybeValue = nil
block(value)
}
@zacclark
zacclark / Want.md
Last active December 30, 2015 21:09
Christmas list 2013
@zacclark
zacclark / rules.md
Created September 2, 2012 02:16
Turn of the Card

Turn of the Card

This is a distilled form of the full rules for easier consumption on a mobile device.

Trauma

1. Bloodied (B).

This is what your character looks like after a lop-sided street fight. The damage isn't lethal and it wonít affect your characterís performance, but it lets him know that heís taken a wrong turn somewhere.

The City

Home. The steaming of the tar roofs in the summer heat is the earliest smell you remember. Some say that this was the first city, built by the Angels thousands of years ago, before they left and the world began to rot. You're currently living near the dockyards, east of the scar. The city is home to millions, and you make up a single spec of life in that petri dish. The eastern docks are one of the seedier pieces of the city--home to crooked merchants, thieves, drug runners, and the disgruntled poor.

The heart of the city lies a few miles inland, across thousands of shacks, warehouses, and stone-walled taverns and shops. The ground slopes increasingly upwards as the city climbs even higher, one and two story buildings giving way to fading towers and eventually to The Ring. Surrounding the houses of nobility is a set of 6 towers, wrought of white marble and bound in rusting steel. Since time immemorial these towers have stood, and the rich of the city built their homes among them.

Table of Con

@zacclark
zacclark / triangle.rb
Created December 21, 2011 05:03
Changing a friend's triangle implementation
# your way fixed
def triangle(a,b,c)
equal = false
[[a,b], [a,c], [b,c]].each do |first, second|
if first == second
equal ? (return :equilateral) : (equal = true)
end
end
select
people.id as person,
statuses.status as original,
actions.status_code as copy,
statuses.created_at,
actions.occurred_at
from
people
JOIN attendances ON attendances.person_id = people.id
JOIN statuses ON statuses.id = attendances.current_status_id
@zacclark
zacclark / migrate.rb
Created May 10, 2011 22:38
VHGDB - Migrating statuses to actions
class MoveStatusDataToStatusChangeActions < ActiveRecord::Migration
def self.up
execute <<-EOQ
INSERT INTO actions(status_code, attendance_id, type, occurred_at, created_at, updated_at, archived_title, archived_company_id)
SELECT
statuses.status, statuses.attendance_id, 'StatusChangeAction', statuses.created_at, statuses.created_at, statuses.updated_at, titles.title, companies.id
FROM statuses
JOIN attendances ON attendances.id = statuses.attendance_id
JOIN people ON people.id = attendances.person_id
JOIN employments ON employments.id = people.current_employment_id
f = File.open("./theme")
waiting = true
f.each_line do |line|
if waiting
#puts line
waiting = false if line.to_s == "[default]\r\n"
else
arr = line.split(" ")
#puts arr.inspect
puts "<key>#{arr[0]}</key>"
class FlatPerson
def initialize(person)
raise TypeMismatch unless person.class == Person
emp = person.employments_to_edit[0] || Employment.new
emp.company ||= Company.new
comp = emp.company
comp.cisco_dataset ||= CiscoDataset.new
cd = comp.cisco_dataset