Skip to content

Instantly share code, notes, and snippets.

View tolitius's full-sized avatar

Anatoly tolitius

View GitHub Profile
@tolitius
tolitius / into-crux.md
Last active August 22, 2020 14:37
(get-in crux [:mindset])

several facts "at once"

=> (crux/submit-tx node [[:crux.tx/put {:crux.db/id :legend/picasso :kind :human}]
                         [:crux.tx/put {:crux.db/id :legend/picasso :planet :earth}]
                         [:crux.tx/put {:crux.db/id :legend/picasso :alive? :always}]
                         [:crux.tx/put {:crux.db/id :legend/picasso :location "Barcelona"}]])
@tolitius
tolitius / server-with-reitit-routes.md
Created July 3, 2020 22:00
an example of starting a server with reitit routes

separate namespace for routes:

(ns hubble.routes
  (:require [reitit..]))

(defn make-routes [config]
  [["/api/hubble" {:swagger {:tags ["ops"]}}
    ;; ....
@tolitius
tolitius / jwks-repl.clj
Created March 30, 2020 23:23
how to use jwks with buddy
(require '[jsonista.core :as json]
'[org.httpkit.client :as http]
'[buddy.core.keys :as keys]
'[buddy.sign.jwt :as jwt])
(def mapper (json/object-mapper {:decode-key-fn keyword}))
;; if done fo real => check for http/get error
(defn jwks->pubkey [jwks-url]
(-> @(http/get jwks-url)
@tolitius
tolitius / 0. README.md
Last active March 17, 2020 18:05
kafka: tail last N messages

expects

  • kafka installed
  • zookeeper hostname
  • jq installed
@tolitius
tolitius / delete-old-builds.md
Created February 28, 2020 23:00
jenkins: delete old builds

Manage Jenkins => Script Console

import jenkins.model.Jenkins
import hudson.model.Job

MAX_BUILDS = 10
Jenkins.instance.getAllItems(Job.class).each { job ->
  println job.name
 def recent = job.builds.limit(MAX_BUILDS)
@tolitius
tolitius / venn'in.md
Last active October 11, 2019 23:24
venn'in
=> (pprint agenda)

{:first-topic #{:justin :scott :les :valentin :andy},
 :second-topic #{:justin :scott :les :valentin :andy :gopi},
 :third-topic #{:les :valentin :andy :gopi},
 :fourth-topic #{:les :valentin :andy :gopi},
 :fifth-topic #{:beth :les :valentin :andy :gopi},
 :sixth-topic #{:beth :gopi},
 :seventh-topic #{:justin :scott :beth}}
(ns issue-104.core
(:require [mount.core :as mount :refer [defstate]]))
(mount/in-cljc-mode)
(defstate ^{:on-reload :noop} teststate
:start "hi")
@tolitius
tolitius / 0. today-i-learned.md
Last active April 16, 2018 20:19
TIL: Today I Learned

what is it?

Chariot wants you to learn a basic idea about what the blockchain is made of. The only way to learn it is to use it: really.

Hence here is what we offer you, proud Charioteer:

You can get any educational materials such as ebooks, books, online courses, etc. and reimburse all or some of its cost by using the new and shiny Chariot cryptocurrency.

You do it by creating a Stellar account via BB-8 (instructions below),

@tolitius
tolitius / n-n-matrix-transpose.clj
Last active November 16, 2017 05:07
transpose N x N matrices
=> (defn transpose [m]
(apply mapv vector m))
=> (transpose [[1 2] [3 4]])
[[1 3] [2 4]]
=> (transpose [[1 2 3] [4 5 6] [7 8 9]])
[[1 4 7] [2 5 8] [3 6 9]]
use std::fmt::{self, Formatter, Display};
struct Matrix(f32, f32, f32, f32);
// do we prefer pure or since &mut is safe (and faster) it is preferable?
fn transpose(Matrix(a, b, c, d): Matrix) -> Matrix {
Matrix(a, c, b, d)
}
impl Display for Matrix {