Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Thomas thomas-shares

🏠
Working from home
  • Gouda
View GitHub Profile
@thomas-shares
thomas-shares / gist:048fdb2eabac62844074
Last active Aug 29, 2015
How many ways are there to say "morning" in Clojure?
View gist:048fdb2eabac62844074
(->> ((->> [0 2 5 1 -4 1 -6] (map #(partial + %)) (apply juxt)) 109) byte-array (String.))`
morning
(loop [txt ""] (if (= 1803412773 (hash txt)) txt (recur (apply str (repeatedly 7 (fn [] (char (rand-nth [114 105 110 111 109 103]))))))))
(->> "bW9ybmluZw=="
.getBytes
(.decode (java.util.Base64/getDecoder))
(new String))
@thomas-shares
thomas-shares / gist:8a7bb265198f2b735daa
Created May 26, 2015
Rules engine. ThoughtWorks Clojure DOJO
View gist:8a7bb265198f2b735daa
(ns twrule.core)
;; A is the B
;; fact: '(father a b )
(def facts #{'(father andrew bob) '(father bob charlie)})
;; Grandfather rule: if A is the father of B, and B is the father of C then A is the Grandfather C
(def rules [{:patterns ['(father ?a ?b) '(father ?b ?C)]
:assertions ['(grandfather ?a ?C)]}])
@thomas-shares
thomas-shares / gist:62f9bb2a2fa67ec5b517
Last active Aug 29, 2015
trying to set up a OSM map with a marker
View gist:62f9bb2a2fa67ec5b517
;; The problem is that the text in :element of over-lay gets interpreted as text, not really
;; surprising at the moment as it is text, but I don't know what to do with it so that it
;; works like in the example: http://artarmstrong.com/blog/2014/10/28/openlayers-3-custom-markers-by-latitude-longitude/
(ns clojurescript-apis.core
(:require-macros [hiccups.core :as h]
[cljs.core.async.macros :as m :refer [go alt!]])
(:require [clojure.browser.repl :as repl]
[domina :as dom]
[hiccups.runtime :as hiccupsrt]
@thomas-shares
thomas-shares / gist:3277803
Created Aug 6, 2012
FizzBuzz, but functional
View gist:3277803
(def three (cycle [nil nil "fizz"]))
(def five (cycle [nil nil nil nil "buzz"]))
(map vector (range 1 16) three five )
;([1 nil nil] [2 nil nil] [3 "fizz" nil] [4 nil nil] [5 nil "buzz"] [6 "fizz" nil] [7 nil nil] [8 nil nil] [9 "fizz" nil] [10 nil "buzz"] [11 nil nil] [12 "fizz" nil] [13 nil nil] [14 nil nil] [15 "fizz" "buzz"])
@thomas-shares
thomas-shares / permutations.clj
Created Apr 11, 2012
Permutations and same start/end
View permutations.clj
(ns diversen.permutations)
(use 'clojure.math.combinatorics)
(def things '[:a :b :c])
(map #(conj % (last %) ) (permutations things))
;; ((:c :a :b :c) (:b :a :c :b) (:c :b :a :c) (:a :b :c :a) (:b :c :a :b) (:a :c :b :a))
You can’t perform that action at this time.