Skip to content

Instantly share code, notes, and snippets.

View fogus's full-sized avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
@fogus
fogus / facts.lua
Created November 20, 2011 02:52 — forked from randrews/facts.lua
Make Lua look like Prolog!
----------------------------------------------------------------------------------------------------
--- Making Lua look like Prolog:
---
--- Let's use metatables for something other than emulating prototype-based OO. By making the
--- __index metamethod create values for undefined things, we can make Lua look like Prolog!
--- We create empty tables for anything starting with a capital letter, functions that populate
--- those tables for lowercase things (to assign relationships) and if a name begins with "is_"
--- then it becomes a function that queries those tables.
----------------------------------------------------------------------------------------------------
(defn push-wrap [v wrap & args]
(alter-var-root v #(with-meta (apply wrap % args) {::orig %})))
(defn pop-wrap [v]
(alter-var-root v #(if-let [m (::orig (meta %))] m %)))
(defn post [orig post-printer]
(fn [& args]
(let [rtn (apply orig args)]
(post-printer orig rtn args)
@fogus
fogus / HelloDartTest.dart
Created November 23, 2011 19:01 — forked from munificent/HelloDartTest.dart
Dart Compilation
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// Compiled using frog, the in-progress self-hosted compiler:
// dart/frog$ ./frogsh --out=hello.js --compile-only samples/hello.dart
class HelloDartTest {
static testMain() {
@fogus
fogus / hacklog.textile
Created November 23, 2011 19:07 — forked from candera/hacklog.textile
Hack Log

This is my score for the “One Hundred Days of Hacking” game. Rules here.

Date Score Commit Comment
2011-Nov-30 10 51f854e baysick
2011-Nov-29 9 527e76c accession
2011-Nov-28 8 d2c7a26 core.cache
2011-Nov-27 7 9bdf608 core.memoize
2011-Nov-26 6 72af911 minderbinder
2011-Nov-25 5 736ed99 core.cache
2011-Nov-24 4 a1021d6 clojurescript
@fogus
fogus / giant-steps.clj
Created November 24, 2011 17:12 — forked from daveray/giant-steps.clj
First chorus of Giant Steps solo by Overtone
; TODO
; Incorporate changes
; Convert to concert pitch
; Convert to correct octave
(use 'overtone.live)
(definst beep [note 60 vol 0.5]
(let [freq (midicps note)
src (sin-osc freq)
@fogus
fogus / vpm_opt_bench.scala
Created November 30, 2011 14:55 — forked from adriaanm/vpm_opt_bench.scala
virtpatmat compilation of a match and various hand-coded optimizations
import improving.benchmark.Benchmark.Race
val list = List(1, 3, 4, 7)
val race = Race(() => fastMatch(list), () => virtMatch_no_option(list))(100000).converge()
def fastMatch(x1: List[Int]) = {
x1 match {
case 1 :: 3 :: 4 :: 5 :: x => println("nope")
case 1 :: 3 :: 4 :: 6 :: x => println("nope") // only need to test whether the previous case failed due to the third element not being 5, and whether third element is 6
@fogus
fogus / let.clj
Created December 7, 2011 14:04 — forked from sritchie/let.clj
(defmacro let?
[bindings & body]
(let [[bind [kwd pred & more]] (split-with (complement #{:ensure}) bindings)]
`(let [~@bind]
~@(cond (and kwd more) [`(when ~pred (check-let [~@more] ~@body))]
kwd [`(when ~pred ~@body)]
:else body))))
(let? [x 100
y 300
@fogus
fogus / gist:1447924
Created December 8, 2011 18:22 — forked from swannodette/gist:1447808
hard.clj
(defn anyo [g]
(conde
[g succeed]
[(anyo g)]))
(def nevero (anyo fail))
(run* [q]
(conde
[nevero]
@fogus
fogus / bells.clj
Created December 12, 2011 15:19 — forked from jennifersmith/bells.clj
Cheesy Holiday Music and bell synthesis example
(ns overtone-xmas.bells
( :use [overtone.live]
[overtone.sc.machinery.defcgen]))
;;http://computermusicresource.com/Simple.bell.tutorial.html
(def dull-partials
[
0.56
@fogus
fogus / bells.clj
Created December 13, 2011 18:51 — forked from jennifersmith/bells.clj
Cheesy Holiday Music and bell synthesis example
(ns overtone-xmas.bells
( :use [overtone.live]
[overtone.sc.machinery.defcgen]))
;;http://computermusicresource.com/Simple.bell.tutorial.html
(def dull-partials
[
0.56