Skip to content

Instantly share code, notes, and snippets.

View danlentz's full-sized avatar

Dan Lentz danlentz

View GitHub Profile
@danlentz
danlentz / DDG-UD--drama.lisp
Created June 15, 2013 23:03
Sambchase's dictionary scraping paste
(ql:quickload '(drakma cl-interpol yason))
(defpackage dictionary-api-scraper
(:nicknames :dictionary)
(:use :cl)
(:import-from :drakma
:http-request)
(:import-from :babel
:octets-to-string)
(:import-from :yason
(defmacro ->> (gen &rest forms)
"Clojure's ->> macro"
(reduce (lambda (g f)
(cond ((symbolp f) (list f g))
((consp f) `(,@f ,g))
(t (error "invalid form : ~S" f))))
forms :initial-value gen))
(defmacro $ (&rest xs)
"Gauche's $ macro (minimal ver.)"
@danlentz
danlentz / cl-history.txt
Created June 15, 2013 22:35
Detailed account and personal insights on the history of common-lisp
From [email protected] Thu Oct 20 16:53:41 EDT 1994
Article: 15160 of comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!usenet.eel.ufl.edu!usenet.cis.ufl.edu!caen!math.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ns.mcs.kent.edu!kira.cc.uakron.edu!malgudi.oar.net!malgudi.oar.net!welch
From: [email protected] (Arun Welch)
Newsgroups: comp.lang.lisp
Subject: CL History (was Re: Why do people like C?)
Date: 20 Oct 94 15:34:10
Organization: OARnet
Lines: 3244
Message-ID: <[email protected]>
@bhyde
bhyde / slime-documentation-search.el
Last active December 18, 2015 05:48
Hand off slime doc search to a website, bound to C-c C-d C-s, defaults to quickdocs.org.
;;; -*- lexical-binding: t -*-
(define-slime-contrib slime-documentation-search
"Hand off a documenation search to a web site."
(:authors "Ben Hyde <[email protected]>")
(:license "GPL")
(:on-load
(define-key slime-doc-map "\C-s" 'slime-documention-search)
(define-key slime-doc-map "s" 'slime-documention-search)))

Libgit2 Conventions

We like to keep the source consistent and readable. Herein are some guidelines that should help with that.

Naming Things

All types and functions start with git_, and all #define macros start with GIT_.

@pnathan
pnathan / clj-hash.lisp
Last active December 16, 2015 11:38
clj-hash: clojure's hashes kind of brought to common lisp
(defmacro clj-hash (&rest kvs)
"Destructures `kvs`: assums keys and values are paired together:
kvs ::= k1 v1 ... kn vn
Defines a sequence of functions ki that will obtain the value of ki
from a hash table.
Raises simple-error on ki not being a keyword.
@danlentz
danlentz / Stream-examples.lisp
Created April 20, 2013 22:23
Sbcl stream exqmples
(defclass wrapped-stream (fundamental-stream)
((stream :initarg :stream :reader stream-of)))
(defmethod stream-element-type ((stream wrapped-stream))
(stream-element-type (stream-of stream)))
(defmethod close ((stream wrapped-stream) &key abort)
(close (stream-of stream) :abort abort))
(defclass wrapped-character-input-stream
anonymous
anonymous / Siri Listener
Created March 27, 2013 19:54
An AppleScript that waits for a message to appear in the Mac "Notes" application, then perform an action. An iOS user can use Siri to "Write a note", and then say "What apps are running?" to get a list of all apps running on the Mac, "Shut down" to shut down the Mac, "Go to sleep" to put the Mac to sleep, or "Restart my mac" to restart the Mac. …
on run
-- just here to get things started...
end run
on idle
tell application "Notes"
if exists note "What apps are running?" then
delete note "What apps are running?"
tell application "Finder"
set myRunningApps to name of every process whose visible is true
;;; THIS IS A PROOF OF CONCEPT. This has been "released" in case someone
;;; actually wants to develop it into a usable tool. Don't even think
;;; about using this version for any sort of production use.
;;; Author: Juho Snellman
;;; http://jsnell.iki.fi/blog/archive/2005-07-06.html
(defparameter *retain* (make-hash-table :test 'eq))
(defparameter *ignore* (make-hash-table :test 'eq))
(defparameter *classes* nil)
(deftype octet () '(unsigned-byte 8))
(defun read-le-uint (size in)
(loop FOR i FROM 0 BELOW size
SUM (ash (read-byte in) (* i 8))))
(defun read-bytes (size in)
(let ((ary (make-array size :element-type 'octet)))
(read-sequence ary in)
ary))