Skip to content

Instantly share code, notes, and snippets.

View aclissold's full-sized avatar

Andrew Clissold aclissold

View GitHub Profile
#!/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.

@aclissold
aclissold / catch.py
Created November 28, 2014 22:05
Pokéball success rate
#!/usr/bin/env python3
from math import sqrt
def main():
'''Display the probability of successfully capturing a Pokémon.'''
# Read in the formulae parameters.
max_hp = int(input('Max HP: '))
hp = int(input('Remaining HP: '))
let fruits = ["apple", "bananananana"]
/*
var s: String
if fruits.count == 1 {
s = ""
} else {
s = "s"
}
@aclissold
aclissold / after.swift
Created December 7, 2014 02:29
For github.com/Keithbsmiley/swift.vim/pull/30
// MARK: NHBalancedFlowLayoutDelegate
func collectionView(collectionView: UICollectionView!,
layout collectionViewLayout: NHBalancedFlowLayout!,
preferredSizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize {
if UIScreen.mainScreen().scale == 1.0 {
var size = photos[indexPath.item].size
size.width /= 2
size.height /= 2
return size
diff --git a/The Oakland Post/PostTableViewController.swift b/The Oakland Post/PostTableViewController.swift
index a2666ed..7f5c336 100644
--- a/The Oakland Post/PostTableViewController.swift
+++ b/The Oakland Post/PostTableViewController.swift
@@ -17,7 +17,7 @@ class PostTableViewController: BugFixTableViewController, MWFeedParserDelegate,
}
var baseURL: String!
- var feedParser: FeedParser!
+ var feedParser: MWFeedParser!
@aclissold
aclissold / ascii.txt
Created February 17, 2015 02:10
All visible ASCII characters
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~