Skip to content

Instantly share code, notes, and snippets.

(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))
@kevinold
kevinold / git-flow_test.sh
Created August 19, 2010 16:45
testing git-flow on existing git repo
# In reply to my own question
# (http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/#comment-69995567)
# about using git-flow with existing git repos I experimented with a dummy
# git repo and it appears rather straight-forward
kold@Macintosh-27 $ git init test_git_flow
Initialized empty Git repository in /private/tmp/test_git_flow/.git/
(/tmp)
kold@Macintosh-27 $ cd test_git_flow/
@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")
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active May 16, 2024 16:51
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
(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"}
@ibdknox
ibdknox / socket.clj
Created October 31, 2010 06:48
compojure with websockets
(ns wl.core
(:use compojure.core, aleph.core, aleph.http, hiccup.core, hiccup.page-helpers)
(:require [compojure.route :as route])
(:gen-class))
(def broadcast-channel (channel))
(defn chat-handler [ch handshake]
(receive ch
(fn [name]
@markrendle
markrendle / Git Bash.vbs
Created November 25, 2010 17:31
Modified Git Bash to use Console2
Set AppObj = CreateObject("Shell.Application")
If WScript.Arguments.Length=1 Then
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"" -d """ & WScript.Arguments(0) & """"
Else
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"""
End If
@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
@robcowie
robcowie / mysqldb_query_generator.py
Created February 7, 2011 16:05
Memory-efficient, streaming query generator with MySQLdb
from MySQLdb.cursors import SSDictCursor
def iterate_query(query, connection, arraysize=1):
c = connection.cursor(cursorclass=SSDictCursor)
c.execute(query)
while True:
nextrows = c.fetchmany(arraysize)
if not nextrows:
break
@enaeseth
enaeseth / yaml_ordered_dict.py
Created February 25, 2011 19:54
Load YAML mappings as ordered dictionaries
import yaml
import yaml.constructor
try:
# included in standard lib from Python 2.7
from collections import OrderedDict
except ImportError:
# try importing the backported drop-in replacement
# it's available on PyPI
from ordereddict import OrderedDict