Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile

Recommendations

Repository

В репозитории содержится программный код, ресурсные файлы, сопутствующая документация и другие файлы, необходимые для разработки/сборки/тестирования приложения.

README.md

Основные секции:

@maxp
maxp / gitignore
Last active October 26, 2024 08:03
generic gitignore
#
# generic .gitignore
#
## no hiddens in scm
.*
## editor backups
*~
*.bak
(def translit-table-ru-en
(apply array-map [\a "a"
\b "b"
\c "c"
\d "d"
\e "e"
\f "f"
\g "g"
\h "h"
\i "i"
@maxp
maxp / grouped-dec.clj
Created February 8, 2022 18:12
grouped decimal number formatter
(defn grouped-dec [decimal-number]
;; NOTE: handle sign separately
(when decimal-number
(let [s (str decimal-number)
[deci fract] (str/split s #"\.")
grouped
(->> deci
(reverse)
(partition 3 3 nil)
(map #(apply str %))
@maxp
maxp / remove-nils.clj
Last active March 10, 2021 00:59
remove nil values from map
(let [data {:a :b :c nil :d 1}]
(->> data
(remove (comp nil? second))
(into {})))
;; {:a :b, :d 1}
-- postgresql 13 default
-- ubuntu, core i5, ssd
create table t1 (i bigint, c varchar(20), t text);
create table t2 (i bigint, c varchar(20), t text);
insert into t1 (i,c,t)
select random() * 1000000, '', '12345678912345678912345678900'
from generate_series(0,1000000);
@maxp
maxp / bmk.core.clj
Created August 23, 2020 07:09
babashka maker library
(ns bmk.core
(:import
[java.time ZonedDateTime]
[java.time.format DateTimeFormatter])
(:require
[clojure.string :refer [split]]
[clojure.java.shell :refer [sh]]))
;=
@maxp
maxp / bmk.clj
Created August 23, 2020 07:07
babashka based maker
#!/usr/bin/env bb
(require 'babashka.classpath)
(babashka.classpath/add-classpath "./tools")
(ns bmk.main
(:require
[bmk.core :refer [print-lines cmd sh-c]]))
;=
@maxp
maxp / build.clj
Last active October 26, 2024 08:07
cljs node repl
(ns build
(:import
[java.time LocalDateTime]
[java.time.format DateTimeFormatter])
(:require
[clojure.tools.build.api :as b]
))
(def APP_NAME (System/getenv "APP_NAME"))
@maxp
maxp / thread-loop.clj
Last active March 3, 2019 08:12
threaded init/step/cleanup lifecycle
;;
;; mlib: run proccessing loop in separate thread
;;
(ns mlib.thread
(:require
[clojure.core.async :refer [thread <!!]]))
;
(defn- thread-loop [state' init step cleanup]