Skip to content

Instantly share code, notes, and snippets.

View apg's full-sized avatar
🐢
Turtle

Andrew Gwozdziewycz apg

🐢
Turtle
View GitHub Profile
(use-modules (cairo))
(define *pi* 3.1415926535897931)
(define *image-operations* (make-hash-table))
(define (register-image-operation name f)
(hash-set! *image-operations* name f))
(register-image-operation 'move
$ ruby1.9.1 error-quine-generator.rb -v python 10 "foo bar"
seed text: foo bar
foo bar
File "/tmp/quine.py", line 1
File "/tmp/quine.py", line 1
^
IndentationError: unexpected indent
@apg
apg / wrapup.md
Created April 20, 2012 14:03
Hack and Tell Wrap up for Round 16

Subject: Rocky had to wrap up his hands after Drago too... (Round 16 Wrap Up)

(While James was out sick^Wabusing the list, I was fighting with my MacBook (5,1) which no longer boots Debian[0]. So, apologies for the wrap up's tardiness, but here we go!)

Hello Hackers-

Thanks to Meetup for hosting us again! If you or someone you know would like to host us, and have room for 75-100+ people, get in

@apg
apg / foob.go
Created April 5, 2012 11:44
Some playing around with go validation ideas.
package main
import (
"errors"
"fmt"
)
type BaseField interface {
NameOf() string
IsOptional() bool
@apg
apg / gist:2216159
Created March 27, 2012 14:04
God Wrote in Lisp
I was taught assembler in my second year of school.
It's kinda like construction work — with a toothpick for a tool.
So when I made my senior year, I threw my code away,
And learned the way to program that I still prefer today.
Now, some folks on the Internet put their faith in C++.
They swear that it's so powerful, it's what God used for us.
And maybe it lets mortals dredge their objects from the C.
But I think that explains why only God can make a tree.
@apg
apg / be.scm
Created February 10, 2012 12:19
(define (game min max)
(let* ((guess (floor (/ (+ min max) 2)))
(hl (begin (format #t "is your number ~a?\n(h)igher/(l)ower/(c)orrect: " guess) (read))))
(cond
((eq? hl 'h) (game guess max))
((eq? hl 'l) (game min guess))
((eq? hl 'c) (format #t "I win!\n"))
(else (game min max)))))
(game 0 100)
@apg
apg / be.scm
Created February 9, 2012 13:05
let-values
;; Suppose you have this function partition which splits a list
;; in two as soon as the predicate p? returns true. It does not
;; include the value that the predicate succeeded on, but values
;; after it are included.
(define (partition cs p?)
(let loop ((l cs)
(accum '()))
(cond
((null? l) (values (reverse accum) '()))
#!/bin/bash
# passadd
if [ -z "$PASSFILE" ]
then
echo "PASSFILE doesn't exist"
exit 1
fi
if [ $# -ne 1 ]
@apg
apg / passadd
Created January 11, 2012 14:42
#!/bin/bash
# passadd
if [ -z "$PASSFILE" ]
then
echo "PASSFILE doesn't exist"
exit 1
fi
if [ $# -ne 1 ]
#!/bin/bash
ps ax | grep "emacs --daemon" | grep -v "grep"
if [ "$?" -eq "1" ]
then
/usr/bin/emacs --daemon
fi
/usr/bin/emacsclient -c $@