Skip to content

Instantly share code, notes, and snippets.

View JonathanGTH's full-sized avatar

Johanan Gonzalez JonathanGTH

View GitHub Profile
def get_if_related_to(id, relationship) do
table("people") |> filter(lambda fn (person) ->
case relationship do
r when r in [:brother, :sister] ->
person[:siblings] |> contains(id)
r when r in [:mother, :father] ->
person[:children] |> contains(id)
r when r in [:son, :daughter] ->
table("people")
|> get(id)
(ns clj-lmdb.core
(:refer-clojure :exclude [get]) ; suppress the shadowing warning
(:require [clojure.core :as core])
(:import [org.fusesource.lmdbjni Database Env]
[org.fusesource.lmdbjni Constants]))
(declare ^:dynamic *txn*)
(declare ^:dynamic *db*)
(defprotocol LMDB
(def open-for-discussion? (atom true))
(def discussion-count (agent 0))
(def discussion-board (ref []))
(def discussion-board-count 3)
(defn open-discussion [duration]
(do (Thread/sleep duration) (swap! open-for-discussion? not)))
(defn add-discussion []
(future
@JonathanGTH
JonathanGTH / Citrusbyte.clj
Created August 8, 2016 06:18
Flatten Arbitrary Arrays in Order
(ns citus-byte)
(defn flatten2
{:static true}
[x]
(letfn [(flat [coll]
(lazy-seq
(when-let [c (seq coll)]
(let [x (first c)]
(if (sequential? x)
(concat (flat x) (flat (rest c)))
@JonathanGTH
JonathanGTH / simplecart_parser.clj
Created June 24, 2016 20:55 — forked from sventech/simplecart_parser.clj
Clojure parser for SimpleCart(js) form POST/GET
(ns webstore.simplecart_parser
(:require [clojure.string :as string]))
;; see github.com/sventech/simplecart-js for tax calculation improvement fork
(def input-params
{"item_quantity_1" "1",
"itemCount" "2",
"item_price_1" "9.99",
"store_name" "Online Store",
"item_name_1" "Awesome Product - MP3",
(ns clj-lmdb.core
(:refer-clojure :exclude [get]) ; suppress the shadowing warning
(:require [clojure.core :as core])
(:import [org.fusesource.lmdbjni Database Env]
[org.fusesource.lmdbjni Constants]))
(declare ^:dynamic *txn*)
(declare ^:dynamic *db*)
(defprotocol LMDB
@JonathanGTH
JonathanGTH / gist:dde758be8a15b93a485d
Created March 28, 2016 05:39
Concurrency-Thead.clj
(def open-for-discussion? (atom true))
(def discussion-count (agent 0))
(def discussion-board (ref []))
(def discussion-board-count 3)
(defn open-discussion [duration]
(do (Thread/sleep duration) (swap! open-for-discussion? not)))
(defn add-discussion []
(future
export const Main = {
render({props, children, context, path}){
return(
<div id="app_container">
<HeaderContainer />
<div id="app_container_yield">
{children}
</div>
</div>