Skip to content

Instantly share code, notes, and snippets.

View barkanido's full-sized avatar
Focusing on

Ido Barkan barkanido

Focusing on
View GitHub Profile
barkanido / setup-neovim-ubuntu.txt
Created October 19, 2020 17:35
a working neovim setup on Ubuntu + clojure dev env
# tested on ubuntu 20.04
Install NeoVim
install a JDK (8/11 is fine) (I use azul)
install lein (a Clojure build tool)
sudo apt install nodejs git curl nvim python3-pip npm clang
sudo npm install -g neovim
pip3 install --upgrade pynvim jedi msgpack black
pip install --upgrade pynvim jedi msgpack
clone Clojure language server (clone and run the install_clojure_lsp script.
(defprotocol Talker
(talk [this msg]))
(defrecord Hero
[name type position health objects]
(talk [this msg]
(println (:name this) ":" msg)))
(->Hero "Bad Guy" :warrior {:x 11 :y 344} 93 [:sword :dagger])
{:type :sword
:name "excalibur"
:strength 50
:weight 40}
{:type :warrior
:name "Bad guy"
:position {:x 11 :y 344}
:health 93
:objects [:sword :dagger]}
"a string"
{"a-map-key" [42]}
['("this" "is" "a" "list" "of" "strings")]
#{\a \b}
barkanido / data-flow1.clj
Last active December 26, 2019 04:38
a simple clojure function
(defn foo [a b]
(let [x (+ a b)]
(def result (foo 3 4))
barkanido / match_example.clj
Created May 13, 2019 11:29
beware of clojure.core.match
(match/match [a b]
[_ true] :first
[true false] :second
[_ false] :third)
(= b true) :first
(= b false) (try
barkanido /
Created April 2, 2019 06:43
multi fprmatter (parser) for timstamps in java 8 time aPI
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
public class Main {
barkanido / core.clj
Last active March 10, 2019 15:28
testing url query string parsing in clojure
(ns toy-url-decoder.core
(:require [cemerick.url :as c-url]
[criterium.core :as crit])
(:import [ URI URL]
[io.netty.handler.codec.http QueryStringDecoder]
[java.nio.charset Charset]
[org.apache.http.client.utils URLEncodedUtils]
[org.apache.http NameValuePair]
[java.util List Map Map$Entry]))
user=> (aero/put c "index" "set-name" 42 1000)
<< … >>
user=> (defn inc-transcoder [rec] (when rec
#_=> (update rec :payload inc)))
user=> (d/chain (aero/get-single c "index" "set-name" {:transcoder inc-transcoder})
#_=> :payload
#_=> println)
<< … >>