Skip to content

Instantly share code, notes, and snippets.

View rgm's full-sized avatar

Ryan McCuaig rgm

View GitHub Profile
@rgm
rgm / stamp-icon.rb
Last active September 11, 2023 12:40
Add the current version and build number on your iOS app icon
#!/usr/bin/env ruby
# Requires ImageMagick: `brew install imagemagick`
# Requires version.sh from https://gist.github.com/osteslag/1089407
#
# Set RGM_STAMP_VERSION_ON_ICONS=1 in your build settings to enable/disable
# stamping on Debug/Relase configurations.
#
# Make base unstamped versions Icon.base.png, &c. in the source tree. The
# script will make stamped versions Icon.png, &c. It relies on Xcode to copy
1. 6:36:14 UBC Triathlon Club ( 39:38)
2. 6:42:49 ICBC Head Office ( 40:17)
3. 6:48:07 HootSuite ( 40:49)
4. 6:56:15 Knight Piesold Ltd ( 41:38)
5. 7:04:21 Ainsworth Engineered ( 42:27)
6. 7:04:29 PMC Sierra ( 42:27)
7. 7:05:11 TELUS Lemurs ( 42:32)
8. 7:06:34 BGC ENGINEERING ( 42:40)
9. 7:07:06 SD#23 SUNRUNNERS ( 42:43)
10. 7:10:26 Ledcor Group ( 43:03)
@rgm
rgm / gist:8627518
Last active January 4, 2016 13:19
Floyd's algorithm for SICP exercise 3.19
(define (has-cycle? ls)
(define (has-cycle-h tortoise hare)
(cond ((null? hare) #f)
((null? (cdr hare)) #f)
((eq? (car tortoise) (car hare)) #t)
(else
(has-cycle-h (cdr tortoise) (cddr hare)))))
(cond ((null? ls) #f)
(else (has-cycle-h ls (cdr ls)))))
@rgm
rgm / gist:8627828
Created January 26, 2014 03:12
SICP lecture 5B 55m00s -> end
;; pure smoke immutable cons
(define cons
(lambda (x y)
(lambda (m) (m x y))))
(define car
(lambda (x)
(x (lambda (a d) a))))
;; SICP 3.3.4 - Constraint system
(define (for-each-except exception procedure list)
(define (loop items)
(cond ((null? items) 'done)
((eq? (car items) exception) (loop (cdr items)))
(else (procedure (car items))
(loop (cdr items)))))
(loop list))
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp) (make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
@rgm
rgm / lazy.diff
Last active August 29, 2015 13:57
diff --git a/metacircular.scm b/metacircular.scm
index 20542d1..97632e5 100644
--- a/metacircular.scm
+++ b/metacircular.scm
@@ -10,26 +10,43 @@
env))
((begin? exp) (eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
- ((application? exp) (apply (eval (operator exp) env)
- (list-of-values (operands exp) env)))
@rgm
rgm / nondeterministic.scm
Created April 4, 2014 02:37
Nondeterministic interpreter of SICP 4.3
(define (eval exp env succeed fail)
((analyze exp) env succeed fail))
(define (analyze exp)
(cond ((self-evaluating? exp) (analyze-self-evaluating exp))
((variable? exp) (analyze-variable exp))
((quoted? exp) (analyze-quoted exp))
((assignment? exp) (analyze-assignment exp))
((definition? exp) (analyze-definition exp))
((if? exp) (analyze-if exp))
@rgm
rgm / analyzing->nondeterministic.diff
Last active August 29, 2015 13:58
changes needed to turn the analyzing interpreter of SICP 4.1 to the nondeterministic interpreter of SICP 4.3
diff --git a/nondeterministic.scm b/nondeterministic.scm
index 1fab899..52e5b73 100644
--- a/nondeterministic.scm
+++ b/nondeterministic.scm
@@ -1,5 +1,5 @@
-(define (eval exp env)
- ((analyze exp) env))
+(define (eval exp env succeed fail)
+ ((analyze exp) env succeed fail))
@rgm
rgm / logic.scm
Created April 24, 2014 16:32
Query interpreter from SICP §4.4
;; SICP 4.4 Query Interpreter
;; http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-29.html#%_sec_4.4
;; scheme -load logic.scm
;; ==================================================
;; 0 table data structure, see 3.3.3
;; ==================================================
(define (make-table)
(let ((local-table (list '*table*)))