Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar

Roman Liutikov roman01la

View GitHub Profile
roman01la /
Created May 20, 2023 17:00
Export large scale map from OSM
  1. Go to
  2. Choose your area for export
  3. Put export bounding box longitude and latitude into and run it to calculate which tiles to has to be downloaded
  4. Create tiles directory
  5. Put calculated coordinates into download_tiles.js and run it do download tiles (couldn't make downloading work in Python)
  6. Put calculated coordinates into and run it
  7. The output will be stored in map.png file
roman01la / gui.js
Created April 7, 2023 11:35
View gui.js
const r = require("raylib/drm/index");
const net = require("net");
const path = require("path");
const { pexec } = require("./utils");
const renderer = require("./renderer");
function getScreenSize() {
return pexec(`fbset -s | grep "geometry" | awk '{print $2" "$3}'`).then((r) =>
r.split(" ").map((s) => parseInt(s, 10))
View aoc_2021_3.clj
(defn part-1 [input]
(->> input
(map seq)
(apply map list)
(map #(vals (into (sorted-map) (set/map-invert (frequencies %)))))
(apply map list)
(map (comp #(Integer/parseInt % 2) str/join))
(apply *)))
View aoc_2021_2.clj
(defn parse-input [input]
(->> input
(map #(let [[v n] (str/split % #" ")]
[v (Integer/parseInt n)]))))
(defn part-1 [input]
(->> (parse-input input)
(reduce (fn [[h d] [v n]]
(case v
View aoc_2021_1.clj
(defn part-1 [input]
(->> input
(partition 2 1)
(filter #(apply < %))
(defn part-2 [input]
(->> input
(partition 3 1)
(map #(apply + %))

This example illustrates an intersting side effect of Clojure's lazy sequences when used in re-frame subscriptions. The behaviour described below takes place only on initial subscribe call

(reg-sub :test/x-2
  (constantly [])
  (fn [_ _]
    (prn "evaluating body of " :test/x-2)
    (map #(do (prn "evaluating lazy seq returned from " :test/x-2) (inc %)) (range 3))))

(reg-sub :test/x-1
roman01la / analyze.clj
Created March 18, 2021 01:42
analyzing unused and undefined re-frame subscriptions via clj-kondo
View analyze.clj
(ns analyze.core
(:require [clj-kondo.core :as clj-kondo]
[clojure.set :as set]))
;; checks re-frame's :<- syntax
;; to mark dependency subscriptions as used
(def analyze-reg-sub
"(require '[clj-kondo.hooks-api :as api])
(fn [{node :node}]
(let [[_ kw & children] (:children node)
roman01la / core.clj
Created December 3, 2020 13:57
Day 2 - Advent of Code 2020
View core.clj
(->> (clojure.string/split (slurp "input_02") #"\n")
(map #(re-find #"(\d+)-(\d+) (\w): (\w+)" %))
(filter (fn [[_ min max char string]]
(>= (Integer/parseInt max)
(count (re-seq (re-pattern char) string))
(Integer/parseInt min))))
(->> (clojure.string/split (slurp "input_02") #"\n")
(map #(re-find #"(\d+)-(\d+) (\w): (\w+)" %))
roman01la / core.clj
Last active December 1, 2020 12:19
Day 1 - Advent of Code 2020
View core.clj
(def nums
(->> (str/split (slurp "input_01") #"\n")
(map #(Integer/parseInt %))))
(->> (for [x nums
y nums
:when (= 2020 (+ x y))]
(* x y))
(some identity))
roman01la / re-frame.clj
Last active October 21, 2020 11:32
Debugging re-frame subscriptions
View re-frame.clj
(:require [cljs.compiler :as cljsc]))
(defn- anonymous-function-declaration? [form]
(and (list? form)
(= 'fn (first form))
(vector? (second form))))
(defn- query-id->js-fn-name [query-id]
(let [ns-part (when-let [ns-part (namespace query-id)]