Skip to content

Instantly share code, notes, and snippets.

View geoffreywiseman's full-sized avatar

Geoffrey Wiseman geoffreywiseman

View GitHub Profile
@geoffreywiseman
geoffreywiseman / example-industrious-one.sil
Last active December 27, 2016 16:27
Comparing lazy to "industrious" properties at the SIL level.
sil_stage canonical
import Builtin
import Swift
import SwiftShims
// static CommandLine._argc
sil_global [fragile] @_TZvOs11CommandLine5_argcVs5Int32 : $Int32
// globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_token4
@geoffreywiseman
geoffreywiseman / Countdown.rb
Last active November 24, 2016 16:16
Game simulation of 4-way countdown, one in Ruby, one in Swift.
class Game
def initialize()
@turn_index = 0
@players = [Player.new(1), Player.new(2)]
@players.first.set_opponent(@players.last)
@players.last.set_opponent(@players.first)
end
def take_turn
@geoffreywiseman
geoffreywiseman / Signpost.swift
Last active October 3, 2016 23:16
Signpost Helper
import Foundation
public class Signpost {
static func start( code:UInt32, arg1:UInt = 0, arg2:UInt = 0, arg3:UInt = 0, arg4:UInt = 0 ) -> Int32 {
if #available(iOS 10.0, *) {
return kdebug_signpost_start(code,arg1,arg2,arg3,arg4);
} else {
return 0;
}
}
@geoffreywiseman
geoffreywiseman / Validator.java
Created July 1, 2014 00:49
Uber-Simple Use of the RAML Parser as a Validator
package org.raml;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.List;
import org.raml.parser.rule.ValidationResult;
import org.raml.parser.visitor.RamlValidationService;
public class School {
private final String name;
private final String nickname;
public School(String name, String nickname) {
this.name = name;
this.nickname = nickname;
}
@Override
@geoffreywiseman
geoffreywiseman / reset-twitter-spaces.rb
Created May 20, 2011 13:57
Ruby code using rb-appscript to reset Twitter's preferences in Spaces since Twitter doesn't work very well with OSX Spaces.
require "rubygems"
require "appscript"
include Appscript
class SystemEvents
def initialize( &block )
@app = app( "System Events" )
launch
instance_eval &block
@geoffreywiseman
geoffreywiseman / prune-dsl.rb
Created December 17, 2010 19:57
An example of what a prune DSL could look like.
preprocess do |file|
file.modified_time = File.mtime( file.name )
modified_date = Date.parse modified_time.to_s
file.days_since_modified = Date.today - modified_date
file.months_since_modified = ( Date.today.year - modified_date.year ) * 12 + (Date.today.month - modified_date.month)
end
category "Ignoring directories" do
match { |file| File.directory?(file.name) }