Skip to content

Instantly share code, notes, and snippets.

@gregspurrier
gregspurrier / env_dump.shen
Created February 4, 2015 15:49
A function to generate code that recreates the state of the current envrionment
(define construct-environment
Globals -> [do | (global-load-sequence Globals)])
(define global-load-sequence
[] -> []
[Name | Names] -> [[set Name (construct-value (value Name))]
| (global-load-sequence Names)])
(define atom?
X -> (or (boolean? X)
@gregspurrier
gregspurrier / gist:9634498
Created March 19, 2014 02:34
Think that properties are always enumerated in insertion order in JavaScript? Think again.
# The following is in Node, but Firefox has the same behavior
$ node --version
v0.10.26
tinker:~ greg$ node
> var x = {"z": 0, "2": 1, "0": 2, "a": 3, "-3": 4, "b": 5, "-5": 6, "1": 7}
undefined
> Object.keys(x)
[ '0',
'1',
'2',
@gregspurrier
gregspurrier / gist:9414181
Created March 7, 2014 15:58
A tmux binding for opening the URL or path contained in the paste buffer in OS X
# Send the paste-buffer to the open command
bind u run-shell "tmux show-buffer | xargs open"
@gregspurrier
gregspurrier / sequence.scala
Last active December 29, 2015 23:49
Sequence wildcards and sequence arguments in Scala
import scala.collection.immutable.Queue
val q = Queue(1, 2, 3)
// When pattern matching against a sequence, the sequence wildcard _*
// can be used as the last pattern and will match an arbitrary number of
// elements. To bind the matched sequence to a variable, use the form
// `x @ _*`:
val restSeq = q match { case Queue(x, xs @ _*) => xs }
// --> rest: Seq[Int] = Queue(2, 3)
@gregspurrier
gregspurrier / foo.txt
Created July 1, 2013 02:50
Example that is crashing emacs when used with mmm-mode on OS X
= Some document
== Huzzah
[source,ruby]
----
# This should be ruby code
1.times do
puts "hello world"
end
@gregspurrier
gregspurrier / gist:5659105
Created May 27, 2013 21:10
specdoc output of KLaSC as of May 27, 2013.
Testing KLamba specification compliance of:
Shen 2010, copyright (C) 2010 Mark Tarver
released under the Shen license
www.shenlanguage.org, version 11
running under Common Lisp, implementation: CLisp
port 1.5 ported by Mark Tarver
@gregspurrier
gregspurrier / k_lambda_spec.txt
Last active March 13, 2020 15:10
ShenRuby's K Lambda Spec (work in progress)
Atoms:
a string
is self-evaluating
a symbol
is self-evaluating
may include any of the legal characters for symbol
may begin with any legal character other than a digit
may not begin with a digit
numbers
@gregspurrier
gregspurrier / gist:1515426
Created December 23, 2011 21:39
Hash#without
class Hash
# Returns a new hash that does not contain the specified keys
#
# {:a => 1, :b => 2, :c =>3, :d => 4}.without(:a, :b)
# => {:c=>3, :d=>4}
def without(*keys)
dup.tap { |h| keys.each { |k| h.delete(k) } }
end
end
@gregspurrier
gregspurrier / gist:1264972
Created October 5, 2011 16:47
Anonymous controller bug?
gspurrie-mn:proj% rvm use ruby-1.8.7@rspec_bug --create
Using /Users/gspurrie/.rvm/gems/ruby-1.8.7-p352 with gemset rspec_bug
gspurrie-mn:proj% gem install bundler
Fetching: bundler-1.0.21.gem (100%)1.0.21.gem
Successfully installed bundler-1.0.21
1 gem installed
Installing ri documentation for bundler-1.0.21...
Installing RDoc documentation for bundler-1.0.21...
gspurrie-mn:proj% gem install rails
@gregspurrier
gregspurrier / gist:916727
Created April 13, 2011 00:16
ree-1.8.6 install failure
gspurrie-mn:~% rvm --version
rvm 1.6.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
gspurrie-mn:~% rvm install ree-1.8.6
Installing Ruby Enterprise Edition from source to: /Users/gspurrie/.rvm/rubies/ree-1.8.6-20090610
ree-1.8.6-20090610 - #fetching (ruby-enterprise-1.8.6-20090610)
ree-1.8.6-20090610 - #extracting ruby-enterprise-1.8.6-20090610 to /Users/gspurrie/.rvm/src/ree-1.8.6-20090610
ree-1.8.6-20090610 - #installing
Removing old Rubygems files...