Skip to content

Instantly share code, notes, and snippets.

View brentonashworth's full-sized avatar

Brenton Ashworth brentonashworth

View GitHub Profile
@brentonashworth
brentonashworth / clj.rb
Created December 3, 2009 04:59
Ruby Script to run Clojure
#!/usr/bin/env ruby -wKU
JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
JAVA="#{JAVA_HOME}/bin/java"
GIT_ROOT=ENV['GIT_ROOT']
CLJ="/opt/clojure"
LIB="#{GIT_ROOT}/library"
classpath=".:src:test:classes" +
":#{GIT_ROOT}/formpluslogic/fpl-clojure-util/fpl-clojure-util.jar" +
":#{CLJ}/swank-clojure/src/"
@brentonashworth
brentonashworth / test.clj
Created December 3, 2009 06:38
Clojure Test Runner
(ns com.formpluslogic.util.test
(:use [clojure.test]
[clojure.test :only (run-tests)]
[com.formpluslogic.util.file_utils]))
(def test-dir "test")
(def test-file-prefix "test_")
(def test-file-ext ".clj")
(def *logging* false)
@brentonashworth
brentonashworth / gist:574594
Created September 11, 2010 00:21
Sandbar forms
;; Use sandbar to create forms. Create routes, validate input, display error messages,
;; marshal form data, etc. More documentation and examples coming soon.
(defn password-strength [m]
(if (< (count (:password m)) 10)
(add-validation-error m :password properties)
m))
(def validator
(build-validator
(def properties
{:username "Username"
:password "Password"})
(def security-policy
[#"/admin.*" :admin
#"/permission-denied.*" :any
#"/login.*" :any
#".*\.(css|js|png|jpg|gif)$" :any
#".*" #{:admin :user}])
$(function() {
$("#hire-date").datepicker({dateFormat: 'yy-mm-dd'});
});
$(function() {
$("#hire-date").datepicker({dateFormat: 'yy-mm-dd'});
$("#language").autocomplete({source: "langs-autocomplete"});
});
div.sandbar-field {
position: relative;
}
div.sandbar-form div.error-message {
height: 24px;
padding-left: 24px;
background: url(../images/warning.png) no-repeat 4px -2px;
color: red;
vertical-align: bottom;
$(function() {
$("#hire-date").datepicker({dateFormat: 'yy-mm-dd'});
$("#language").autocomplete({source: "langs-starting-with"});
$("#name").blur(function() {
validateField("name");
});
user=> (use 'leibniz.derivative)
nil
user=> (def y '(* (+ (* 3 ?x) 4) (+ (* 4 ?x) 6)))
#'user/y
user=> (def fy (f [?x] y))
#'user/fy
user=> (fy 7)
850
user=> (deriv y ?x)
(+ (* 24 ?x) 34)
@brentonashworth
brentonashworth / gist:904481
Created April 5, 2011 20:32
Polymorphic on return type
{-# LANGUAGE TypeSynonymInstances #-}
class TwoOf a where
twoOf :: String -> a
instance TwoOf Bool where
twoOf str = length str >= 2
instance TwoOf String where
twoOf str = take 2 str