Skip to content

Instantly share code, notes, and snippets.

View luismbo's full-sized avatar

Luís Oliveira luismbo

View GitHub Profile
@luismbo
luismbo / config.el
Last active November 5, 2021 10:56
Minimal, self-contained SLIME installation for reproducing bugs
$ cat minimal-config.el
(setq user-emacs-directory "/tmp/temp-emacs-home")
(ignore-errors (delete-directory user-emacs-directory t))
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(package-install 'slime)
(setq inferior-lisp-program "sbcl")
(slime)
@luismbo
luismbo / redirect.lisp
Created May 27, 2020 12:17
Redirect stdout to REPL
CL-USER> (multiple-value-bind (read write) (sb-unix:unix-pipe)
(let ((read-stream (sb-sys:make-fd-stream read :buffering :line)))
(sb-thread:make-thread (lambda ()
(loop for line = (read-line read-stream nil nil)
while line do (write-line line *standard-output*))))
(sb-posix:dup2 write sb-sys:*stdout*)))
1
CL-USER> (progn (cffi:foreign-funcall "puts" :string "COME TO ME STDOUT!" :int)
(cffi:foreign-funcall "fflush" :pointer (cffi:null-pointer) :int))
0
(in-package :cl-user)
(defmacro defun* (name args &body body)
`(progn
(defun ,name ,args ,@body)))
(progn
(defun* works ()))
(uiop:with-upgradability ()
~/s/typep ❯❯❯ cat compiler-bug.lisp
(in-package :cl-user)
(defclass foo ()
())
(defun bar ()
(let ((x (non-existing-function-1)))
(when (typep x 'foo)
(non-existing-function-2 x))))
@luismbo
luismbo / periodic-scheduler.lisp
Last active April 10, 2019 09:34
Periodic Scheduler
(in-package :cl-user)
;;; Vince, A. "Scheduling periodic events." Discrete Applied Mathematics 25.3 (1989): 299-310.
;;; http://www.sciencedirect.com/science/article/pii/0166218X89900085
;; * Events E_1, ..., E_n occur periodically with periods m_1, ..., m_n.
;; * x_i denote any occurence time of E_i.
;; * 0 <= x_i <= m_i for all i since E_i recurs at intervals m_i.
;; * Other occurences of E_i are given by x_i + k*m_i, k an integer.
;; * Therefore an n-tuple of times x = (x_1, ..., x_n) determines all occurences of

Keybase proof

I hereby claim:

  • I am luismbo on github.
  • I am luismbo (https://keybase.io/luismbo) on keybase.
  • I have a public key ASCvm-kTgSnAQwHt2mK9XI45slHYkaDh50NBmtR2QXeioAo

To claim this, I am signing this object:

@luismbo
luismbo / portuguese+esperanto-emacs-style-prefix.ahk
Last active April 25, 2020 14:33
Emacs-style AutoHotKey keymaps
CapsLock::Ctrl
F13::WinActivate, ahk_exe firefox.exe
^#u::WinActivate, ahk_exe firefox.exe
F14::WinActivate, ahk_exe thunderbird.exe
^#i::WinActivate, ahk_exe thunderbird.exe
F15::WinActivate, ahk_exe Slack.exe
^#o::WinActivate, ahk_exe Slack.exe
@luismbo
luismbo / repl-read-mode.el
Last active June 14, 2016 20:13
Tweaked repl-read mode for Xach
;;;;; REPL Read Mode
(setq slime-repl-read-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map lisp-mode-map)
(define-key map "\C-m" 'slime-repl-return)
(define-key map [return] 'slime-repl-return)
(define-key map "\C-c\C-b" 'slime-repl-read-break)
(define-key map "\C-c\C-c" 'slime-repl-read-break)
(define-key map [remap slime-indent-and-complete-symbol] 'ignore)
@luismbo
luismbo / hygrophobia.py
Created January 22, 2015 14:14
hygrophobia.py
#!/usr/bin/env python
API_KEY='XXX'
API_URL='https://api.xively.com/v2/feeds/XXX'
SERIAL_PORT='/dev/tty.usbserial-A9005aBb'
import serial
import json
import requests
@luismbo
luismbo / Makefile
Last active December 19, 2015 03:39
Project template for Coursera's "Discrete Optimization" course using SBCL.
submit:
python submit.pyc
clean:
find . \( -name "*~" -name "*.dfsl" -o -name "*.fasl" -o -name "*.fas" -o -name "*.lib" -o -name "*.x86f" -o -name "*.amd64f" -o -name "*.sparcf" -o -name "*.sparc64f" -o -name "*.hpf" -o -name "*.hp64f" -o -name "*.ppcf" -o -name "*.nfasl" -o -name "*.ufsl" -o -name "*.fsl" -o -name "*.lx64fsl" \) -exec rm {} \;