This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |