Skip to content

Instantly share code, notes, and snippets.

View aclissold's full-sized avatar

Andrew Clissold aclissold

View GitHub Profile
@aclissold
aclissold / SlingScene.m
Created May 4, 2014 04:28
Simple SpriteKit Slingshot
//
// SlingScene.m
//
// Demonstrates a simple slingshot mechanism.
//
// Created by Andrew Clissold on 5/3/14.
// Copyright (c) 2014 Andrew Clissold. All rights reserved.
//
/* Contents of SlingScene.h:
@aclissold
aclissold / NSUserDefaults+UIColor.swift
Created June 1, 2015 14:52
Swift NSUserDefaults UIColor extension
extension NSUserDefaults {
func colorForKey(key: String) -> UIColor? {
var color: UIColor?
if let colorData = dataForKey(key) {
color = NSKeyedUnarchiver.unarchiveObjectWithData(colorData) as? UIColor
}
return color
}
package main
import (
"fmt"
"log"
"math/rand"
"runtime"
"strconv"
"time"
)
-=-=-=- Andrew and Skye's Awesome Adventures: -=-=-=-
-=-=-=- Question 2: Counterfeit Coin Correctness -=-=-=-
Loop invariant:
At the beginning of each recursion, the real doubloon is either in pile
A, B, or C.
Initialization:
# reversebinary.py
def main():
'''Reverse numbers in binary.
For instance, the binary representation of 13 is 1101, and reversing it
gives 1011, which corresponds to the number 11.
'''
decimal_in = read_input()
@aclissold
aclissold / vimium.css
Last active October 29, 2015 21:39
Custom Vimium hint marker CSS
div > .vimiumHintMarker {
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#eee));
border: 1px solid #ddd;
text-shadow: none !important;
box-shadow: none;
}
div > .vimiumHintMarker span {
color: #a00;
font-weight: bold;
@aclissold
aclissold / move.sh
Created September 21, 2015 23:01
Rename <num>.c <num>/main.c
#!/bin/bash
for f in $(ls *.c)
do
echo $f
dir=$(echo $f | sed -e 's/.c//g')
mv $f $dir/main.c
done
@aclissold
aclissold / main.m
Created June 17, 2015 19:53
Objective-C from the command line
// cc -fobjc-arc -framework Foundation main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"hello, world");
}
return 0;
}
@aclissold
aclissold / get.swift
Created May 31, 2015 19:21
Swift GET request using spam and Alamofire
import Foundation
import Alamofire // Alamofire/Alamofire
import Blocker // aclissold/Blocker
Alamofire.request(.GET, "http://httpbin.org/get").responseJSON {
(_, _, JSON, _) in
if let JSON = JSON as? [String: AnyObject] {
println(JSON)
}
@aclissold
aclissold / go.zsh
Created February 19, 2015 15:10
Fork of the deprecated Go Zsh plugin for my dotfiles
# Copyright (c) 2012 The Go Authors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer