Skip to content

Instantly share code, notes, and snippets.

View ToddG's full-sized avatar

ToddG ToddG

View GitHub Profile
(ns web01.core
(:import
java.util.Map
java.util.HashMap
[java.io File InputStream]
[clojure.lang IDeref IFn ISeq])
(:use
compojure.core,
ring.adapter.jetty
clojure.contrib.json.read
@ToddG
ToddG / basic_binary_search_tree
Created December 4, 2010 06:31
Basic Binary Search Tree
(ns algorithms.core
(:use clojure.test))
;; -----------------------------------------------------------------------------
;; A simple BST implemented in Clojure using both defrecord and defprotocol.
;; Note the use of the unwind function to update the graph after each insertion.
;;
;; References:
;;
;; BST/Clojure
@ToddG
ToddG / diningphilosopher.clj
Created December 28, 2010 23:50
Dining Philosopher Problem
(ns algorithms.problems.diningphilosophers)
; ----------------------------------------------
; Dining Philosopher Problem
;
; This implementation satisfies the following story
; line:
;
; Our waiters set several tables of various
; sizes for dinner. One by one, the various hungry
@ToddG
ToddG / speedtest1.clj
Created December 29, 2010 05:02
Testing Mark's NonBlockingHashMap
(ns justforfun.speedtest1
(:use justforfun.NonBlockingHashMap))
(set! *warn-on-reflection* true)
;; I've simply extended Mark Engelberg's test code for his NonBlockingHashMap and
;; included my test results -- TDG
(defmacro xtime
"Evaluates expr and returns the time."
@ToddG
ToddG / dynamic_file.erl
Created May 2, 2011 05:49
file performance testing
-module(dynamic_file).
%% notes:
%% http://www.matisse.net/bitcalc/?input_amount=17179869184&input_units=bits&notation=legacy
%% http://20bits.com/articles/network-programming-in-erlang/
%% ------------------------------------------------------------------
%% API Function Exports
%% ------------------------------------------------------------------
@ToddG
ToddG / abc.erl
Created May 8, 2011 17:06
example of a dynamic list
%% -*- mode: nitrogen -*-
-module (abc).
-compile(export_all).
-include_lib("nitrogen_core/include/wf.hrl").
-include("records.hrl").
main() -> #template { file="./site/templates/bare.html" }.
title() -> "Hello from abc.erl!".
@ToddG
ToddG / capitalize.erl
Created June 7, 2011 05:38
Capitalize and CamelCase Words
-module(capitalize).
-behaviour(gen_server).
-define(SERVER, ?MODULE).
-include_lib("eunit/include/eunit.hrl").
%% ------------------------------------------------------------------
%% API Function Exports
%% ------------------------------------------------------------------
-export([
@ToddG
ToddG / blog.html
Created July 4, 2011 02:28
working html5 video tag in a static html file
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Chapter 1 Examples</title>
<style type="text/css">
header,nav,footer,article {display:block;}
nav {float:left; width:20%;}
article {float:right; width:79%;}
footer {clear:both;}
@ToddG
ToddG / mypage.erl
Created July 4, 2011 02:39
nitrogen framework web page with html5 video tag
%% -*- mode: nitrogen -*-
-module (mypage).
-compile(export_all).
-include_lib("nitrogen_core/include/wf.hrl").
-include("records.hrl").
main() -> #template { file="./site/templates/html5.html" }.
title() -> "Todd's <b>Html5</b> Page".
@ToddG
ToddG / mypage.erl
Created July 4, 2011 17:06
ordering issues w/wiring in nitrogen
%% -*- mode: nitrogen -*-
-module (myraphaelpage).
-compile(export_all).
-include_lib("nitrogen_core/include/wf.hrl").
-include_lib("nitrogen_core/include/google_chart.hrl").
-include("records.hrl").
main() -> #template { file="./site/templates/raphael.html" }.
title() -> "Todd's <b>Raphael</b> Page".