Skip to content

Instantly share code, notes, and snippets.

View stathissideris's full-sized avatar

Stathis Sideris stathissideris

  • London
View GitHub Profile
(defn zipify [value pattern]
(loop [[value-zipper pattern-zipper :as both-zippers] (map #(z/zipper coll? seq {} [%]) [value pattern])
result (transient {})]
(let [[value-node pattern-node :as both-nodes] (map z/node both-zippers)]
(condp apply [z/end? both-zippers]
every? (when (seq both-zippers) (persistent! result)) ;;both zippers exhausted at the same time, result!
some nil ;;reached the end of one of the zippers when the other one still had stuff left
(recur
(cond

Recent improvements to the ClojureScript compiler have greatly simplified setting up development versus production outputs.

This example uses Figwheel as something that you want to exclude for production, but the pattern is general.

With this simple setup you only need one html file/view and it will work for developement and production.

/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
(defn mapify
"Return a seq of maps like {:name \"Edward Cullen\" :glitter-index 10}"
[rows]
(let [headers (map (comp conversions headers->keywords) (first rows))]
(for [row (rest rows)] (zipmap headers row))))
@stathissideris
stathissideris / datomic_clojure_collections.clj
Last active August 29, 2015 14:02 — forked from stuarthalloway/gist:2645453
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@stathissideris
stathissideris / gist:3705914
Created September 12, 2012 10:51 — forked from Chouser/gist:3687532
Lazy seq as event subscription mechanism
;; Here is a spike of a lightweight in-process pubsub mechanism that allows pure ;; functional consumers, both blocking and asynchronous.
;; This defines the event stream, in this case just a series of numbers,
;; a new one produced each second
(defn timer []
(lazy-seq
(do
(Thread/sleep 1000)
(cons (System/nanoTime) (timer)))))