Skip to content

Instantly share code, notes, and snippets.

View shegeley's full-sized avatar
🍴
Fork you

Grigory Shepelev shegeley

🍴
Fork you
View GitHub Profile
@shegeley
shegeley / backend.cljs
Created December 5, 2024 18:23
clojurescript: sequelize, expresss, cljs.core.async sample code
(ns backend.core
(:require ["sequelize" :refer (Sequelize DataTypes)]
[cljs.core.async :refer [go]]
[cljs.core.async.interop :refer-macros [<p!]]
["express" :as express]))
(def port 1337)
(defn env [x & [default]]
(or (aget (.. js/process -env) x) default))
@shegeley
shegeley / treemacs-auto-toggle.el
Created October 28, 2024 08:05
Emacs Treemacs auto-toggling in text and prog-modes. Author: @ichernyshovvv
(defun treemacs-toggle-maybe ()
(require 'treemacs)
(if (eq last-command 'treemacs)
(set-frame-parameter (selected-frame) 'treemacs-forced-p
(not (frame-parameter (selected-frame) 'treemacs-forced-p)))
(unless (frame-parameter (selected-frame) 'treemacs-forced-p)
(if (seq-find
(lambda (x)
(with-current-buffer (window-buffer x)
(derived-mode-p 'text-mode 'prog-mode)))
@shegeley
shegeley / srfi-125.scm
Last active May 26, 2024 05:57
Guile Scheme SRFI-125 packaging attempt
(use-modules
(guix gexp)
(guix download)
((guix licenses) #:prefix license:)
(guix packages)
(guix git-download)
(guix download)
(guix utils)
(guix build-system guile)
(gnu packages guile)
@shegeley
shegeley / hash-table-compare.scm
Last active May 21, 2024 17:44
Guile Scheme hash table deep hash and equality comparsion
(use-modules (srfi srfi-69))
#|
(hash (list 1 2)) => 1690321764596975924
(hash (list 2 1)) => 1690321764596975924
(hash (vector 1 2)) => 2121270931541232526
(hash (vector 2 1)) => 1271456826911243416
|#
(define (hash-table-deep-hash table)
@shegeley
shegeley / scmfmt.scm
Created June 14, 2023 07:20 — forked from ojarjur/scmfmt.scm
Code formatter for Scheme using Guile's pretty-print method. This reads from stdin and writes to stdout.
(use-modules (ice-9 pretty-print))
;; Helper methods for maintaining comments and whitespace.
(define (copy-line-comment)
(let ((char (read-char)))
(if (not (eof-object? char))
(if (eq? char #\newline)
(newline)
(begin (write-char char) (copy-line-comment))))))
(define (maintain-empty-lines)
@shegeley
shegeley / convenience-lambda.scm
Created April 15, 2023 03:30 — forked from shanecelis/convenience-lambda.scm
A succinct anonymous procedure syntax for Guile scheme
;; convenience-lambda.scm
;;
;; This syntax was inspired by arc and Clojure's anonymous procedure
;; syntax.
;;
;; #.\ (+ %1 %2) -> (lambda (%1 %2) (+ %1 %2))
;; #.\ (+ % %%) -> (lambda (% %%) (+ % %%))
;;
;; The .\ is supposed to approximate the lowercase lambda character in
;; ascii.
@shegeley
shegeley / crypro.clj
Created February 10, 2022 04:25
Some clojure drafts on Coursera Cryprography I course.
(ns cryptogroups.groups
(:require [clojure.set :as set]))
(defn pow
[x n]
(Math/pow x n))
(defrecord Z [N])
(defrecord Z* [N])
@shegeley
shegeley / keybindings.el
Created June 11, 2021 16:23
Doom Emacs Paredit Keybindings Customization Example
;; Paredit's bindings set to be called with SPC + l as prefix
(map!
:map paredit-mode-map
:leader (:prefix ("l" . "Lisps")
:nvie "f" #'paredit-forward
:nvie "b" #'paredit-backward
:nie "k" #'paredit-kill-region
:nie "s" #'paredit-splice-sexp
:nie "(" #'paredit-wrap-round
@shegeley
shegeley / russian-obscene-regrex.yaml
Created December 20, 2020 07:27
Russian obscene words filter (regexes) in yaml format.
# Source https://github.com/oranmor/russian_obscenity
# основной фильтр
- '(?:\w*(?:[хxh](?:[уyu][иiu])|[пnp][еиeiu](?:[з3z][дd]|[дd](?:[еаоeoa0][рpr]|[рpr]))|[бb6][лl]я[дd]|[оo0][хxh][уyu][еe]|[мm][уyu][дd][еоиаeioau0]|[дd][еe][рpr][ьb]|[гrg][аоoa0][вbv][нhn]|[уyu][еёe][бb6])|[хxh][\W_]*(?:[уyu][\W_]*[йиеёяeiju])|[пnp][\W_]*[еиeiu][\W_]*(?:[з3z][\W_]*[дd]|[дd][\W_]*(?:[еаоeoa0][\W_]*[рpr]|[рpr]))|[бb6][\W_]*[лl][\W_]*я[\W_]*[дd]|[оo0][\W_]*[хxh][\W_]*[уyu][\W_]*[еe]|[мm][\W_]*[уyu][\W_]*[дd][\W_]*[еоиаeioau0]|[дd][\W_]*[еe][\W_]*[рpr][\W_]*[ьb]|[гrg][\W_]*[аоoa0][\W_]*[вbv][\W_]*[нhn]|[уyu][\W_]*[еёe][\W_]*[бb6]|[ёеe][бb6])\w+'
# жоп*
- 'ж[\W_]*(?:[оo0][\W_]*[пnp][\W_]*(?:[аa]|[oо0](?:[\W_]*[хxh])?|[уеыeyiuё]|[оo0][\W_]*[йj])\w*)'
# дерьмо
- '[дd][\W_]*[еe][\W_]*[рpr][\W_]*(?:[ьb][\W_]*)?[мm][\W_]*[оуеаeoya0u](?:[\W_]*[мm])?'
# чмо, чмырь
- '[чc][\W_]*[мm][\W_]*(?:[оo0]|[ыi][\W_]*[рpr][\W_]*[еиьяeibu])'
# сука, сучка
@shegeley
shegeley / symbolic-system.clj
Last active August 24, 2020 05:42
Translating decimal number to some symbolic enumeration system consistend of distinct strings
(ns symbolic-system.utils
(:require [clojure.math.numeric-tower :as math]))
(defn symbolic-enumeration-system->decimal-number
"Translates symbolic enumeration system element that consists of distinct strings to decimal number based on number of elements in the system. System elements must be given in descending order"
[x system]
{:pre [(spec/and
(spec/valid? (spec/coll-of string?) x)
(spec/valid? (spec/coll-of string?) system)
(spec/valid? not-empty system)