Skip to content

Instantly share code, notes, and snippets.

View tangrammer's full-sized avatar
🏠
Working from home

Juan A. Ruz tangrammer

🏠
Working from home
View GitHub Profile
@tangrammer
tangrammer / copy-clj-impl.org
Created July 19, 2018 12:55
clojure implementation of formatting copyright years

clj challenge :)

(defn- parse
  "Parse years collection into years integer collection. Example: from ['1978' '1956' ...] to (1978 1956)"
  [col*]
  (map  #(Integer/parseInt %) col*))

(defn- group-consecutive-years
  "Example: from (2014 2010 2011 2012 2015 2016 2017) to ((2010 2011 2012) (2014 2015 2016 2017))"
@tangrammer
tangrammer / example.clj
Created June 19, 2018 15:03
example aggregation generation data from specs
(in-ns 'akvo.lumen.specs.aggregation)
(def s* lumen.s/sample)
(s* ::l.aggregation.filter/filter)
;; => {:operation "remove",
;; :strategy "isLower",
;; :value "3hrEm8YaB0ZxnuS",
;; :column
;; {:columnName "d3",
@tangrammer
tangrammer / org-mode-reference-in.org
Created June 4, 2018 22:06 — forked from drj42/org-mode-reference-in.org
This is a cheat sheet for Emacs org-mode... in org-mode format!
@tangrammer
tangrammer / org-mode-reference-in.org
Created June 4, 2018 22:06 — forked from drj42/org-mode-reference-in.org
This is a cheat sheet for Emacs org-mode... in org-mode format!

inject plpgsql

CREATE OR REPLACE FUNCTION extract_cols_as_char (tablename CHARACTER, my_prefix CHARACTER DEFAULT '')
CREATE OR REPLACE FUNCTION history.log_change() RETURNS trigger AS $_$
DECLARE
c refcursor;
tt tstzrange;
r record;
str text;
my_new text;
BEGIN
str := '';
java.lang.IllegalStateException:
Attempt to remove an object from the bag that was not borrowed or reserved
ConcurrentBag.java:207 com.zaxxer.hikari.util.ConcurrentBag.remove
HikariPool.java:394 com.zaxxer.hikari.pool.HikariPool.closeConnection
HikariPool.java:223 com.zaxxer.hikari.pool.HikariPool.releaseConnection
ConnectionProxy.java:216 com.zaxxer.hikari.proxy.ConnectionProxy.close
jdbc.clj:1014 clojure.java.jdbc/db-query-with-resultset*
jdbc.clj:996 clojure.java.jdbc/db-query-with-resultset*
jdbc.clj:1090 clojure.java.jdbc/query
jdbc.clj:1047 clojure.java.jdbc/query
@tangrammer
tangrammer / .dir-locals.el
Created April 19, 2018 10:04
akvo-lumen cider adaptation to work with docker nrepl
;; using docker-compose up, we loose the cider ability to navigate definitions with `C - .` due the source of current (docker) nrepl is under a different path `/app/src` instead of akvo-lumen local git repo
;; so the trick is to replace docker source paths by user-local-paths.
((nil . ((eval . (defun to-local-paths (info)
"adapt src and .m2 docker paths to local paths"
(let* ((file (nrepl-dict-get info "file"))
(res-0 (progn
(replace-regexp-in-string "/app/" (clojure-project-dir) file))))
(replace-regexp-in-string "/home/akvo/.m2/"
(concat (getenv "HOME") "/.m2/")
@tangrammer
tangrammer / custom.el
Last active July 25, 2017 08:30 — forked from kristianhellquist/custom.el
Emacs, copy current file and line number to clipboard
(defun copy-current-line-position-to-clipboard ()
"Copy current line in file to clipboard as '</path/to/file>:<line-number>'"
(interactive)
(let ((path-with-line-number
(concat (buffer-file-name) "::" (number-to-string (line-number-at-pos)))))
(when path-with-line-number
(with-temp-buffer
(insert path-with-line-number)
(clipboard-kill-region (point-min) (point-max)))
(message (concat path-with-line-number " copied to clipboard")))))
@tangrammer
tangrammer / 00_destructuring.md
Created May 12, 2017 12:06 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors