Skip to content

Instantly share code, notes, and snippets.

View penguins-python
from itertools import chain,imap
manufacturing_groups = { 'multiglobal manufacturing group',
'intergalactic joint ventures',
'transdimensional megacorp', }
manufacturers = { 'multiglobal manufacturing group': { 'red heron manufacturers',
'blue bass super-corp',
'yellow dog llc',
'orange penguin family manufacturers',
'green hornet industries', },
View penguins-haskell
import qualified Data.Map as Map -- refer to function foo as
gs = ["g1","g2"]
g2m = Map.fromList [("g1",["m1","m2"]),("g2",["m2"])]
m2w = Map.fromList [("m1",["w1","w2"]),("m2",["w2","w3"])]
nest xs = map (\x -> [x]) xs
-- lookup in dictionary by first element of key list, then prepend to key list
View recursive-consume.clj
user> (clojure.pprint/pprint (macroexpand-all
'(defn consume [c] (a/go (let [n (a/<! c)]
(when (zero? (mod n 10000)) (println n)))
(consume c)))))
pnf / clj-fly
Created Dec 11, 2014
Preliminary flycheck support for Clojure using Cider and Eastwood
View clj-fly
;;; clj-fly.el --- Flycheck: Clojure support -*- lexical-binding: t; -*-
;;; Commentary:
;;; So far, this only invokes eastwood. It works best if flycheck-pos-tip is used, so as not to clash with Cider doc messages.
;;; Code:
(require 'cider-client)
(require 'flycheck)
(defun parse-eastwood (s)

Keybase proof

I hereby claim:

  • I am pnf on github.
  • I am pnf ( on keybase.
  • I have a public key whose fingerprint is 1919 04F5 FA4D EF6A 64B3 AEDD 3F99 0C80 DAAD DC69

To claim this, I am signing this object:

pnf / blehblehblehpnf
Last active Aug 29, 2015
View blehblehblehpnf
scala> classOf[Enumeration#Value].getDeclaredFields.find(_.toString.contains("outerEnum"))
res137: Option[java.lang.reflect.Field] = Some(private final scala.Enumeration scala.Enumeration$Value.scala$Enumeration$$outerEnum)
scala> classOf[Enumeration#Value].getDeclaredFields.find(_.toString.contains("outerEnum")).get
res138: java.lang.reflect.Field = private final scala.Enumeration scala.Enumeration$Value.scala$Enumeration$$outerEnum
scala> val f = classOf[Enumeration#Value].getDeclaredFields.find(_.toString.contains("outerEnum")).get
f: java.lang.reflect.Field = private final scala.Enumeration scala.Enumeration$Value.scala$Enumeration$$outerEnum
pnf / mapf
Created Jun 10, 2013
Explore sequential composition and chained futures
View mapf
object mapfunc {
println("Let's do wacky things with lists") //> Let's do wacky things with lists
import scala.concurrent._
// Hold a list of functions of no arguments producing A
class SeqF[A] (l : Seq[()=>A]) {
def map[B](f : A =>B) = new SeqF( x => () => f(x())))
def scanLeft[B](b0 : B)(f : (B,A)=>B) : SeqF[B] = {
pnf /
Created Jun 21, 2013
Draw a sort-of-pretty ascii graph from input data in outline form.
#!/usr/bin/env python
import re
import sys
from collections import deque
class Frame:
def __init__(self,node,indent):
self.node = node
self.indent = indent
View view-bounds
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> implicit def strToInt(x:String) = x.toInt
warning: there were 1 feature warning(s); re-run with -feature for details
strToInt: (x: String)Int
scala> class C[A](v:A){def a(implicit ev:A=>Int)=123+ev(v)}
defined class C
pnf / frascii
Created Jun 24, 2013
Print out a fractal tree
View frascii
#!/usr/bin/env python
from math import *
import sys
# draw line from x,y of length s at angle theta, spawn growth of length s*r, theta+/-q unless n==0
def grow(x, y, theta, s, q, r, n):
ret = [(x,y,theta,s)]
n = n-1
if n>0:
x2 = x + s*cos(theta)
You can’t perform that action at this time.