Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
puffnfresh / getinstance.js
Created March 29, 2013 02:04
Two nice helper functions for creating constructors in JavaScript.
// Polyfill for Object.create
function create(proto) {
function Ctor() {}
Ctor.prototype = proto;
return new Ctor();
}
// Always returns an instance of constructor
function getInstance(self, constructor) {
return self instanceof constructor ? self : create(constructor.prototype);
@vmarquez
vmarquez / Polymorphism.scala
Last active December 23, 2015 09:49
Two implementations of a Design by Contract Cache interface. Parametric Polymorphism is more flexible than subtype polymorphism.
case class GenericCache[A[_,_], B, C](instance: A[B,C], getf: B=>C, putf: (B,C)=>Unit) {
def retrieve(b: B) = getf(b)
def insert(b: B, c: C) = putf(b,c)
}
//Notice how neither cache implementations have to even be aware of the existnace of the typeclass. much more flexible than inheritance
class FastCache[A,B] {
private var m = Map[A,B]() //excuse mutability for illustration purposes
def add(a: A, b: B): Unit = {
m = m + (a->b)
@soc
soc / gist:8454725
Created January 16, 2014 13:07
My experience with C#
I did a small project in C# recently, and I basically assumed
that coming from Scala I could enjoy all the benefits of a
(more) mainstream language and a polished, integrated
ecosystem.
Boy was I wrong.
My experience starts with installing Microsoft's latest Visual
Studio 2013 Express Desktop IDE which went really smooth.
@cb372
cb372 / jargon.md
Last active January 10, 2026 21:11
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.

@aparrish
aparrish / spacy_intro.ipynb
Last active March 14, 2025 21:43
NLP Concepts with spaCy. Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active December 18, 2025 05:55
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.