Skip to content

Instantly share code, notes, and snippets.

View aclissold's full-sized avatar

Andrew Clissold aclissold

View GitHub Profile
# 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()
-=-=-=- 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:
package main
import (
"fmt"
"log"
"math/rand"
"runtime"
"strconv"
"time"
)
@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 / 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;
#!/usr/bin/env python3
import sys
keys = {
'C4': 'q', 'C#4': 'a', 'Db4': 'a', 'D4': 'z',
'G4': 'd',
'E5': 'h',
'C5': 't',
'G5': 'j',
@aclissold
aclissold / exponential.swift
Last active August 29, 2015 14:07
e^x to n terms of accuracy http://swiftstub.com/71611885/
// Computes an estimation of e^x using a Taylor series expansion with n terms.
// 1 + (x^1/1!) + (x^2/2!) + ... + (x^n/n!)
func exponential(x: Double, n: Double) -> Double {
var exponential: Double = 1
for var y: Double = 1; y <= n; y++ {
var power: Double = 1
var yFactorial: Double = 1
for var i: Double = 1; i <= y; i++ {
yFactorial *= i
@aclissold
aclissold / problem4.py
Created October 7, 2014 06:28
Gaussian Naive Bayes
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
from sklearn.naive_bayes import GaussianNB
# Problem:
# https://www.dropbox.com/s/ta4sh8cld3sh7rj/Screenshot%202014-10-07%2002.28.13.png?dl=0
#########
@aclissold
aclissold / convenience.swift
Created October 18, 2014 15:50
Convenience initializers in Swift
class Letter {
convenience init(filePath: String) {
self.init()
loadFromFile(filePath)
}
func loadFromFile(filePath: String) {
println("loading \(filePath)")
}
}
@aclissold
aclissold / Font Playground.md
Last active August 29, 2015 14:07
Font Playground

Font Playground

A tiny Playground for UIFont. Inspect title to visualize attributes.

Usage: clone this gist and rename the folder to Fonts.playground.