Skip to content

Instantly share code, notes, and snippets.

@dadair-ca
dadair-ca / gist:f490e9a63d1d771b5eeb
Last active March 22, 2020 13:00
Eco Public API Reverse Engineering
View gist:f490e9a63d1d771b5eeb
;; Hourly from yesterday morning up to current hour
http://www.eco-public.com/api/h7q239dd/data/periode/101017181/?begin=20150509&end=20150510&step=3
;; Totals from yesterday and (so far?) today
http://www.eco-public.com/api/h7q239dd/data/periode/101017181/?begin=20150509&end=20150510&step=4
;; Hourly for yesterday
http://www.eco-public.com/api/h7q239dd/data/periode/101017181/?begin=20150509&end=20150509&step=3
;; Hourly for today
View clojure_decorator.clj
;; Let's say we have a function `foo`, that we want to decorate with logging:
(defn foo [x]
(inc x))
;; First, let's change the name to suggest an impl:
(defn foo* [x]
(inc x))
View R-parse-JS-date.R
mydate <- strptime('Mon Dec 09 2019 13:35:10 GMT-0700',
format='%a %b %d %Y %H:%M:%S GMT%z')
View logging_context.clj
(defprotocol Logging
(log [logger data]))
(def ^:dynamic *logger*
(reify Logging
(log [this data]
(clojure.pprint/pprint data))))
(def request-data {::request-id 1 ::request-source "someone"})
View fhirbase-CTEs.sql
WITH inserted AS (
SELECT fhir_create_resource(:resource) AS resource -- should end up inserting into `encounter` table
), joined_foo AS (
INSERT INTO foo(x) SELECT resource->'id' FROM inserted
RETURNING *
), joined_bar AS (
INSERT INTO bar(x) SELECT resource->'id' FROM inserted
RETURNING *
) SELECT resource FROM inserted;
@dadair-ca
dadair-ca / example.clj
Last active October 2, 2016 19:52
core async processing improvements
View example.clj
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Forecast generation
(defn inst->forecasts [inst]
(for [r (range 1 25)]
[(c/to-sql-time (t/plus (without-minutes inst) (t/hours r))) (rand-int 50)]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Async
@dadair-ca
dadair-ca / description.md
Created September 27, 2016 01:55
Clojure postgresql enum type conversion
View description.md

Given an enum type e_role, being represented in clojure-land as a string, use the enum in a query and typecast inside it.

Note the ?::e_role:

INSERT INTO accounts (account_id, email, password, account_role)
       VALUES (DEFAULT, :email, :password, ?::e_role);

Use positional arguments for the enum(s) (note the :? [..]):

View console output
--- jwt ---
nil
Starting HTTP server on port nil
{:app
{:middleware
{:functions
{:hide-errors duct.middleware.errors/wrap-hide-errors,
:not-found duct.middleware.not-found/wrap-not-found,
:ring-json-response ring.middleware.json/wrap-json-response,
:ring-json-body ring.middleware.json/wrap-json-body},
View Dockerfile-dev
FROM clojure
RUN mkdir -p /app
COPY ./dev /app/dev
COPY ./profiles.clj /app/profiles.clj
COPY ./project.clj /app/project.clj
COPY ./resources /app/resources
COPY ./src /app/src
View gist:e897748bca5e264f5298
(comment
I'm trying to build a very simple clojurescript app using re-frame (& reagent, secretary),
and I am getting the following error in the console, that I can't seem to debug:
Error: No protocol method IDeref.-deref defined for type cljs.core/PersistentArrayMap: {:name "Black Temple", :snippet "25-man raid"}
)
(ns raid-commander.core
(:require [reagent.core :as reagent :refer [atom]]
[reagent.session :as session]