Skip to content

Instantly share code, notes, and snippets.

View shanecelis's full-sized avatar

Shane Celis shanecelis

View GitHub Profile
;; Possible bug, or at least unexpected behavior, for typed array
;; literals. Demonstration below. The same storage is used
;; for the same literal.
;;
;; Run on guile (GNU Guile) 2.0.5 on Mac OS X.
;;
;; Shane Celis
(define x #f64(0. 1. 2.))
(define y #f64(0. 1. 2.))
;; Set the first element of x to 1.
/*
This file demonstrates a bug with C goto labels and Guile.
$ gcc `pkg-config guile-2.0 --cflags --libs` goto_label_bug.c -o goto_label_bug
goto_label_bug.c: In function 'main':
goto_label_bug.c:10: error: expected expression before 'SCM'
$ gcc `pkg-config guile-2.0 --cflags --libs` goto_label_bug.c -o goto_label_bug -D INSERT_NOOP
$ # No problem.
@shanecelis
shanecelis / show-errors.c
Created July 18, 2013 17:47
This file exhibits a lots of warnings in a C file that calls GNU Guile. The warnings are shown only when there is a compilation error.
/*
This file exhibits a lots of warnings in a C file that calls GNU
Guile. The warnings are shown only when there is a compilation error.
Shane Celis
*/
#include <libguile.h>
#define C_STRING_TO_SYMBOL(str) scm_string_to_symbol(scm_from_locale_string(str))
@shanecelis
shanecelis / make-trampoline.scm
Created August 29, 2013 17:48
Derivative of make-trampoline by Mark Weaver from #guile on irc.freenode.net
(define (make-trampoline module name)
"Creates a trampoline out of a symbol in a given module, e.g. (lambda () (name))"
(let ((var (module-variable module name)))
(unless var
(scm-error 'no-such-variable "make-trampoline" "Can't make a trampoline for variable named '~a that does not exist in module ~a." (list name module) #f))
(let ((proc (lambda () ((variable-ref var)))))
(set-procedure-property! proc 'name
(string->symbol (format #f "~a-trampoline" name)))
proc)))
@shanecelis
shanecelis / define-with-source.scm
Created November 25, 2013 19:35
An attempt at making the source code for procedures easy to track down at runtime. Useful for Emacsy when aping the self-documenting system in Emacs.
;; define-with-source.scm
;;
;; An attempt at making the source code for procedures easy to track
;; down at runtime. Useful for Emacsy when aping the self-documenting
;; system in Emacs.
;;
;; Shane Celis
(define-module (define-with-source)
#:use-module (ice-9 optargs)
such combinator much lambda
quiet
Y = λf.(λx.f (x x)) (λx.f (x x))
loud
such y much f
very a is plz f with f
wow a
such x much f
such z with x
very b is plz f with f
@shanecelis
shanecelis / unity-api-lookup.el
Created May 28, 2014 20:34
Simple Emacs utility function to lookup Unity API references
;; Simple Emacs utility function to lookup Unity API references by Shane Celis.
(defun unity-api-lookup (string)
"Opens up a browser to Google's first hit for the search string 'unity api reference ' plus your search term."
(interactive (list
(read-string "Look up Unity API reference for: "
(thing-at-point 'word) 'unity-api-lookup-history)))
(browse-url (concat "http://www.google.com/search?btnI&q="
(url-hexify-string
(concat "unity api reference " string)))))
@shanecelis
shanecelis / CoroutineTests.cs
Last active July 15, 2022 15:03
I was curious about how one could manually drive Unity's coroutines without necessarily putting them into Unity's scheduler.
/*
CoroutineTests.cs -- Shane Celis
I was curious about how one could manually drive Unity's coroutines
without necessarily putting them into Unity's scheduler. At the
heart of it, it's really easy to manually drive them:
// Get the coroutine.
IEnumerator ienum = MyCoroutine();
// Run it until it yields.
(defun dired-open-by-macosx ()
"Opens a file in dired with the Mac OS X command 'open'."
(interactive)
(shell-command (concat "open " (shell-quote-argument (expand-file-name (dired-file-name-at-point))))))
(define-key dired-mode-map (kbd "O") 'dired-open-by-macosx)
;;; minimap.el --- Sidebar showing a "mini-map" of a buffer
;; Copyright (C) 2009-2014 Free Software Foundation, Inc.
;; Author: David Engster <deng@randomsample.de>
;; Keywords:
;; Version: 1.2
;; This file is part of GNU Emacs.