Skip to content

Instantly share code, notes, and snippets.

@currentoor
currentoor / reset_component.clj
Last active January 11, 2016 23:21
Reset the components of an entity without worrying about the current values or their entity-ids.
(defn reset-components [db eid attr new-comps]
(let [current-comps (-> (d/pull db [attr] eid) attr)
;; First we do a value based comparison ignoring component entity ids.
current-comp-vals (into #{} (map #(dissoc % :db/id) current-comps))
new-comp-vals (into #{} new-comps)
deletions (clojure.set/difference current-comp-vals new-comp-vals)
additions (clojure.set/difference new-comp-vals current-comp-vals)
@bartojs
bartojs / profile.boot
Created December 3, 2015 01:51
boot clj profile for fmt and lein tasks
(deftask fmt
"fmt file or dir using cljfmt (changes files)"
[f files VAL str "file(s) to format"]
(set-env! :dependencies '[[cljfmt "0.3.0"]])
(require 'cljfmt.core
'clojure.java.io)
(let [reformat-string (resolve 'cljfmt.core/reformat-string)
file (resolve 'clojure.java.io/file)
fmt-file (fn [f]
(println "formatting" (.getName f))
@gtallen1187
gtallen1187 / scar_tissue.md
Created November 1, 2015 23:53
talk given by John Ousterhout about sustaining relationships

"Scar Tissues Make Relationships Wear Out"

04/26/2103. From a lecture by Professor John Ousterhout at Stanford, class CS142.

This is my most touchy-feely thought for the weekend. Here’s the basic idea: It’s really hard to build relationships that last for a long time. If you haven’t discovered this, you will discover this sooner or later. And it's hard both for personal relationships and for business relationships. And to me, it's pretty amazing that two people can stay married for 25 years without killing each other.

[Laughter]

> But honestly, most professional relationships don't last anywhere near that long. The best bands always seem to break up after 2 or 3 years. And business partnerships fall apart, and there's all these problems in these relationships that just don't last. So, why is that? Well, in my view, it’s relationships don't fail because there some single catastrophic event to destroy them, although often there is a single catastrophic event around the the end of the relation

@mikeball
mikeball / core.clj
Last active June 3, 2020 13:22
Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; in project.clj dependencies
; [com.impossibl.pgjdbc-ng/pgjdbc-ng "0.5"]
(ns pglisten.core
(:import [com.impossibl.postgres.jdbc PGDataSource]
[com.impossibl.postgres.api.jdbc PGNotificationListener]))
@vvvvalvalval
vvvvalvalval / mock-connection.clj
Last active September 19, 2018 06:09
Mocking datomic.Connection for fast in-memory testing
(ns bs.utils.mock-connection
"Utilities for using Datomic"
(:require [datomic.api :as d])
(:use clojure.repl clojure.pprint)
(:import (java.util.concurrent BlockingQueue LinkedBlockingDeque)
(datomic Connection)))
(defrecord MockConnection
[dbAtom, ^BlockingQueue txQueue]
@vlinhart
vlinhart / buy_endpoint.json
Last active April 30, 2017 01:16
/buy/ proposed api
// Request POST body - common
{
"seller_site": "http://localhost:8000/backend/v1/sites/28950",
"buyer_site": "http://localhost:8000/backend/v1/sites/1", // the SFO for example, we can't say on backend which site user wants
"start_date": "2015-12-01",
"end_date": "2015-12-02",
"room_guests": {
"room_data": {
"price": 250,
@Deraen
Deraen / silk-data.cljs
Last active August 29, 2015 14:27
Additional data to Silk routes
(deftype AdditionalData [data]
silk/Pattern
(-match [_ _]
data)
(-unmatch [_ _]
nil)
(-match-validator [_]
(constantly true))
(-unmatch-validators [_]
{}))
@martinklepsch
martinklepsch / logging.cljc
Last active July 2, 2024 13:37
simple Clojurescript logging using Google Closure logging tools
;; This previously was CLJX but has now been updated to use cljc. Thanks @caskolkm
;; https://gist.github.com/caskolkm/39d823f5bac7051d3062
(ns app.logging
(:refer-clojure :exclude [time])
(:require #?(:clj [clojure.tools.logging :as log]
:cljs [goog.log :as glog]))
#?(:cljs (:import goog.debug.Console)))
#?(:cljs
@bensu
bensu / maps.cljs
Last active February 1, 2016 21:33
google maps config
(ns component.maps
(:require [google.maps])
(defn map-opts []
"Default initial map options."
{:zoom 3
:mapTypeId google.maps.MapTypeId.ROADMAP
:center (google.maps.LatLng. 59, 18)
:mapTypeControl false
:styles [{:stylers [{:visibility "on"}]}]})
(defui Artist
static IQuery
(query [cl _]
[:db/id :artist/name])
Object
(render [{:keys [props]}]
(dom/div nil (:artist/name props))))
(defui ArtistList
static IQuery