Skip to content

Instantly share code, notes, and snippets.

@danslapman
danslapman / config.json
Last active April 9, 2026 08:39
My config for fresh-editor
{
"version": 1,
"theme": "dracula",
"locale": "en",
"check_for_updates": false,
"file_explorer": {
"show_hidden": true
},
"lsp": {
"haskell": [{
@danslapman
danslapman / statusline-mac.sh
Last active April 3, 2026 15:11
My statusline
input=$(cat)
model=$(echo "$input" | jq -r '.model.display_name // "Unknown"')
five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
make_bar() {
local pct="$1"
local filled=$(awk "BEGIN { printf \"%.0f\", $pct * 10 / 100 }")
@danslapman
danslapman / Default%20%28OSX%29.sublime-keymap
Last active August 23, 2022 07:28
Sublime text settings
[
{ "keys": ["alt+space"], "command": "auto_complete" },
{ "keys": ["alt+q"], "command": "lsp_signature_help_show" }
]
@danslapman
danslapman / links.txt
Created June 28, 2022 21:29
streaming json
@danslapman
danslapman / thesis.txt
Last active June 23, 2022 19:58
Typeclasses
Доклад простыми словами знакомит слушателя с понятиями "тайпкласс" и "тип высшего порядка" и объясняет,
почему об этом постоянно говорят функциональщики.
Для тех, кто был на докладе Олега на Joker 2018, но ничего не понял
@danslapman
danslapman / .zshenv
Created June 1, 2022 14:49
JDK switcher for MacOS
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
jdk() {
version=$1
escaped=$(echo $JAVA_HOME | sed -e 's/[]\/$*.^[]/\\&/g')
pattern=$(printf 's/%s\/bin://g' "$escaped")
export PATH=$(echo $PATH | sed -e "$pattern")
export JAVA_HOME=$(/usr/libexec/java_home -v "$version")
export PATH=$JAVA_HOME/bin:$PATH
java -version
@danslapman
danslapman / GenericExtensions.cs
Last active June 19, 2023 06:45
Basic F# support for Swashbuckle
public static class GenericExtensions
{
public static void CopyProperties<T>(this T source, T destination)
{
var props = source?.GetType().GetProperties();
if (props == null) return;
foreach (var prop in props)
{
prop.SetValue(destination, prop.GetValue(source));
}
@danslapman
danslapman / yoneda.sc
Last active January 12, 2022 16:03
Yoneda lemma explanation
// https://ru.wikipedia.org/wiki/%D0%9B%D0%B5%D0%BC%D0%BC%D0%B0_%D0%99%D0%BE%D0%BD%D0%B5%D0%B4%D1%8B
/*
Scala за 5 минут
int Plus(int Lhs, int Rhs) => lhs + rhs; def plus(lhs: Int, rhs: Int) = lhs + rhs;
Func<int, Int, Int> plus = (lhs, rhs) => lhs + rhs; val plus: (Int, Int) => Int = (lhs, rhs) => lhs + rhs;
@danslapman
danslapman / .editorconfig
Last active September 19, 2022 15:16
My .editorconfig
#https://github.com/fsprojects/fantomas/blob/master/docs/Documentation.md
[*.{fs,fsx}]
indent_size=4
max_line_length=120
fsharp_max_value_binding_width=120
fsharp_max_function_binding_width=120
fsharp_multiline_block_brackets_on_same_column=true
fsharp_multi_line_lambda_closing_newline=true
fsharp_multiline_block_brackets_on_same_column = true
fsharp_experimental_stroustrup_style = true
@danslapman
danslapman / ManagedSourcesCachePlugin.scala
Created June 23, 2021 07:12
ManagedSourcesCachePlugin
package sbt
import sbt.Keys._
import sbt.internal.inc.HashUtil
import sbt.internal.remotecache.CustomRemoteCacheArtifact
import sbt.nio.FileStamp
import sbt.nio.file.FileAttributes
import sbt.plugins.JvmPlugin
import sbt.util.InterfaceUtil.toOption