Skip to content

Instantly share code, notes, and snippets.

View leobm's full-sized avatar

Felix Wittmann leobm

  • Hamburg, Germany
View GitHub Profile
@leobm
leobm / gist:5013347
Created February 22, 2013 13:23 — forked from jerrypnz/poll.rkt
#lang racket
(require web-server/http
web-server/managers/none
web-server/servlet
web-server/servlet-env)
(provide interface-version manager star-polling-app)
(define interface-version 'v2)
(defmacro def-curry-fn [name args & body]
{:pre [(not-any? #{'&} args)]}
(if (empty? args)
`(defn ~name ~args ~@body)
(let [rec-funcs (reduce (fn [l v]
`(letfn [(helper#
([] helper#)
([x#] (let [~v x#] ~l))
([x# & rest#] (let [~v x#]
(apply (helper# x#) rest#))))]
#!/bin/sh -x
cd /tmp
if [ ! -d "geocouch" ]; then
git clone https://github.com/couchbase/geocouch.git
fi
cd geocouch
git checkout couchdb1.2.x
(ns algos.dijkstra
(use '[clojure.contrib.incubator])
)
(declare dijkstra build-path add-rdist update-rdists take-minnode)
(defn shortest-path
([net root nodedst children distance]
/*
* Dependencies: Apache POI Library from http://poi.apache.org/
*/
package poi_excels;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
;; by John Lawrence Aspden - http://www.learningclojure.com/2013/04/destructuring.html
;; Destructuring
;; One of Clojure's great strengths is the ability to create maps ad-hoc and to deal with them easily.
;; You can create an ad-hoc structure with named fields:
{:a 3 :b 1}
;; And unpack it, providing defaults for its values if they are not present, as easily as:
(ns tokenring.core
(:require [lamina.core :as lamina])
(:require [aleph.tcp :as aleph])
(:require [gloss.core :as gloss]))
(defn connect-and-send [message]
(println (str "connecting and sending: " message))
(let [ch (lamina/wait-for-result
(aleph/tcp-client {:host "192.168.48.35"
;;:host "localhost"
(ns test-core-typed.core
(:import (clojure.lang Symbol))
(:require [clojure.core.typed :refer [ann]]))
(ann foo-bar [Symbol -> Number])
(defn foo-bar [a]
(+ a 1))
(ann barbar [Number -> Boolean])
(defn barbar [a]
1) make sure you actually HAVE postgres AND postgis AND plsql!
2) enable postgis extension (may be in a different path or already coming from your distribution)
psql -U YOURUSER -d YOURDB -f /usr/share/postgresql/contrib/postgis-2.0/postgis.sql
or, on psql shell:
CREATE extension postgis;
checkbox :: Bool -> IO (Elem, Signal Bool)
checkbox checked = do
c <- newElem "input"
(p,s) <- emptyPipe
setProp c "type" "checkbox"
sink (\isChecked -> do
setProp c "checked" $ if isChecked then "true" else ""
) s
setCallback c OnChange (do
checked <- getProp c "checked"