Skip to content

Instantly share code, notes, and snippets.

View frankiesardo's full-sized avatar

Francesco Sardo frankiesardo

View GitHub Profile
@frankiesardo
frankiesardo / count_coins.pl
Created October 3, 2013 12:30
Count the coins kata in prolog
value(1, 1).
value(2, 5).
value(3, 10).
value(4, 25).
value(5, 50).
count_coins(Amount, Ways) :- cc(Amount, Ways, 5).
cc(X, 0, _) :- X < 0.
cc(_, 0, 0).
@frankiesardo
frankiesardo / gist:7254813
Created October 31, 2013 18:45
Harrt Potter Kata desc
To try and encourage more sales of the 5 different Harry
Potter books they sell, a bookshop has decided to offer
discounts of multiple-book purchases.
One copy of any of the five books costs 8 EUR.
If, however, you buy two different books, you get a 5%
discount on those two books.
If you buy 3 different books, you get a 10% discount.
@frankiesardo
frankiesardo / CustomMatchers.java
Created November 15, 2013 19:20
Espresso & Brioche
public class CustomMatchers {
public static Matcher<View> withBackground(final int resourceId) {
return new TypeSafeMatcher<View>() {
@Override
public boolean matchesSafely(View view) {
return sameBitmap(view.getContext(), view.getBackground(), resourceId);
}
@Override
(ns percolation.core
"Currently working for non-recursive, fully specified (no [:*]), attributes only (no limit, defaults etc.) pull api queries."
(:require [datomic.api :as d]))
(def schema
"Percolation specific schema"
[{:db/id #db/id[:db.part/db]
:db/ident :percolator/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
(require '[clojure.java.shell :as shell]
'[clojure.string :as str])
(defn- current-tag []
(let [{:keys [exit out]} (shell/sh "git" "describe" "--tags")]
(when (zero? exit)
(str/trim out))))
(def version
(if-let [tag (current-tag)]
#!/usr/bin/env boot
(set-env!
:dependencies '[[com.datomic/datomic-pro "0.9.5302"]
[com.datomic/datomic-transactor-pro "0.9.5302"]]
:repositories {"my.datomic.com"
{:url "https://my.datomic.com/repo"
:username "..."
:password "..."}})
(defn find-in [m ks]
(loop [path []
ks (seq ks)
m m]
(if ks
(when-let [[k m] (find m (first ks))]
(recur (conj path k) (next ks) m))
[path m])))
(ns example.log)
(defprotocol Logger
(log [this msg]))
(defn map* [f logger]
(reify Logger
(log [this msg] (log logger (f msg)))))
(ns tinylog.core
(:require [clj-http.client :as http]
[cheshire.core :as json]
[clojure.core.async :as async]))
(defprotocol Logger
(log [this msg]))
(defn map* [f logger]
(reify Logger
{:paths ["/"]
:deps {}}