Skip to content

Instantly share code, notes, and snippets.

CL-USER> (ql:system-apropos "tree")
#<SYSTEM bk-tree / bk-tree-20110219-git / quicklisp 2011-04-18>
#<SYSTEM cl-btree-0.5 / cl-btree-0.5 / quicklisp 2011-04-18>
#<SYSTEM mcclim-tree-with-cross-edges / mcclim-20101006-cvs / quicklisp 2011-04-18>
#<SYSTEM spatial-trees / spatial-trees-20101006-darcs / quicklisp 2011-04-18>
#<SYSTEM trees / trees_0.11 / quicklisp 2011-04-18>
#<SYSTEM vcs-tree / vcs-tree-20101006-git / quicklisp 2011-04-18>
#!/bin/sh
#
# Swap Caps lock and Control
#
xmodmap -e "remove Lock = Caps_Lock"
xmodmap -e "remove Control = Control_L"
xmodmap -e "keysym Control_L = Caps_Lock"
xmodmap -e "keysym Caps_Lock = Control_L"
xmodmap -e "add Lock = Caps_Lock"
xmodmap -e "add Control = Control_L"
#+source: hetero-table
#+begin_src emacs-lisp
'((1 2 3 4)
("a" "b" "c" "d"))
#+end_src
#+source: all-to-string
#+begin_src emacs-lisp :var tbl='()
(defun all-to-string (tbl)
(if (listp tbl)
(defun all-to-string (tbl)
(if (listp tbl)
(mapcar #'all-to-string tbl)
(if (stringp tbl)
tbl
(format "%s" tbl))))
(require :cl-irc) (require :cl-ppcre)
(defpackage :adapt-bot (:use :cl :cl-irc :cl-ppcre))
(in-package :adapt-bot)
(defvar *connection*
(connect :nickname "adaptive-lab-bot" :server "irc.freenode.net"))
(defvar *group* "#adaptiveunm")
(defun say (fmt &rest args)
@eschulte
eschulte / xmonad.hs
Created June 5, 2011 20:49
simple xmonad configuration for running xmonad as the window manager for the XFCE desktop
-- Configuration for running xmonad as the window manager over XFCE
-- see http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Doc-Extending.html
import XMonad
import XMonad.Layout.NoBorders -- to remove window borders
import XMonad.Hooks.ManageDocks -- manage docks and panels
import qualified XMonad.StackSet as W -- to shift and float windows
import qualified Data.Map as M -- used to add key bindings
myManageHook = composeAll
-- per-window options, use `xprop' to learn window names and classes
@eschulte
eschulte / gist:902174
Created April 4, 2011 18:52
use bind to restructure arguments to lambda expressions
(defmacro lambdab ((&rest instrs) &rest body)
"Use `bind' to allow restructuring of argument to lambda expressions."
(declare (indent 1))
(let* ((evald-instrs instrs)
(syms (mapcar (lambda (_) (gensym)) evald-instrs)))
`(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))
;; example usage
(let ((fn (lambdab ((a b) c) (cons a c))))
(funcall fn '(1 2) 3)) ;; => (1 . 3)
@eschulte
eschulte / spreadsheet.clj
Created January 24, 2011 08:20
simple propagator-backed spreadsheet -- see http://gitweb.adaptive.cs.unm.edu/propagator.git
(ns propagator.spreadsheet ; see http://gitweb.adaptive.cs.unm.edu/propagator.git
(use propagator))
(def xrange 10) (def yrange 10)
(def spreadsheet
(map (fn [_] (map (fn [_]
(let [c (gensym)] (eval `(defcell ~c nil)) c))
(range xrange)))
(range yrange)))
@eschulte
eschulte / parse-elf-header.clj
Created January 6, 2011 16:20
Parse out an elf header, then write the header to a separate file. uses
(in-ns bin-ed.core) ; https://github.com/eschulte/bin-ed
;; example: parse the header of an elf file
(let [a-out (file-to-bytes "data/a.out")
head-ident-tmpl [:mag0 :byte
:mag1 :char
:mag2 :char
:mag3 :char
:class :byte
:data :byte
@eschulte
eschulte / lisp-interpreter.clj
Created November 29, 2010 19:24
Lisp interpreter in 4 lines of Clojure
#!/usr/bin/env clj-env
;; -*- mode: clojure -*-
(loop [expr ""]
(when-let [l (str expr " " (read-line))]
(recur (if (apply = (map (comp count #(filter (partial = %) l)) [\( \)]))
(do (println (eval (read-string l))) "") l))))