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
;; 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
;; 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))
mydate <- strptime('Mon Dec 09 2019 13:35:10 GMT-0700',
format='%a %b %d %Y %H:%M:%S GMT%z')
(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"})
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 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

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 :? [..]):

--- 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},
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
(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]