Skip to content

Instantly share code, notes, and snippets.

Peter Fraenkel pnf

Block or report user

Report or block pnf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View viewducers.scala
trait ViewTransformer[-A,+B] {
def sequence(in: Iterable[A]) = transform(in.view).to(IterableFactory.toSpecific(in.iterableFactory))
def transform(v: View[A]): View[B]
def map[C](f: B => C): ViewTransformer[A,C] = new ViewTransformerImpl[A,C,B](this) {
override def transform(v: View[A]): View[C] = prev.transform(v).map(f)
}
def flatMap[C](f: B => IterableOnce[C]): ViewTransformer[A,C] = new ViewTransformerImpl[A,C,B](this) {
override def transform(v: View[A]): View[C] = prev.transform(v).flatMap(f)
}
}
View quicksort.hs
{-# LANGUAGE RankNTypes #-}
import Data.STRef
import Data.Vector (fromList, toList, freeze, thaw)
import Control.Monad
import Data.Vector.Mutable (MVector, STVector, read, write, swap)
import qualified Data.Vector as V (Vector, length)
import Data.List (sortOn)
import Prelude hiding (read)
import GHC.ST
View qaxl.clj
(ns qaxl.core
(:use clojure.walk clojure.pprint qaxl.cache)
(:require [co.paralleluniverse.pulsar.async :as qa]
[clojure.core.async :as a]
[co.paralleluniverse.pulsar.core :as q]
[clojure.test :refer [function?]]
[co.paralleluniverse.fiber.httpkit.client :as hk]
[co.paralleluniverse.pulsar.core :refer [fiber]]
[clojure.core.match :refer [match]]))
View quattro.el
;; La bella vita di quattro finestre
(global-set-key "\C-col" 'windmove-left)
(global-set-key "\C-cor" 'windmove-right)
(global-set-key "\C-cou" 'windmove-up)
(global-set-key "\C-cod" 'windmove-down)
(global-set-key "\C-cow" 'ido-jump-to-window)
(defun windmove-opposite () (interactive)
(if (windmove-find-other-window 'up) (windmove-up) (windmove-down))
(if (windmove-find-other-window 'right) (windmove-right)(windmove-left)))
(global-set-key "\C-coo" 'windmove-opposite)
@pnf
pnf / blehblehblehpnf
Last active Aug 29, 2015
blehblehblehpnf
View blehblehblehpnf
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
View keybase.md

Keybase proof

I hereby claim:

  • I am pnf on github.
  • I am pnf (https://keybase.io/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
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)
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)))))
(def
consume
(fn*
([c]
(let*
[c__8709__auto__
View penguins-haskell
import qualified Data.Map as Map -- refer to function foo as Map.foo
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 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', },
You can’t perform that action at this time.