Skip to content

Instantly share code, notes, and snippets.

View orb's full-sized avatar

Norman Richards orb

View GitHub Profile
@orb
orb / once.clj
Created February 28, 2014 15:39
a core.logic query occurs-onceo that states that x occurs exactly one time in xs
(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)
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
(def matches
{:a {:a "foo" :b "bar"}
:b {:a "blue" :b {:a "fred" :b "bob"}}})
(defn winner [node]
(if (map? node)
(:winner node)
node))
(defn select-winner [node aorb]
(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))))
@orb
orb / context.xml
Last active August 29, 2015 14:02
<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
orb / myapp
Last active August 29, 2015 14:04
generic nginx proxy
upstream myapp {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://myapp;
proxy_read_timeout 180;
@orb
orb / jaspertest-core.clj
Last active August 29, 2015 14:06
jasper clojure
(ns jaspertest.core
(:import [net.sf.jasperreports.engine JasperFillManager JasperExportManager JasperCompileManager])
(:require [clojure.java.io :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
@orb
orb / Game.java
Last active August 29, 2015 14:08
public class Game {
// https://gist.github.com/orb/
public static void main(String[] args) {
char[][] board = new char[20][40];
initBoard(board);
int x = 5;
int y = 5;
int xspeed = 1;
int yspeed = -1;
@orb
orb / lesson1.hs
Created October 25, 2014 02:02
haskell 1
-- exercise 1
toDigitsRev n = if (n <= 0)
then []
else (n `mod` 10) : (toDigitsRev (n `div` 10))
toDigits = reverse . toDigitsRev
-- exercise 2