Skip to content

Instantly share code, notes, and snippets.

View krisajenkins's full-sized avatar
💭
:: Geek

Kris Jenkins krisajenkins

💭
:: Geek
View GitHub Profile
@krisajenkins
krisajenkins / fizzbuzz.clj
Created August 12, 2012 18:57
Fizzbuzz in clojure.
(clojure.pprint/pprint
(map vector
(range 25)
(cycle [:fizz :_ :_])
(cycle [:buzz :_ :_ :_ :_])))
; Credit to http://clojure-and-me.blogspot.co.uk/2012/08/functional-fizzbuzz.html, code rewritten a little by me.
(defwidget my-widget
...)
@krisajenkins
krisajenkins / .emacs-attic.el
Created January 26, 2013 16:09
def*-style syntax highlighting for Clojure in Emacs
;;; Adds new defn-esque keyword highlighting.
(add-hook 'clojure-mode-hook '(lambda ()
(font-lock-add-keywords nil '(("(\\(defwidget\\)\\s-+\\(\\w+\\)"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))))))
@krisajenkins
krisajenkins / .emacs-attic.el
Created January 26, 2013 16:13
def*-style syntax highlighting for Clojure in Emacs - Annotated
; Add a function that runs for any Clojure buffer.
(add-hook 'clojure-mode-hook
; It's an anonymous function and it takes no arguments.
'(lambda ()
; It calls the function that adds syntax-highlighting rules.
(font-lock-add-keywords nil
; So many escape codes! But behind those we're just saying:
; Match the '(' character.
@krisajenkins
krisajenkins / gist:6214585
Created August 12, 2013 20:03
LDN Clojure Bot
(defn possible-new-positions
[[x y]]
(map (fn [[x' y']]
[(+ x x')
(+ y y')]) (vec tron/legal-moves)))
(defn safe-move?
[look position]
(nil?
@krisajenkins
krisajenkins / .emacs snippet
Last active December 21, 2015 07:09
Add flashy flashing to Emacs eval calls.
(require 'nrepl-eval-sexp-fu)
(setq nrepl-eval-sexp-fu-flash-duration 0.25)
(defadvice lisp-eval-region (around lisp-eval-region-flash activate)
"Flash any calls to lisp-eval-region (and the functions that depend on it, like lisp-eval-defun)."
(let* ((start (ad-get-arg 0))
(end (ad-get-arg 1))
(flasher (nrepl-eval-sexp-fu-flash (cons start end)))
(hi (cadr flasher))
(unhi (caddr flasher)))
@krisajenkins
krisajenkins / demo.clj
Created November 21, 2013 17:34
Simple Quil
(defn setup []
(smooth)
(frame-rate 3)
(background 200))
(defn draw []
(fill (random 255))
(ellipse (random (quil/width))
(random (quil/height))
(random 100)
@krisajenkins
krisajenkins / wat.scala
Created November 25, 2013 12:46
Scala, we need to talk about what 'immutable' means.
class Thing { var x = 5 }
val things = scala.collection.immutable.List(new Thing)
println(things.head.x) // Prints 5
things.head.x = 10 // WAT?
println(things.head.x) // Prints 10
@krisajenkins
krisajenkins / wat2.scala
Last active December 29, 2015 08:08
Erm...WAT.
class Thing {
var x = 5
override def equals(o: Any) = o match {
case that: Thing => that.x == this.x
case _ => false
}
}
val a = new Thing
val b = new Thing
val stuff = scala.collection.immutable.Set(a, b)
@krisajenkins
krisajenkins / .vimrc-snippet
Created February 13, 2014 09:43
My current vim bundle list.
Bundle 'gmarik/vundle'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'Shougo/neocomplcache'
Bundle 'altercation/vim-colors-solarized'
Bundle 'edsono/vim-matchit'
Bundle 'godlygeek/tabular'
Bundle 'johnsyweb/vim-makeshift'
Bundle 'jpalardy/vim-slime'