Skip to content

Instantly share code, notes, and snippets.

View PetrGlad's full-sized avatar
🚶‍♂️
.

Petr Gladkikh PetrGlad

🚶‍♂️
.
View GitHub Profile
@Phate6660
Phate6660 / rust recommendations and alternatives.md
Last active May 29, 2024 12:35
My growing list of Rust programs to use.
@natowi
natowi / audio2midi.md
Last active July 19, 2024 03:32
List of open source audio to midi packages
@pjstadig
pjstadig / transducers.md
Last active June 8, 2021 13:22
The secret feature of transducers that no one talks about!

The Pledge

One thing that always made me a little sad about transducers was how map lost its ability to iterate multiple collections in parallel. This is actually my favorite feature of map. For example:

(map + (range 5) (range 5 10))
=> (5 7 9 11 13)

One somewhat practical use of this is if you want to compare two sequences, pairwise, using a comparator. Though I wish that every? took multiple collections, this is an adequate substitute:

@martinsson
martinsson / TicTacToe.java
Last active December 11, 2017 17:38
One-liner solution to the TicTacToe kata ;o)
// Not what I'd call good readable code, but it amuses me ;D
private boolean playerWon(char player, char[] board) {
return of(
// rows
of(0, 1, 2), of(3, 4, 5), of(6, 7, 8),
// columns
of(0, 3, 6), of(1, 4, 7), of(2, 5, 8),
// diagonals
of(0, 4, 8),of(2, 4, 6)
@cgrand
cgrand / binding-conveying.clj
Created April 4, 2017 09:04
Did you know? #clojure
;; did you know that binding conveying is not immutable but read-only? (the future sees updates performed by the original thread)
=> (with-local-vars [a 1]
(future (Thread/sleep 1000) (prn 'future @a))
(var-set a 2))
2
future 2
;; you have to push new bindings to isolate:
=> (with-local-vars [a 1]
(with-bindings {a @a}
@reborg
reborg / rich-already-answered-that.md
Last active July 11, 2024 09:54
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@evancz
evancz / Architecture.md
Last active December 21, 2022 14:28
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo
@tonsky
tonsky / user.keymap
Created June 4, 2014 12:04
LightTable keymap of Sublime shortcuts
{ :+
{ :editor
{ "pmeta-/" [:toggle-comment-selection]
"ctrl-shift-up" [:editor.sublime.selectLinesUpward]
"ctrl-shift-down" [:editor.sublime.selectLinesDownward]
"pmeta-d" [:editor.sublime.selectNextOccurrence]
"ctrl-m" [:editor.sublime.goToBracket]
"ctrl-shift-m" [:editor.sublime.selectBetweenBrackets]
"shift-pmeta-space" [:editor.sublime.selectScope]
"ctrl-pmeta-up" [:editor.sublime.swapLineUp]
@PetrGlad
PetrGlad / bashrc.sh
Last active February 10, 2024 21:30
My ubuntu setup
shopt -s histappend
export PATH=$PATH:$HOME/.local/bin:$HOME/bin
stty -ixon
# export PS1='\n\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]`__git_ps1` \n\$ '
# export PS1='\n\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[38;5;250m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[38;5;250m\]`__git_ps1`\[\033[00m\] \n\[\033[01;32m\]☯\[\033[00m\] '
# export PS1='\n\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[38;5;243m\]\u@\h\[\033[00m\]:\[\033[38;2;140;140;200m\]\w\[\033[00m\]\[\033[38;5;243m\]`__git_ps1`\[\033[00m\] \n\[\033[01;32m\]☯\[\033[00m\] '
export PS1='\n\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[38;5;243m\]\u@\h\[\033[00m\]:\[\033[38;2;140;140;200m\]\w\[\033[00m\]\[\033[38;5;243m\]`__git_ps1`\[\033[00m\] \n\[\033[01;3`[ $(id -u) == "0" ] && echo 3 || echo 2`m\]☯\[\033[00m\] '