Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Vest chrisvest

View GitHub Profile
View .vimrc
syntax on
set background=dark
" Return cursor to the previous position when this file was open last
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
filetype plugin indent on
View gist:128317
module Rpn
where
import qualified Data.Map as Map
data Operator a = Unary (a -> a)
| Binary (a -> a -> a)
| Ternary (a -> a -> a -> a)
| Quaternary (a -> a -> a -> a -> a)
| Reductive ([a] -> a)
View clj
#!/bin/bash
# Runs clojure.
# With no arguments, runs Clojure's REPL.
# Arguments starting with -J are unpack and passed to the JVM.
# Arguments -cp and -classpath are treated specially so we correctly
# build a classpath.
# If rlwrap is found, the java invocation is wrapped in it.
# For other arguments, the first is treated as a script name, the rest
# passed as command-line arguments.
View clj
#!/bin/bash
BREAK_CHARS="(){}[],^%$#@\"\";:''|\\"
CLOJURE_DIR=/home/cvh/workspace/clojure
CLOJURE_JAR=$CLOJURE_DIR/clojure.jar
CONTRIB_JAR=$CLOJURE_DIR-contrib/clojure-contrib.jar
if [ "-c" = "$1" ]; then
mkdir -p classes
java -cp .:classes:$CLOJURE_JAR -Dclojure.compile.path=classes clojure.lang.Compile "$2"
View gist:552253
; Generate random output from input seed-text, using a Markov chain.
MAXGEN = 10000
NONWORD = "\n"
HEAD = NONWORD, NONWORD
prefix := HEAD
statetab = HashMap with-factory: (= Vector)
to start
View gist:906624
Install Caliper http://code.google.com/p/caliper/
Clone https://github.com/chrisvest/stormpot
$ mvn package && ./benchmark stormpot.benchmark.PartitionSelect
Compare ModuloAtomicCount with ModuloIdentityHashNewObject
- you may subtract ModuloConst from both if you want, or
ModuloIdentityHashThread from ModuloIdentityHashNewObject,
to remove a bit of the overhead.
View chrisvest-4clojure-solution28.clj
;; chrisvest's solution to http://4clojure.com/problem/28
(fn squash [xs]
(if (sequential? xs)
(mapcat squash xs)
(list xs)))
View chrisvest-4clojure-solution29.clj
;; chrisvest's solution to http://4clojure.com/problem/29
(fn [s] (apply str (filter #(Character/isUpperCase %) s)))
View chrisvest-4clojure-solution30.clj
;; chrisvest's solution to http://4clojure.com/problem/30
(fn [xs]
(reduce (fn [v x] (if (= x (last v)) v (conj v x))) [] xs))
View chrisvest-4clojure-solution31.clj
;; chrisvest's solution to http://4clojure.com/problem/31
#(partition-by identity %)
You can’t perform that action at this time.