Skip to content

Instantly share code, notes, and snippets.

View jl2's full-sized avatar

Jeremiah LaRocco jl2

View GitHub Profile
#!/usr/bin/lisp --script
(defmacro home (path)
`(merge-pathnames ,path (user-homedir-pathname)))
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
@jl2
jl2 / ltktest.asd
Created October 9, 2015 16:11
Test using ltk canvas.
;;;; ltktest.asd
(asdf:defsystem #:ltktest
:description "Describe ltktest here"
:author "Jeremiah LaRocco <[email protected]>"
:license "ISC"
:depends-on (#:ltk
#:iterate
#:alexandria)
:serial t
@jl2
jl2 / main.c
Created September 24, 2015 16:27
#include <stdio.h>
int my_function(int bob[20]) {
return sizeof(bob);
}
int main(int argc, char *argv[]) {
int array[22] = {0};
printf("%d\n", my_function(array));
return 0;
#include <iostream>
#include <chrono>
uint64_t fib(uint64_t n) {
uint64_t a=1;
uint64_t b=1;
uint64_t c = b+a;
for (uint64_t i=0; i<(n-2); ++i) {
c = b + a;
b = a;
@jl2
jl2 / package.lisp
Last active August 29, 2015 14:11
Association list based trie data structure in Common Lisp. Faster more memory efficient, and handles unicode better than the vector based trie I tried before.
;;;; package.lisp
(defpackage #:trie
(:use #:cl)
(:export #:create
#:add
#:contains
#:words
#:with-prefix
#:from-file
@jl2
jl2 / gist:d6b0f0829ee45c5e8e5f
Created November 26, 2014 01:01
updateemacs
#!/usr/bin/lisp --script
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(let* ((bzr-out-string (make-array '(0) :element-type 'base-char
:fill-pointer 0 :adjustable t))
@jl2
jl2 / updateql.lisp
Last active August 29, 2015 14:09
Update SBCL from Git
#!/usr/bin/lisp --script
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(ql:update-dist "quicklisp")
@jl2
jl2 / tsp.lisp
Last active August 29, 2015 14:03
Beginnings of a program to run approximation algorithms on instances of the traveling salesman problem.
;; (load "tsp.lisp")
(ql:quickload 'cl-ppcre)
(defstruct svg
(points nil :type list)
(polys nil :type list)
(lines nil :type list))
(defstruct point
@jl2
jl2 / svg.lisp
Last active August 29, 2015 14:02
Very rudimentary library for generating simple SVG files from Common Lisp. Handles points, lines, and polygons.
(defstruct svg
(points nil :type list)
(polys nil :type list)
(lines nil :type list))
(defstruct point
(x 0.0 :type (or float integer))
(y 0.0 :type (or float integer)))
(defstruct line
@jl2
jl2 / speeds.py
Created August 28, 2013 23:11
Read travel time data from http://cotrip.org/speed.htm and do neat stuff with it...
#!/usr/bin/env python3
import io
import sys
import json
import httplib2
from lxml import etree
roads_url = 'http://cotrip.org/speed.htm'
def printJSON(json):