Skip to content

Instantly share code, notes, and snippets.

@ejbs
ejbs / DTEK.asm
Created September 12, 2016 19:59
DTEK
# hexmain.asm
# Written 2015-09-04 by F Lundevall
# Copyright abandonded - this file is in the public domain.
# Q1: Print 0, since it cleans out the bits left of the fourth bit
# Q2: For numbers <9
.text
main:
li $a0,0x0F # change this to test different values
jal hexasc # call hexasc
;; Unrolling a loop (just for fun)
(defconstant mod-adler 65521)
(defun adler32 (data &optional (length nil))
(let ((l (or length (length data)))
(a 1)
(b 0))
(declare (type fixnum l a b)
(type (vector fixnum) data))

In response to REBOL versus LISP macros

This is an attempt by me to re-create the so-called definitional binding of REBOL in LISP and is a continuation of my comment here: https://news.ycombinator.com/item?id=11587952 .

We will start by loading a couple of libraries.

(ql:quickload '( :alexandria :closer-mop))
(in-package :closer-mop)
(use-package :alexandria)
;; http://blog.hostilefork.com/rebol-vs-lisp-macros/
(ql:quickload '( :alexandria :closer-mop))
(in-package :closer-mop)
(use-package :alexandria)
(defvar *env* ())
(defclass fexpr (funcallable-standard-object)
((env :accessor env :initform nil :initarg :env)
(src :accessor src :initform nil :initarg :src)
@ejbs
ejbs / git add and commit current file for Emacs
Created February 11, 2014 10:54
Small function for nice integration with git add and commit in Emacs workflow
(defun git-add-and-commit-current-file ()
(interactive)
(let ((bufn (buffer-file-name (current-buffer))))
(if bufn
(progn
(shell-command (format "git add %s" bufn))
(shell-command (format "git commit -m \"%s\"" (read-from-minibuffer "Message: "))))
(print "Current buffer has no file associated with it"))))
;; (global-set-key (kbd "C-c C-f") 'git-add-and-commit-current-file)
(defun read-hash-list (stream)
(read-delimited-list #\} stream))
(defun make-read-hash-table (stream char)
(declare (ignore char))
(let ((a-list (read-hash-list stream))
(ht (make-hash-table)))
(assert (evenp (length a-list)))
(loop for i = 0 then (+ i 2) until (= i (length a-list))
do (setf (gethash (elt a-list i) ht)