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 / 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)
@shegeley
shegeley / filter-nested.clj
Created July 28, 2020 07:19
Clojure filter that works with deep nested structures
(defn filter-nested
[pred xs]
(loop [r []
ys xs]
(let [k (first ys)
_ (print k)]
(cond
(not (sequential? k))
(cond
(= [] ys) r
@shegeley
shegeley / scotty-web-server-problem.hs
Last active September 2, 2019 14:46
Explanation of my problem with scotty server
getProducts :: IO [Product]
main :: IO ()
main = do
S.scotty 3000 $ do
S.liftAndCatchIO getProducts >>= \products -> do
S.get "/" $ do ...
S.get "/products" $ do ...
@shegeley
shegeley / nofap.hs
Created April 28, 2019 15:02
Nofap daemon in Haskell prototype
module App where
import Data.List.Split
import Data.Maybe
import Control.Monad
import Data.Time
import qualified System.Directory as SD
data Event = ChangeUserData User | Masturbated ZonedTime | WatchedPorn ZonedTime | ExportAppData | None deriving (Show, Read)
@shegeley
shegeley / marriage.hs
Last active July 26, 2019 14:57
Stable marrige problem in Haskell. University task. Not optimized by complexity. Started learning haskell 2-3 month ago.
{- Author: Grigory Shepelev.; Github: @altjsus; E-mail: altjsus@gmail.com -}
import Data.List
import Data.Ord
import Data.Maybe
import Control.Monad
import System.Random
import Fake hiding (shuffle)
import Fake.Provider.Person.EN_US