Skip to content

Instantly share code, notes, and snippets.

View orthecreedence's full-sized avatar

andrew lyon orthecreedence

View GitHub Profile
(defun sleeper ()
(let ((f1 (green-threads:make-future)))
(as:delay (lambda () (complete-future f1 'hai)) :time 3)
f1))
(defun app ()
(with-green-thread
(format t "start sleeper~%")
(format t "end sleeper: ~a~%" (wait-on (sleeper)))))
@orthecreedence
orthecreedence / gist:9916737
Last active August 29, 2015 13:57
Hotfix for disabling "minimize to tray"
cd /path/to/turtl
mkdir -p tmp/release
cd tmp
unzip ../package.nw
# in your editor of choice, open main.js and find this block (around line 154):
#
# win.on('minimize', function() {
# win.hide();
# // Window.hide() hides the tray menu, so we just remove it and re-add it
@orthecreedence
orthecreedence / gist:2e7d974cfbbed733347f
Last active August 29, 2015 14:02
Non-recursive macrolet
(defpackage :mlet-nonr
(:use :cl))
(in-package :mlet-nonr)
(defun %attack (item fn)
(format t "attacking ~a, then calling fn~%" (car item))
(funcall fn (car item)))
(defmacro attack (item fn)
"This is a macro so we can bind to multiple values. In this case, %attack only
(defun return-fastest (&rest functions)
(let* ((retvals nil)
(threads nil)
(results-lock (bt:make-lock "results"))
(sig (bt:make-condition-variable))
(wrapped (mapcar (lambda (fn)
(lambda ()
(let ((got-results (bt:with-lock-held (results-lock) retvals)))
(format t "th: res1: ~a~%" got-results)
(unless got-results

Keybase proof

I hereby claim:

  • I am orthecreedence on github.
  • I am orthecreedence (https://keybase.io/orthecreedence) on keybase.
  • I have a public key whose fingerprint is DEDF 113E 5424 8344 1637 16B5 5C66 FAD1 3222 D757

To claim this, I am signing this object:

@orthecreedence
orthecreedence / gist:a2b666419fe220bfae31
Last active August 29, 2015 14:02
ECL socket failure (segfault) test
(ql:quickload :cl-async)
(defpackage :sock-test
(:use :cl)
(:export :delay
:request))
(in-package :sock-test)
(defun delay ()
"Use an async delay. This uses the standard cl-async callback mechanism, which
@orthecreedence
orthecreedence / gist:15dea89a0a7d591bba51
Last active August 29, 2015 14:02
ECL CFFI segfault
(ql:quickload :cffi)
(defpackage :sock-test
(:use :cl)
(:export :delay
:request))
(in-package :sock-test)
(defconstant +af-inet+ 2)
(ql:quickload '(:cl-async :cl-interpol :babel))
(defpackage :cl-async-bench
(:use :cl))
(in-package :cl-async-bench)
(cl-interpol:enable-interpol-syntax)
(defparameter
*http-response*
#!/bin/bash
FILE=$1
if [ "$FILE" == ""]; then
echo "Usage: $0 /path/to/dump.sql"
exit 1
fi
/usr/local/postgres/bin/psql \
-h 127.0.0.1 \
@orthecreedence
orthecreedence / ga.lisp
Created October 9, 2015 02:45
Common Lisp optimal formula finder (using genetic algorithms)
(ql:quickload :bordeaux-threads)
(defpackage :genetic
(:use :cl))
(in-package :genetic)
(defvar *target* 345)
(defun ^ (num pow)
(if (< pow 1)