Skip to content

Instantly share code, notes, and snippets.

View KirinDave's full-sized avatar

Dave Fayram KirinDave

View GitHub Profile
set -g prefix "`"
unbind-key C-b
bind "`" send-prefix
set-option -g mouse-select-pane on
set-window-option -g utf8 on
bind '"' choose-window
bind k confirm-before kill-window
@KirinDave
KirinDave / gist:1162732
Created August 22, 2011 15:53 — forked from Ragmaanir/gist:1162677
cyclic definitions
object A1 { lazy val X = B1.Y }
object B1 { lazy val Y: Int = A1.X }
println("Executes safely unless you try and evaluate A1.X or B1.Y because they have no definition.")
object ABase { val X = 1 }
object A2 { lazy val X = B2.Y+1 }
object B2 { lazy val Y :Int = ABase.X*2 }
println("Even this could cause problems, but lazy helps. A2.X = " + A2.X.toString)
Thread.new {
sleep(1)
$stderr.puts ">> Baby threw up."
raise "Barf."
}
$stderr.puts ">> Mommy is listening to the monitor, but she is also drunk."
sleep(5)
$stderr.puts ">> Mommy never woke up."
@KirinDave
KirinDave / inredis.hs
Created July 1, 2011 04:07
Amping up the redis client library in haskell.
subscriptionEnumerator :: (BS s, MonadIO m) =>
Redis
-> Int
-> Enumerator (Message s) m b
subscriptionEnumerator rs timeout (Continue k) = do
nextRead <- liftIO $ listen rs timeout;
let chunk = Chunks $ maybeToList nextRead in
k chunk >>== subscriptionEnumerator rs timeout
subscriptionEnumerator rs timeout step = returnI step
@KirinDave
KirinDave / main.el
Created June 22, 2011 21:19
How I load my file
(add-to-list 'load-path "~/.emacs.d/manual/color-theme")
(add-to-list 'load-path "/Users/kirindave/lib/emacs/solarized")
(require 'color-theme)
(require 'color-theme-solarized)
(eval-after-load 'color-theme
(progn (color-theme-initialize)))
; This is my old theme.
;(color-theme-charcoal-black)
;(set-face-background 'region "#555555")))))
@KirinDave
KirinDave / maze.rag
Created April 24, 2011 07:15
The canonical example of a rag file.
1|A Maze|You are in the center of a maze.|south=2,east=2||
2|The Center of the Maze|A fountain quietly burbles in the center of this maze, housed by a belltower. A gentle breeze rustles the hedges surrounding you. A thick velvet rope hangs down from the belltower, swaying softly.|north=1|south=3|pull rope=A deep gonging sound can be heard. There is a sound of mechanical action beneath your feet, and the hedge to the south ripples and shuffles like a door has opened behind it. (You can go south from here).\dance=You dance quietly while no one can see you.
3|The Real Center of the Maze|The wizard's tower stands here, forboding. Its dark stone buttresses crowd back the hedges of the maze. Clouds gather about the top of its spiraling reach. There is a door in front of you, slightly ajar.|north=2,door=4||
@KirinDave
KirinDave / erlang-setup.el
Created April 22, 2011 17:26
My toplevel emacs file
;;This is needed for Erlang mode setup
(defun get-erlang-root ()
(if (file-exists-p "/p/lib/erlang")
"/p/lib/erlang"
"/usr/local/lib/erlang"))
(let* ((root-dir (get-erlang-root))
(bin-dir (expand-file-name "bin" root-dir))
package com.banksimple.util
private[util] final class Effectful[T](val origin: T) {
/**
* A special case of doto, andAlso is useful for
* quick logging or output tasks. Similar in use
* to doto, but only takes one function.
* */
def andAlso(x: T => Unit): T = { x(origin) ; origin }
@KirinDave
KirinDave / HordeActor.scala
Created February 20, 2011 17:58
An actor to address a tight-timeline horde problem, where many request for identical (and potentially non-trivial) pieces of data enter the system at once.
package com.swipr.lib
import akka.actor._
import akka.dispatch._
import scala.collection.immutable._
package HordeProtocol {
case class GetOrCreate(key: Any, valueGenerator: () => Any)
case class ClearJob(keyToClear: Any, value: Any)
}