Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar
🇺🇦

Roman Liutikov roman01la

🇺🇦
View GitHub Profile
var icons = [
"<svg height=\"32\" class=\"octicon octicon-mark-github text-white\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"32\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z\"></path></svg>",
"<svg height=\"24\" class=\"octicon octicon-x text-gray\" viewBox=\"0 0 12 16\" version=\"1.1\" width=\"18\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6
@roman01la
roman01la / build
Created March 14, 2017 11:59
Gambit Scheme JavaScript target
$ cd lib
$ make _gambit.js
$ cd ..
$ gsc/gsc -:=. -warnings -target js code.scm
$ gsc/gsc -:=. -warnings -target js -link -l lib/_gambit.js code.js
$ cat code_.js code.js lib/_gambit.js > p.js
$ node p.js
@roman01la
roman01la / index.html
Created June 17, 2013 01:32
THREE.js scene setup with JSONLoader for OSM2WebGL demo
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="viewport"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/three.js/r58/three.min.js"></script>
<script src="//threejs.org/examples/js/controls/OrbitControls.js"></script>
@roman01la
roman01la / README.md
Created May 20, 2023 17:00
Export large scale map from OSM
  1. Go to https://www.openstreetmap.org/export#map=11/48.6129/38.2221
  2. Choose your area for export
  3. Put export bounding box longitude and latitude into calc_tiles.py 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 stitch_tiles.py and run it
  7. The output will be stored in map.png file
@roman01la
roman01la / gui.js
Created April 7, 2023 11:35
raylib
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))
);
@roman01la
roman01la / analyze.clj
Created March 18, 2021 01:42
analyzing unused and undefined re-frame subscriptions via clj-kondo
(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
roman01la / clojurescript-repl-workflow.md
Last active October 22, 2022 12:07
ClojureScript REPL Workflow

ClojureScript REPL Workflow

Short write up on using REPL when developing UIs in ClojureScript.

Hot-reload on save or Eval in REPL?

Everyone's standard approach to hot-reloading is to use a tool (Figwheel or shadow-cljs) that reloads changed namespaces automatically. This works really well: you change the code, the tool picks up changed files, compiles namespaces and dependants, notifies REPL client which then pulls in compiled changes, and re-runs a function that re-renders UI.

The other approach is to use ClojureScript's REPL directly and rely only on eval from the editor. This more or less matches Clojure style workflow. This approach might be useful when you don't want tools overhead or hot-reloading becomes slow for you or you just used to this style of interactions. Also changing code doesn't always mean that you want to reload all the changes. On the other hand it is very easy to change a couple of top-level forms and forget to eval one of them.

@roman01la
roman01la / react-native-stylesheet.cljs
Last active August 5, 2022 19:31
Access React Native compiled styles map using Clojure's keywords.
(def stylesheet (.-StyleSheet ReactNative))
(defn create-stylesheet [styles]
(->> styles
(clj->js)
(.create stylesheet)
(js->clj)
(clojure.walk/keywordize-keys)))
; usage
(defn part-1 [input]
(->> input
str/split-lines
(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 *)))
(defn parse-input [input]
(->> input
(str/split-lines)
(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