Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar
🇺🇦

Roman Liutikov roman01la

🇺🇦
View GitHub Profile
(ns uix.ssr
(:require [uix.core :as uix :refer [$ defui]]
#?(:cljs ["react-slider" :as react.slider])
#?(:clj [uix.dom.server :as dom.server])))
#?(:cljs
(defui js-comp* [{:keys [children]}]
(let [[show? set-show] (uix/use-state false)]
(uix/use-effect
#(set-show true)
@roman01la
roman01la / extract_telegram_macos.ipynb
Created May 31, 2024 15:20 — forked from stek29/extract_telegram_macos.ipynb
Extract Telegram messages from db_sqlite PostBox – made for Telegram for macOS, but should work with Telegram for iOS
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
sudo apt install -y iptables hostapd dnsmasq dhcpcd5 isc-dhcp-server python3-pip python3-venv
sudo nano /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.42.1/24
nohook wpa_supplicant
sudo nano /etc/dhcp/dhcpd.conf
@roman01la
roman01la / blend.py
Created May 15, 2024 11:09
Running Blender on multiple GPUs on Modal.com
from pathlib import Path
from typing import Dict
import modal
import modal.gpu
app = modal.App("blender")
rendering_image = (
modal.Image.debian_slim(python_version="3.11")
.apt_install("xorg", "libxkbcommon0", "ffmpeg")
@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))
);
(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
(defn part-1 [input]
(->> input
(partition 2 1)
(filter #(apply < %))
count))
(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