Skip to content

Instantly share code, notes, and snippets.

@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]))
@mikeball
mikeball / example.clj
Created February 10, 2016 09:52
Flatten nested maps to csv
(def json-raw
[{"type" "t1"
"weather" { "lat" 1
"lon" 2}}
{"type" "t2"
"weather" { "lat" 3
"lon" 4
"abc" {"xyz" 5}}}])
@mikeball
mikeball / avoid-nesting.clj
Last active May 26, 2016 18:19
Avoid nesting if statements using a short circuited threading macro.
(defmacro short->
"Short circuit pipeline/threading operator that shorts on given condition."
[init & steps-and-conditions]
(let [check (-> (take-last 2 steps-and-conditions)
((fn [conditions] (if-not (and (= (count conditions) 2)
(= (first conditions) :on))
(throw (Exception. "Invalid conditions function syntax."))
(second conditions)))))

How to Backup your Solus to S3

This guide will show you how to back up, and restore, your important data to Amazon S3 fully encrypted.

Install deja-dup

Install deja-dup from the Software Center

@mikeball
mikeball / Program.fs
Created February 13, 2017 09:00
F#, dotnet core and postgreql query
open System
open Npgsql
type Category = {
id: int;
name: string
}
let categoriesSQL = "
@mikeball
mikeball / cljs-installation.md
Last active June 28, 2017 20:39
CLJS Installation

CLJS Setup

This guide is intended to help you get started with CLJS.

An important note: CLJS is best experienced when developing and testing interactively against a live running instance of your application. In this way it's different than most other languages which use an edit/compile/restart method of working. While it is technically possible to use an edit/compile/restart workflow, if you use it with CLJS, you're gonna have a bad time.

Tools Installation

{Embedded Video of Tools Installation}

{
:builds
{:tool
{:src ["src"]
:compiler {:main "tool.core"
:target :nodejs
:optimizations :simple
:output-to "target/tool.js"}}
cat /root/.npm/_logs/2017-09-10T04_24_41_517Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'https://github.com/reasonml/reason-cli/archive/beta-v-1.13.6-bin-linux.tar.gz' ]
2 info using npm@5.4.1
3 info using node@v8.4.0
4 verbose npm-session 0543e7aa71cf9ceb
cat /home/mike/.npm/_logs/2017-09-10T06_57_33_782Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'https://github.com/reasonml/reason-cli/archive/beta-v-1.13.7-bin-linux.tar.gz' ]
2 info using npm@5.3.0
3 info using node@v8.4.0
4 verbose npm-session f664dd009f0ec190

~/.clojure/deps.edn file

 {:1.8 {:override-deps {org.clojure/clojure {:mvn/version "1.8.0"}}}
  :1.9 {:override-deps {org.clojure/clojure {:mvn/version "1.9.0"}}}
  :master {:override-deps {org.clojure/clojure {:mvn/version "1.10.0-master-SNAPSHOT"}}}
  :test {:extra-paths ["test"]}
  :bench {:extra-deps {criterium {:mvn/version "0.4.4"}}}
 :proto {:extra-deps {proto-repl {:mvn/version "RELEASE"}}}