Skip to content

Instantly share code, notes, and snippets.

View numist's full-sized avatar

Scott Perry numist

View GitHub Profile
@numist
numist / gist:9218846
Created February 25, 2014 22:03 — forked from kyleve/gist:8213806
/**
Provides the ability to verify key paths at compile time.
If "keyPath" does not exist, a compile-time error will be generated.
Example:
// Verifies "isFinished" exists on "operation".
NSString *key = SQKeyPath(operation, isFinished);
// Verifies "isFinished" exists on self.
@numist
numist / swift-repl.fish
Created June 9, 2014 15:55
A function for your fish configuration to run the Swift REPL without making Xcode6-beta your default toolchain.
function swift
set developer_dir $DEVELOPER_DIR
set -x DEVELOPER_DIR /Applications/Xcode6-Beta.app/Contents/Developer/
xcrun swift
if echo $developer_dir | grep "/"
set -x DEVELOPER_DIR $developer_dir
else
set -e DEVELOPER_DIR
end
end
@numist
numist / Set.swift
Last active August 29, 2015 14:02
A quick implementation of Sets along with some operators for performing some set arithmetic.
import Foundation
struct SetGenerator<T:Hashable> : Generator {
var backingGenerator: DictionaryGenerator<T, Void>
init(backingGenerator: DictionaryGenerator<T, Void>) {
self.backingGenerator = backingGenerator;
}
@numist
numist / there_i_fixed_it.rb
Created November 13, 2014 17:48
Get the system time zone in Olson format using Ruby
def get_local_timezone_str
# Yes, this is actually a shell script…
olsontz = `if [ -f /etc/timezone ]; then
cat /etc/timezone
elif [ -h /etc/localtime ]; then
readlink /etc/localtime | sed "s/\\/usr\\/share\\/zoneinfo\\///"
else
checksum=\`md5sum /etc/localtime | cut -d' ' -f1\`
find /usr/share/zoneinfo/ -type f -exec md5sum {} \\; | grep "^$checksum" | sed "s/.*\\/usr\\/share\\/zoneinfo\\///" | head -n 1
fi`.chomp
@numist
numist / scheduler.c
Last active August 29, 2015 14:17
Simple work scheduler and test harness for microcontroller projects in C.
#include "scheduler.h"
#include <stddef.h>
#include <stdbool.h>
//
// Compatibility macros
//
// Missing from Arduino toolchain
#ifndef UINT16_MAX
@numist
numist / RSSKit.swift
Created July 31, 2015 06:41
Feed and Folder protocols with a couple of concrete implementations in the spirit of http://inessential.com/2015/07/19/secret_projects_diary_2_swift_2_0_prot
func ==<T:Feed>(lhs: T, rhs: T) -> Bool {
return lhs.link == rhs.link
}
protocol Feed : Equatable {
var link : String {get}
}
protocol Folder {
typealias FeedType: Feed
@numist
numist / infScr-1.0.0.js
Created November 29, 2011 07:20
generic lazyloader
/*
* Copyright © 2011 by Alexander Micek and Scott Perry
* Released under the MIT License; its terms are at the end of this file.
*
* This file depends on:
* • jQuery (tested against v1.4.2)
* http://jquery.com/
* • jQuery doTimeout (tested against v1.0)
* by "Cowboy" Ben Alman
* http://benalman.com/projects/jquery-dotimeout-plugin/
@numist
numist / jk-1.0.1.js
Created December 5, 2011 13:18
generic keyboard navigation
/*
* Copyright © 2011 by Scott Perry
* Released under the MIT License; its terms are at the end of this file.
*
* This file depends on:
* • jQuery (tested against v1.4.2)
* http://jquery.com/
*
* To use this file, ensure that:
* • jkInterestingElements() returns all available scroll targets
@numist
numist / jsLoad-1.0.0.js
Created December 5, 2011 19:17
javascript resource loader
/*
* Copyright © 2011 by Scott Perry
* Released under the MIT License; its terms are at the end of this file.
*
* This file depends on:
* • jQuery (tested against v1.4.2)
* http://jquery.com/
*
* Pages that include this file should load all their javascript files (other
//
// Generated on Sun Dec 02 00:41:17 -0800 2012.
// Contents copyright © 2012 Scott Perry (http://numist.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF