Skip to content

Instantly share code, notes, and snippets.

@minimal
minimal / zshenv
Created July 13, 2009 15:15
zshrc
#!/bin/zsh
# Dynamically build the $PATH variable
for dircomponent in $path /sw/bin /sw/sbin /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin /compat/linux/bin /compat/linux/sbin /compat/linux/usr/bin /compat/linux/usr/sbin /usr/games /usr/X11R6/bin /usr/X11R6/sbin ~/bin ~/crossover/bin
do
if [[ -e $dircomponent ]]; then
path=($path $dircomponent)
fi
done
typeset -U path
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
;;; Future pipelining macro.
;;; Behaves like a let, but wraps everything in futures - running your bindings concurrently
;;; Computation takes only as long as the longest-running bind
(ns user
(:use clojure.walk clojure.test))
(defn cols
"Projection of n columns from coll"
[n coll]
@klang
klang / clojure-font-lock-setup.el
Created June 1, 2010 18:47 — forked from michalmarczyk/clojure-font-lock-setup.el
adding paredit-mode to the repl
;;; all code in this function lifted from the clojure-mode function
;;; from clojure-mode.el
(defun clojure-font-lock-setup ()
(interactive)
(set (make-local-variable 'lisp-indent-function)
'clojure-indent-function)
(set (make-local-variable 'lisp-doc-string-elt-property)
'clojure-doc-string-elt)
(set (make-local-variable 'font-lock-multiline) t)
@devn
devn / Destructuring Examples.clj
Created June 15, 2010 09:27
Destructuring Examples
;;; All Kinds of Destructuring ;;;
(let [foo 1] foo)
; => 1
(let [[foo bar] [1 2 3]] [foo bar])
; => [1 2]
(let [[foo bar & baz] [1 2 3]] [foo bar baz])
; => [1 2 (3)]
;; stolen from http://cemerick.com/2010/08/02/defrecord-slot-defaults/
(defmacro defrecord+defaults
"Defines a new record, along with a new-RecordName factory function that
returns an instance of the record initialized with the default values
provided as part of the record's slot declarations. e.g.
(defrecord+ Foo [a 5 b \"hi\"])
(new-Foo)
=> #user.Foo{:a 5, :b \"hi\"}"
[name slots & etc]
(require 'pc-select)
(defun slime-update-clojure-namespace ()
"Find the namespace in the current buffer and use SLIME's REPL
to switch to it, updating the namespace for all buffers."
(interactive)
(save-excursion
;; search for this buffer's namespace:
(goto-char 0)
(when (search-forward "(ns " nil t)
(let ((beg (point))
@klang
klang / what-parens-all-I-see-is-the-program.el
Created September 1, 2010 06:46
What parens? All I see is the program. (the Clojure color part of http://briancarper.net/blog/492/emacs-clojure-colors in one convenient place. Just dimming the parens: http://www.davep.org/emacs/parenface.el --- from: http://briancarper.net/blog/492/emac
(defun lisp-enable-paredit-hook () (paredit-mode 1))
(add-hook 'clojure-mode-hook 'lisp-enable-paredit-hook)
(defmacro defclojureface (name color desc &optional others)
`(defface ,name '((((class color)) (:foreground ,color ,@others))) ,desc :group 'faces))
(defclojureface clojure-parens "DimGrey" "Clojure parens")
(defclojureface clojure-braces "#49b2c7" "Clojure braces")
(defclojureface clojure-brackets "SteelBlue" "Clojure brackets")
(defclojureface clojure-keyword "khaki" "Clojure keywords")
(ns dining-service
(:use aleph.core)
(:use aleph.http)
(:use net.cgrand.moustache)
)
(defn report-handler [response-channel request]
(enqueue response-channel
{:status 200
:headers {"content-type" "text/plain"}
@robcowie
robcowie / eventriloquist.py
Created January 20, 2011 17:16
Supervisor --> AMQP event listener
# -*- coding: utf-8 -*-
"""
Run as a supervisor event listener process. See http://supervisord.org/events.html for more info.
An example eventlistener config block looks like:
[eventlistener:myeventhandler]
command=python /path/to/eventriloquist.py
events=EVENT