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
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@fogus
fogus / GetTimeline.groovy
Created January 1, 2012 21:22 — forked from founddrama/GetTimeline.groovy
Goodreads.com reading timeline (stub)
#!/usr/bin/env groovy
import static java.util.Calendar.YEAR
import groovy.text.SimpleTemplateEngine
def usage = """\nUSAGE:
Give it your API key, your Goodreads.com user ID, and the name of the shelf
you want to convert into a timeline:
./GetTimeline.groovy api_key user_id [shelf-name]
@fogus
fogus / core.clj
Created January 1, 2012 23:26 — forked from hiredman/core.clj
(ns match.core
(:use [clojure.core.logic.unify :only [unifier unifier* binding-map
binding-map* prep replace-lvar
lvarq-sym? rem-?]]
[clojure.walk :only [postwalk]])
(:require [clojure.core.logic.minikanren :as mk]))
;;borrowed from contrib, thanks steve
(defmacro cond-let
"Takes a binding-form and a set of test/expr pairs. Evaluates each test
@fogus
fogus / SECD.hs
Created January 1, 2012 23:36 — forked from jozip/SECD.hs
A family of SECD variants
-- Based on "A Rational Deconstruction of Landin's SECD Machine" by Olivier Danvy
-- (BRICS-RS-03-33)
module SECD where
import Data.Maybe
type Ident = String
type Env a = [(Ident, a)]
;; As a goal
;; Non-relational
;; Accepts these patterns of arguments:
;; IOO
;; III
;; IOI
;; IIO
;; I=input (ground), O=output (not ground)
@fogus
fogus / cinc.md
Created January 4, 2012 02:43 — forked from frenchy64/cinc.md
Clojure vault
@fogus
fogus / core.clj
Created January 4, 2012 02:52 — forked from hiredman/core.clj
defbean
(ns pharoh.core
(:import #_(org.drools.compiler DrlParser)
#_(org.drools.spi Consequence)
(java.beans PropertyChangeSupport)))
(definterface IBean
(init [])
(addPropertyChangeListener [pcl])
(removePropertyChangeListener [pcl]))
@fogus
fogus / treap.ml
Created January 4, 2012 03:08 — forked from superbobry/treap.ml
basic treap implementation
(** Task X: Treap. *)
module Treap = struct
type ('a, 'b) t =
| Empty
| Node of ('a, 'b) t * 'a * 'b * ('a, 'b) t
let empty = Empty
let rec merge l r = match (l, r) with
@fogus
fogus / gist:1558291
Created January 4, 2012 03:11 — forked from palladin/gist:1085027
Clojure's Atoms
open System.Threading
type Atom<'T when 'T : not struct>(value : 'T) =
let refCell = ref value
let rec swap f =
let currentValue = !refCell
let result = Interlocked.CompareExchange<'T>(refCell, f currentValue, currentValue)
if obj.ReferenceEquals(result, currentValue) then ()
else Thread.SpinWait 20; swap f
@fogus
fogus / goodreads_csv_filter.rb
Created January 4, 2012 03:11 — forked from rgreenjr/goodreads_csv_filter.rb
Trims Goodreads CSV files so they import into Delicious Library essential data only.
#!/usr/bin/env ruby -w
#
# Trims Goodreads CSV files so they import into Delicious Library essential data only.
#
require 'rubygems'
require 'faster_csv'
path = ARGV.empty? ? "/Users/rgreen/Downloads/goodreads_export.csv" : ARGV[0]