Skip to content

Instantly share code, notes, and snippets.

void initialize_sensors(isr motion_isr)
{
if (has_motion()) {
pinMode(MOTION_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(MOTION_PIN), motion_isr, CHANGE);
}
if (has_prox()) {
prox_sensor.init();
prox_sensor.setTimeout(500);
@dastels
dastels / gist:fbae2b13fbd4ec00f703
Created January 24, 2016 06:52
Odd rubymotion error
*** Starting simulator
(main)> 2016-01-24 00:18:45.737 lisppad[73643:5824162] undefined method `-@' for :handleLongPress:Symbol (NoMethodError)
2016-01-24 00:18:45.741 lisppad[73643:5824162] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'undefined method `-@' for :handleLongPress:Symbol (NoMethodError)
'
*** First throw call stack:
(
0 CoreFoundation 0x000000010303be65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000100a6fdeb objc_exception_throw + 48
2 lisppad 0x00000001005cdd1f _ZL10__vm_raisev + 367
3 lisppad 0x00000001005cde10 rb_vm_raise + 208
def loadView
@layout = PackageSelectLayout.new
@layout.controller = self
self.view = @layout.view
@collection = @layout.collection
lpgr = UILongPressGestureRecognizer.alloc.initWithTarget(@layout, action: 'handleLongPress:')
lpgr.delegate = @layout
lpgr.delaysTouchesBegan = true
@collection.addGestureRecognizer(lpgr)
end
@dastels
dastels / testing.lisp
Created July 11, 2015 22:53
Common Lisp testing framework
;;; Common Lisp testing framework
;;; Copyright 2015 Dave Astels
;;; MIT License
(defvar number-of-tests 0)
(defvar number-of-failures 0)
(defvar failure-messages '())

Keybase proof

I hereby claim:

  • I am dastels on github.
  • I am dastels (https://keybase.io/dastels) on keybase.
  • I have a public key whose fingerprint is 48AD DACE B8BB 7D4F 3109 315E AC29 FFB7 2601 7396

To claim this, I am signing this object:

@dastels
dastels / gist:0e9d3cf0345bab0f6821
Last active August 29, 2015 14:07
Comparison of NewtonScript and GoLisp
NewtonScript
y := {YMethod: func () print("Y method"),
yVar: 14};
x := {Demo: func () begin
self.newVar := 37;
print(newVar);
self.NewMethod := func () print("hello");
self:NewMethod();
self._parent := y;
@dastels
dastels / gist:ce800d700677b0b3522b
Created June 29, 2014 16:34
rubymotionlisp demo snippet
(main)> Lisp::Initializer.register_builtins
=> #<Lisp::Primitive:0x9490f50 @name="vector" @doc="" @special=false @implementation=#<Proc:0x9490ef0>>
(main)> p = Lisp::Parser.new
=> #<Lisp::Parser:0x9827330>
(main)> p.parse_and_eval("(+ 2 3)").value
=> 5
@dastels
dastels / gist:f0db88a0b756298d4c59
Created June 21, 2014 19:08
And.... there's a repl.
>: bin/rubylisp
RubyLisp REPL
> 4
4
> (+ 2 3)
5
> (define (fib x) (if (eq? x 0) 1 (* x (fib (- x 1)))))
<function: fib>
> (fib 4)
24
@dastels
dastels / gist:cb8c29bc484f7561cb54
Created June 21, 2014 18:21
rubylisp extracted into a freestanding gem
>: irb
2.0.0-p247 :001 > require 'rubylisp'
=> true
2.0.0-p247 :002 > Lisp::Initializer.register_builtins
=> ...
2.0.0-p247 :003 > Lisp::Parser.new.parse('(+ 1 2)').evaluate(Lisp::EnvironmentFrame.global).to_s
=> "3"
@dastels
dastels / expect.rb
Created May 8, 2014 16:27
Add rspec's "expect" syntax to RubyMotion's bacon. Place in your project's spec/helpers/expect.rb
module Bacon
class Context
def expect(obj)
Bacon::Should.new(obj)
end
end
end