Skip to content

Instantly share code, notes, and snippets.

@joelpaulkoch
joelpaulkoch / rag_time.exs
Last active September 16, 2025 16:46
A RAG for Elixir in Elixir
Mix.install(
[
{:phoenix_playground, "~> 0.1.6"},
{:phoenix, "~> 1.7.14"},
{:phoenix_live_view, "~> 1.0.0-rc.1"},
{:chroma, "~> 0.1.3"},
{:text_chunker, "~> 0.3.1"},
{:nx, "~> 0.9.0"},
{:exla, "~> 0.9.1"},
{:axon, "~> 0.7.0"},
@acalejos
acalejos / Nx_Decision_Trees.livemd
Last active October 31, 2025 19:28
Serving Spam Detection With XGBoost and Elixir

Nx-Powered Decision Trees

Mix.install(
  [
    {:exgboost, "~> 0.3.1", override: true},
    {:nx, "~> 0.6"},
    {:exla, "~> 0.5"},

Neural network from scratch in ... Elixir

Pure Elixir initial version test

inputs = [1, 2, 3, 2.5]
weights = [0.2, 0.8, -0.5, 1.0]
bias = 2.0
@kissgyorgy
kissgyorgy / listen.py
Created September 4, 2020 16:37
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@germsvel
germsvel / .projections.json
Last active June 24, 2025 07:45
Elixir/Phoenix basic projections
{
"lib/**/views/*_view.ex": {
"type": "view",
"alternate": "test/{dirname}/views/{basename}_view_test.exs",
"template": [
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}View do",
" use {dirname|camelcase|capitalize}, :view",
"end"
]
},
@sudix
sudix / flatten_nested_map.ex
Created January 20, 2017 05:58
Flatten map with nested key on Elixir
defmodule MyMap do
@doc """
flatten given map with nested key.
All keys must be atom or binary.
Returns map
## Examples
@mbutz
mbutz / Deep_Bass.rb
Created May 13, 2016 19:56
Deep Base - Minimal Techno Track with Sonic Pi
use_bpm 125
set_sched_ahead_time! 1
use_debug false
# Timer Loops -------------------------------------------------------
live_loop :atom do
sleep 0.25
end
live_loop :bar, sync: :atom do