Skip to content

Instantly share code, notes, and snippets.

View christianromney's full-sized avatar
🏠
Working from home

Christian Romney christianromney

🏠
Working from home
View GitHub Profile
(def path-element (s/or :key keyword? :index integer?))
(s/def :column/title string?)
(s/def :column/spec (s/or :path (s/+ path-element)
:path+keys (s/cat :path (s/* path-element)
:keys (s/coll-of keyword? []))
:path+fn (s/cat :path (s/* path-element)
:fn fn?)
:fn fn?))
(s/def ::column (s/keys :req [:column/title :column/spec]))
(s/def :grid/title string?)
{:product/type :product.type/ebp
:product/name "Teen Intervene"
:product/surveys
[{:survey/type :survey.type/pre
:survey/title "Pre-Test"
:survey/version 3
:survey/questions
[{:question/id 2030
:question/text "Do you smoke?"
:question/type :question.type/single-option
@christianromney
christianromney / map-reduce.js
Last active May 27, 2016 11:27
Functional Programming example: Implementing `map` in terms of `reduce`
// implementing map in terms of reduce
function count(coll) {
return (typeof coll === "undefined") ? 0 : coll.length;
}
function isEmpty(coll) {
return (0 === count(coll));
}
(def github-repositories-url "https://api.github.com/search/repositories")
(defn repositories-req [language]
(go (let [response (<! (http/get github-repositories-url
{:with-credentials? false
:query-params {"q" (str "language:" language)
"sort" "stars"
"order" "desc"}}))]
;; just *use* the value inside this block...
(println (get-in response [:body :items]))))
# (c) 2016 Mario Cruz
# please credit me if you modify and/or use this code
# not for commercial use
# lots of help from Giles Booth @blogmywiki
# and Christian Romney Twitter: @christianromney
import os
import glob
import json
import random
# (c) 2016 Mario Cruz
# please credit me if you modify and/or use this code
# not for commercial use
# lots of help from Giles Booth @blogmywiki
# and Christian Romney Twitter: @christianromney
import os
import glob
import json
import random
{"title": "Fire and Ice",
"author": "Robert Frost",
"text": ["Some say the world will end in fire,",
"Some say in ice.",
"From what I've tasted of desire,",
"I hold with those who favor fire.",
"But if I had to perish twice,",
"I think I know enough of hate",
"To say that for destruction ice",
"Is also great",
# (c) 2016 Mario Cruz
# please credit me if you modify and/or use this code
# not for commercial use
# lots of help from Giles Booth @blogmywiki
import os
import glob
import json
import random
import printer
{"title": "Fire and Ice"
"author": "Robert Frost"
"text": ["Some say the world will end in fire,",
"Some say in ice.",
"From what I've tasted of desire,",
"I hold with those who favor fire.",
"But if I had to perish twice,",
"I think I know enough of hate",
"To say that for destruction ice",
"Is also great",
# (c) 2016 Mario Cruz
# please credit me if you modify and/or use this code
# not for commercial use
# lots of help from Giles Booth @blogmywiki
from random import *
from printer import *
from PIL import Image
import os
import glob
import json