Skip to content

Instantly share code, notes, and snippets.

@mchambers
mchambers / reflect.swift
Last active March 5, 2021 09:20
Basic Reflection in Swift.
// Let's define a basic Swift class.
class Fruit {
var type=1
var name="Apple"
var delicious=true
}
// We can get at some info about an instance of an object using reflect(), which returns a Mirror.
reflect(Fruit()).count
reflect(Fruit())[1].0
@neonichu
neonichu / fauxpas2puncover.rb
Last active August 29, 2015 14:06
Convert JSON generated by Faux Pas to a format understood by PuncoverPlugin.
#!/usr/bin/env ruby
require 'rubygems'
require 'date'
require 'json'
input = JSON.parse(ARGF.read)
output = { 'meta' => { 'timestamp' => DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%6N') } }
symbols = {}
protocol Calendar {
typealias Unit: BidirectionalIndexType
typealias Era: Unit
typealias Year: Unit
typealias Month: Unit
typealias Week: Unit
typealias Day: Unit
typealias Weekday: Unit
typealias Hour: Unit