Skip to content

Instantly share code, notes, and snippets.

View ColinEberhardt's full-sized avatar

Colin Eberhardt ColinEberhardt

View GitHub Profile
def countChange(money: Int, coins: List[Int]): Int =
if (coins.isEmpty || money < 0)
0
else if (money == 0)
1
else
countChange(money - coins.head, coins) +
countChange(money, coins.tail)
javascript:var ngStats=function(){var e,t,n,i=0,a=1/0,l=0,o=0,d=1/0,s=0,r=0,c=document.createElement("div");c.id="stats",c.addEventListener("mousedown",function(e){e.preventDefault(),v(++r%252)},!1),c.style.cssText="width:80px;opacity:0.9;cursor:pointer";var p=document.createElement("div");p.id="fps",p.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:%23002",c.appendChild(p);var h=document.createElement("div");h.id="fpsText",h.style.cssText="color:%230ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px",h.innerHTML="W",p.appendChild(h);var m=document.createElement("div");for(m.id="fpsGraph",m.style.cssText="position:relative;width:74px;height:30px;background-color:%230ff",p.appendChild(m);m.children.length<74;){var f=document.createElement("span");f.style.cssText="width:1px;height:30px;float:left;background-color:%23113",m.appendChild(f)}var x=document.createElement("div");x.id="ms",x.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:%
@ColinEberhardt
ColinEberhardt / gist:36fe15ddee565af556b2
Created December 3, 2014 06:46
Swift class constants are mutable within the initialiser
// A follow-up to the blog post here:
// http://www.scottlogic.com/blog/2014/11/20/swift-initialisation.html
class Foo { }
class Bar: Foo {
// no initial value set here
let myConstant: Int
@ColinEberhardt
ColinEberhardt / Swift Events
Created February 11, 2015 09:15
An eventing mechanism for Swift
/// An object that has some tear-down logic
public protocol Disposable {
func dispose()
}
/// An event provides a mechanism for raising notifications, together with some
/// associated data. Multiple function handlers can be added, with each being invoked,
/// with the event data, when the event is raised.
public class Event<T> {
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.3
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@ColinEberhardt
ColinEberhardt / gist:b4bf4e4566ffa88afcda
Created March 20, 2015 08:14
Pipe forward operator and curried free functions = fluent interface
// meet Stringy - a simple string type with a fluent interface
struct Stringy {
let content: String
init(_ content: String) {
self.content = content
}
func append(appendage: Stringy) -> Stringy {
@ColinEberhardt
ColinEberhardt / gist:984907adbf8236077c1f
Last active June 15, 2016 23:22
Links from my talk at SwiftSummit
Silverlight and ReactiveExtensions article:
http://blog.scottlogic.com/2010/12/02/exploring-reactive-extensions-rx-through-twitter-and-bing-maps-mashups.html
My Ray Wenderlich author page, contains quite a few ReactiveCocoa and MVVM articles:
http://www.raywenderlich.com/u/ColinEberhardt
ObjC block syntax - say no more!
http://fuckingblocksyntax.com
Twitter app with sentiment analysis
@ColinEberhardt
ColinEberhardt / index.html
Last active July 24, 2017 15:22
Yahoo Finance Chart Step 1 - Basic Chart
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="http://colineberhardt.github.io/d3fc/Layout.js"></script>
<script src="http://colineberhardt.github.io/d3fc/d3fc.js"></script>
<link href="http://colineberhardt.github.io/d3fc/d3fc.css" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/>
</head>
<body>
@ColinEberhardt
ColinEberhardt / index.html
Last active August 29, 2015 14:24
Yahoo Finance Chart Step 2 - Gidlines and Area
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="http://colineberhardt.github.io/d3fc/Layout.js"></script>
<script src="http://colineberhardt.github.io/d3fc/d3fc.js"></script>
<link href="http://colineberhardt.github.io/d3fc/d3fc.css" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/>
</head>
<body>
@ColinEberhardt
ColinEberhardt / index.html
Last active August 29, 2015 14:24
Yahoo Finance Chart Step 3 - Styling
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="http://colineberhardt.github.io/d3fc/Layout.js"></script>
<script src="http://colineberhardt.github.io/d3fc/d3fc.js"></script>
<link href="http://colineberhardt.github.io/d3fc/d3fc.css" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/>
</head>
<body>