Skip to content

Instantly share code, notes, and snippets.

View schneiderfelipe's full-sized avatar
🎯
Focusing

Felipe S. S. Schneider schneiderfelipe

🎯
Focusing
View GitHub Profile
@PixeyeHQ
PixeyeHQ / mdl_observer.nim
Last active May 18, 2024 23:37
On value change observer
from sugar import `=>`, `->`
export `->`, `=>`
type Wrapper[TSource, TProp] = ref object
source: TSource
val: TProp
prop: proc(arg: TSource): TProp
callback: proc(arg: TSource)
var storage = newSeq[proc()](0)
a::Dual + b::Dual = Dual(a.x + b.x, a.ϵ + b.ϵ)
a::Dual - b::Dual = Dual(a.x - b.x, a.ϵ - b.ϵ)
a::Dual * b::Dual = Dual(a.x * b.x, b.x * a.ϵ + a.x * b.ϵ)
a::Dual / b::Dual = Dual(a.x * b.x, b.x * a.ϵ - a.x * b.ϵ)
Base.sin(d::Dual) = Dual(sin(d.x), d.ϵ * cos(d.x))
Base.cos(d::Dual) = Dual(cos(d.x), - d.ϵ * sin(d.x))
struct Dual{T<:Real} <: Real
x::T
ϵ::T
end
function derive(ex, x)
ex == x ? 1 :
ex isa Union{Number,Symbol} ? 0 :
@capture(ex, a_ + b_) ? :($(derive(a, x)) + $(derive(b, x))) :
@capture(ex, a_ * b_) ? :($a * $(derive(b, x)) + $b * $(derive(a, x))) :
@capture(ex, a_^n_Number) ? :($(derive(a, x)) * ($n * $a^$(n-1))) :
@capture(ex, a_ / b_) ? :($b * $(derive(a, x)) - $a * $(derive(b, x)) / $b^2) :
error("$ex is not differentiable")
end

Various search databases and backends as alternatives to Elasticsearch.

Rust

@ines
ines / Install
Last active September 21, 2023 17:14
Streamlit + spaCy
pip install streamlit
pip install spacy
python -m spacy download en_core_web_sm
python -m spacy download en_core_web_md
python -m spacy download de_core_news_sm
@w1th0utnam3
w1th0utnam3 / rust_electron.md
Last active January 29, 2024 23:17
Building a Rust/Electron app
@edmundsmith
edmundsmith / writeup.md
Created July 7, 2019 20:47
Method for Emulating Higher-Kinded Types in Rust

Method for Emulating Higher-Kinded Types in Rust

Intro

I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.

There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.

As an example, currently we can express this type:

@andersevenrud
andersevenrud / alacritty-tmux-vim_truecolor.md
Last active August 22, 2025 16:38
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh

The Cabal/Stack Disambiguation Guide

One of the most frequently asked Haskell beginner questions in recent years is:

"Stack or cabal?"

I will helpfully not answer this question. Instead I will hope to eliminate the confusion that many of the askers seem to have about the various different