Skip to content

Instantly share code, notes, and snippets.

View DanielJomphe's full-sized avatar

Daniel Jomphe DanielJomphe

View GitHub Profile
@dukex
dukex / jasmine.js
Created April 27, 2011 23:45
qUnit Vs Jasmine
describe("accessibility", function () {
beforeEach(function(){
var ac = $('#menu1').menu();
var item0 = $("li:eq(0) a");
});
it("should has menu class", function(){
expect(ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all")).toEqual(true);
});
@iaincarsberg
iaincarsberg / vector2.spec.js
Created July 12, 2011 09:36
Real world usage of Jasmine compared to Qunit
/*global console window describe xdescribe it expect runs waits*/
(function () {
require.paths.unshift(__dirname + '/../../../');
require('thorny/base')('./config/default.json')(function ($) {
describe('a vector2', function () {
it('should contain the following functions', function () {
var vector2 = $('thorny math vector2');
expect(typeof vector2.factory).toEqual('function');
expect(typeof vector2.centroid).toEqual('function');
@ibdknox
ibdknox / alephNoir.clj
Created October 2, 2011 19:53
aleph and noir
(require '[noir.server :as server])
(use 'noir.core 'aleph.http 'lamina.core)
(defn async-response [response-channel request]
(enqueue response-channel
{:status 200
:headers {"content-type" "text/plain"}
:body "async response"}))
(defpage "/" [] "hey from Noir!")
@spulec
spulec / pre-commit
Last active January 13, 2023 02:26
Yipit Pre-commit Hook
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^[MA]\s+(?P<name>.*)$')
CHECKS = [
@stuarthalloway
stuarthalloway / gist:1980351
Created March 5, 2012 18:56
frinj unit conversion running inside a Datomic datalog query
;; lein settings
(defproject foo "1.0.0-SNAPSHOT"
:description "Test App"
:dependencies [[com.datomic/datomic "0.1.2678"]
[frinj "0.1.2" :exclusions [org.clojure/clojure]]])
;; load libs
(use 'frinj.core 'frinj.calc)
(frinj-init!)
(use '[datomic.api :only (q db) :as d])
@weavejester
weavejester / gist:1982807
Created March 6, 2012 01:47
Initial thoughts on Datomic

Initial thoughts on Datomic

Rich Hickey (of [Clojure][1] fame) has released a cloud-based database called [Datomic][2] that has some interesting properties.

Datomic is an log of assertions and retractions of "facts", much as a DVCS like [Git][3] is a log of code diffs. The state of the database at any one time is the sum of all the assertions and retractions up to that date.

@alandipert
alandipert / flp.clj
Created March 20, 2012 04:18
Function-level programming a la Backus
(ns flp
"Function-level programming a la Backus; see
http://www.stanford.edu/class/cs242/readings/backus.pdf"
(:refer-clojure :exclude [/]))
;;; Functional Forms - combine existing functions to form new ones.
(def ^{:doc "Composition"} ° comp)
(defn / [f]
@swannodette
swannodette / example-user.clj
Created May 4, 2012 11:39 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
(defn validates-credentials [username password]
(let [uc (count username)
pc (count password)]
(match [username uc password pc]
[(:or nil "") _ _ _] {:error "No username given" :field "name"}
[_ _ (:or nil "") _] {:error "No password given" :field "pass"}
[_ (_ :guard #(< % 3)) _ _] {:error "Username less than 3 characters" :field "pass"}
[_ _ _ (_ :guard #(< % 4))] {:error "Password less than 4 characters" :field "pass"}
[#"^([a-z0-9-_]+)$" _ _ _] {:error "Username contains invalid characters" :field "name"}
:else true)))
@stuarthalloway
stuarthalloway / gist:2645453
Created May 9, 2012 15:22
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@stuarthalloway
stuarthalloway / gist:2651196
Created May 10, 2012 05:22
Datomic queries against Java collections
// Datomic example code
package datomic.examples;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import static datomic.Peer.*;