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 / DrawArc.asm
Created October 14, 2011 18:43 — forked from kragen/DrawArc.asm
;-----------------------------------------------------------
;
; --> DRAWARC.TEXT
;
; Routine to draw solid or hollow Ovals, RoundRects or Arcs.
;
;------------------------------------------------------
;
@fogus
fogus / chess.rb
Created October 18, 2011 18:40 — forked from daveray/chess.rb
Joy of Clojure Chess Example in Familiar/JRuby
# Rough translation from Joy of Clojure refs example in Familiar
# https://github.com/daveray/familiar
# https://github.com/joyofclojure/book-source/blob/master/src/joy/refs.clj
$initial_board = [[:o, :k, :o],
[:o, :o, :o],
[:o, :K, :o]].to_clojure
# (defn board-map [f bd]
# (vec (map #(vec (for [s %] (f s))) bd)))
@fogus
fogus / syntax.rkt
Created October 21, 2011 16:14 — forked from samth/syntax.rkt
Programming with syntax in Typed Racket
#lang typed/racket
(: stx Syntax)
(define stx #'bar)
(syntax-case stx ()
[foo (identifier? #'foo) (symbol=? 'bar (syntax-e #'foo))]
[_ (error 'whoops)])
@fogus
fogus / ->_.clj
Created October 25, 2011 01:31 — forked from MayDaniel/->_.clj
(use 'clojure.walk)
(defmacro ->_
"Threads the forms, replacing underscores with the result of the last expression."
([x] x)
([x form] (if (seq? form)
(with-meta (postwalk-replace {'_ x} form) (meta form))
(list form x)))
([x form & more] `(->_ (->_ ~x ~form) ~@more)))
@fogus
fogus / cells.clj
Created October 25, 2011 12:36 — forked from richhickey/cells.clj
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
@fogus
fogus / core.clj
Created October 26, 2011 01:48 — forked from hiredman/core.clj
srepl.clj
(ns srepl.core
(:use [clojure.main :only [repl]]
[clojure.pprint :only [pprint with-pprint-dispatch code-dispatch]])
(:import (jline.console ConsoleReader)
(jline.console.completer Completer))
(:gen-class))
(defmulti super-dispatch class)
(defmethod super-dispatch :default [thing]
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-October/thread.html#17696
const className = superClass <| function(/*constructor parameters */) {
//constructor body
super.constructor(/*arguments to super constructor */);
this.{
//per instance property definitions
};
}.prototype.{
//instance properties defined on prototype
// Here is a proposal for minimalist JavaScript classes, humbly offered.
// There are (at least) two different directions in which classes can be steered.
// If we go for a wholly new semantics and implementation, then fancier classical
// inheritance can be supported with parallel prototype chains for true inheritance
// of properties at both the class and instance level.
// If however, we keep current JavaScript prototype semantics, and add a form that
// can desugar to ES3, things must necessarily stay simpler. This is the direction
// I'm assuming here.
@fogus
fogus / database.prolog
Created November 3, 2011 18:13 — forked from anonymous/database.lgt
Meta-Programming in Prolog - Part 1
:- object(database).
:- public(rule/2).
nat(zero) :- true.
nat(s(X)) :- nat(X).
add(zero, Y, Y) :- true.
add(s(X), Y, s(Z)) :-
add(X, Y, Z).
@fogus
fogus / gist:1377358
Created November 18, 2011 18:45 — forked from hugoduncan/gist:1377108
Alternate cache protocol
(ns pallet.cache.impl
"An implementation namespace for pallet.cache")
(defprotocol CacheProtocolImpl
"Cache implementation interface."
(lookup [cache e] [cache e default]
"Retrieve the value associated with `e` if it exists")
(has? [cache e]
"Checks if the cache contains a value associtaed with `e`"))