Skip to content

Instantly share code, notes, and snippets.


Norman Richards orb

View GitHub Profile
orb / once.clj
Created Feb 28, 2014
a core.logic query occurs-onceo that states that x occurs exactly one time in xs
View once.clj
(ns logic.once
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.fd :as fd]))
(defne occurs-noneo [x xs]
([x []])
([x [y . ys]]
(!= y x)
View job test
Infortunately I am unable at accept this pull request because it fails one of my unit tests.
test.job> (fact "job is in the correct city"
(let [job {:company "Amazon" :location :seattle}]
(:location job) => :austin))
FAIL "job is in the correct city" at (form-init8310622436901647370.clj:3)
Expected: :austin
Actual: :seattle
View winner.clj
(def matches
{:a {:a "foo" :b "bar"}
:b {:a "blue" :b {:a "fred" :b "bob"}}})
(defn winner [node]
(if (map? node)
(:winner node)
(defn select-winner [node aorb]
View timer.clj
(defn find-timer [timer-name]
(timers/timer ["APPNAME" "timer" (name timer-name)]))
(defmacro with-timer [timer-name & body]
`(let [timer# (find-timer ~timer-name)]
(timers/time! timer#
(do ~@body))))
View context.xml
<Resource name="jdbc/QuoteDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="SA" password=""
driverClassName="org.hsqldb.jdbc.JDBCDriver" url="jdbc:hsqldb:hsql://localhost:9001/" />
public class Marker {
public String color;
public String tip;
public Marker(String color, String tip) {
this.color = color;
this.tip = tip;
public void write() {
orb / myapp
Last active Aug 29, 2015
generic nginx proxy
View myapp
upstream myapp {
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://myapp;
proxy_read_timeout 180;
orb / jaspertest-core.clj
Last active Aug 29, 2015
jasper clojure
View jaspertest-core.clj
(ns jaspertest.core
(:import [net.sf.jasperreports.engine JasperFillManager JasperExportManager JasperCompileManager])
(:require [ :as io]))
(defn java-hashmap [results-map]
(let [hashmap-reducer (fn [m [k v]] (doto m (.put (name k) v)))]
(reduce hashmap-reducer (java.util.HashMap.) results-map)))
(def mock-data
public class Game {
public static void main(String[] args) {
char[][] board = new char[20][40];
int x = 5;
int y = 5;
int xspeed = 1;
int yspeed = -1;
View lesson1.hs
-- exercise 1
toDigitsRev n = if (n <= 0)
then []
else (n `mod` 10) : (toDigitsRev (n `div` 10))
toDigits = reverse . toDigitsRev
-- exercise 2
You can’t perform that action at this time.