Skip to content

Instantly share code, notes, and snippets.

View thelbane's full-sized avatar

Lee Fastenau thelbane

View GitHub Profile
@thelbane
thelbane / makefile
Last active October 31, 2017 14:54
makefile for cross-development on Mac OSX targeting Apple II 6502 object binary
# The name of the destination disk image
IMAGE_TARGET = tetris.dsk
# Apple II command issued by the "run" recipe after booting the disk image.
RUN_CMD = "BRUN TETRIS"
# Paths and flags for build/processing applications
DASM = dasm
DASM_FLAGS = -v0 -f2
AC = java -jar /usr/local/bin/ac.jar
import Foundation
enum ColumnSelection<Item> where Item: Hashable {
case viewAll
case selection(item: Item)
}
extension ColumnSelection: Hashable {
@thelbane
thelbane / KVOChangeNotifier.swift
Created June 12, 2017 18:52
KVOChangeNotifier
import Foundation
class KVOChangeNotifier: NSObject {
weak var object: AnyObject?
let keyPaths: [String]
var dependentObject: AnyObject
let dependentKeyPaths: [String]
init(object: AnyObject, keyPaths: [String], dependentObject: AnyObject, dependentKeyPaths: [String]) {
self.object = object
self.keyPaths = keyPaths
@thelbane
thelbane / ObservableTests.swift
Created June 11, 2017 20:18
Tests for general KVO and non-KVO observable properties
public class ObservableTests : XCTestCase {
public func testFilters() {
var expectedValues = [0,2,4,6,8]
let expect = expectation(description: "Odd numbers filtered out")
expect.expectedFulfillmentCount = UInt(expectedValues.count)
let observable = Observable(0)
observable
@thelbane
thelbane / playground.swift
Last active October 13, 2017 17:05
Deterministic, succinct Swift/ObjC data binding without a reactive framework.
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
class Person: NSObject {
dynamic var firstName: String
dynamic var lastName: String
init(_ fn: String, _ ln: String) {
func validate(input: String) -> Bool {
let brackets: [Character:Character] = ["[":"]","(":")","{":"}"]
var stack: [Character] = []
for char in input.characters {
if let correspondingBracket = brackets[char] {
stack.append(correspondingBracket)
} else if stack.last == char {
stack.popLast()
} else if brackets.values.contains(char) {

Keybase proof

I hereby claim:

  • I am thelbane on github.
  • I am thelbane (https://keybase.io/thelbane) on keybase.
  • I have a public key whose fingerprint is E1FE 13BD BE9A E0C1 EB39 9429 05B1 B056 3DF7 801A

To claim this, I am signing this object:

; TO PLAY A TONE FROM APPLESOFT...
; POKE 769,DURATION : POKE 771,FREQUENCY : CALL 768
0300- A0 64 LDY #$FF ; LOAD DURATION
0302- A9 01 LDA #$FF ; LOAD FREQUENCY
0304- 85 FA STA $FA ; VALUE AT $FA WILL SLIDE DOWN, CREATING THE VIOLIN EFFECT
0306- AE 03 03 LDX $0303 ; INITIALIZE TONE COUNTER WITH FREQUENCY
0309- E4 FA CPX $FA ; COMPARE WITH SLIDING VALUE
030B- D0 03 BNE $0310 ; SKIP SPEAKER CLICK IF NOT EQUAL
030D- AD 30 C0 LDA $C030 ; CLICK SPEAKER
@thelbane
thelbane / pragma marks.m
Created May 30, 2012 21:41
Objective C sections
#pragma mark - Static
#pragma mark - Init/Dealloc
#pragma mark - Properties
#pragma mark - Public
#pragma mark - Private
@thelbane
thelbane / snakebot.js
Last active May 13, 2016 11:51
Snake game solver/bot
// A bot for this silly demo: http://www.webdeveloperjuice.com/demos/jquery/snake_jquery.html
// Compile with http://closure-compiler.appspot.com/home set to Advanced Optimization
//
// Automatically runs when compiled statement is pasted into console. Type "win()" to run it again.
(window['win'] = function () {
// direction mappings
var i, dirs = ['up', 'right', 'down', 'left'],
diffs = [[-1, 0], [0, 1], [1, 0], [0, -1]]; // don't ask me why the coords are ordered [y,x]
window['t'] = 1; // next Turn direction if we hit a wall (opposite of last turn direction)
window['m'] = 0; // My internally tracked direction