Skip to content

Instantly share code, notes, and snippets.

View r-moeritz's full-sized avatar

Ralph r-moeritz

  • QLD, Australia
  • 18:23 (UTC +10:00)
View GitHub Profile
@r-moeritz
r-moeritz / init.el
Created June 28, 2011 21:28
My init.el
;; -*- mode: Lisp; lexical-binding: t; -*-
;; ----------------------------------------------------------------------
;; HELPER FUNCTIONS
;; ----------------------------------------------------------------------
(defvar electrify-return-match
"[\]}\)\"]"
"If this regexp matches the text after the cursor, do an \"electric\"
return.")
@r-moeritz
r-moeritz / gist:1973703
Created March 4, 2012 16:11
ClojureCLR AssemblyResolve
static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
{
var name = args.Name.Split(',').FirstOrDefault();
if (String.IsNullOrEmpty(name) || name.EndsWith(".resources")) return null;
name = name.Replace('.', '_');
var data = (byte[])Properties.Resources.ResourceManager.GetObject(name);
return (data == null) ? null : Assembly.Load(data);
}
@r-moeritz
r-moeritz / gist:1974044
Created March 4, 2012 17:40
ClojureCLR LoadEmbeddedAssembly
public static void load(String relativePath)
{
bool loadAsResource = EmbeddedAssembly(relativePath);
load(relativePath, true, loadAsResource);
}
private static bool EmbeddedAssembly(String relativePath)
{
return (ResourceData(ResourceName(relativePath)) != null);
}
@r-moeritz
r-moeritz / gist:2761145
Created May 21, 2012 08:21
defmacro/g! nif
(defmacro/g! nif (expr pos zero neg)
`(let ((,g!result ,expr))
(cond ((plusp ,g!result) ,pos)
((zerop ,g!result) ,zero)
(t ,neg))))
@r-moeritz
r-moeritz / gist:2761193
Created May 21, 2012 08:35
nif macroexpand
(macroexpand
'(nif (random 100) 'positive 'zero 'negative))
;; Expands to:
(LET ((#:RESULT3117 (RANDOM 100))) (COND ((PLUSP #:RESULT3117) 'LET-OVER-LAMBDA.G!.EXAMPLES::POSITIVE) ((ZEROP #:RESULT3117) 'LET-OVER-LAMBDA.G!.EXAMPLES::ZERO) (T 'LET-OVER-LAMBDA.G!.EXAMPLES::NEGATIVE)))
@r-moeritz
r-moeritz / gist:2761273
Created May 21, 2012 08:54
nif clojure
(defmacro nif [expr pos zero neg]
`(let [~res# ~expr]
(cond (> ~res# 0) ~pos
(= ~res# 0) ~zero
:else ~neg)))
@r-moeritz
r-moeritz / set-umlaut-keys.lisp
Created July 25, 2012 06:19
Umlaut keybindings
;; -*- mode: Lisp; lexical-binding: t; -*-
(defun global-set-umlaut-keys ()
(let ((gen-insert-key
(lambda (key)
(lambda ()
(interactive)
(ucs-insert key)))))
(global-set-key (kbd "\C-co") (funcall gen-insert-key #xf6))
(global-set-key (kbd "\C-cu") (funcall gen-insert-key #xfc))
@r-moeritz
r-moeritz / hello.lisp
Created July 31, 2012 00:34
ECL Hello World
(princ "Hello world!")
(terpri)
(quit)
@r-moeritz
r-moeritz / gist:3212289
Created July 31, 2012 00:35
compile-file
(ext:install-c-compiler)
(compile-file "hello.lisp" :system-p t)
@r-moeritz
r-moeritz / gist:3212295
Created July 31, 2012 00:37
c:build-program
(c:build-program "binary" :lisp-files '("hello.obj"))