Skip to content

Instantly share code, notes, and snippets.

View maslowalex's full-sized avatar
🇺🇦

Olexandr Maslo maslowalex

🇺🇦
View GitHub Profile
@denguir
denguir / cuda_install.md
Last active October 19, 2025 11:37
Installation procedure for CUDA / cuDNN / TensorRT

How to install CUDA / cuDNN / TensorRT on Ubuntu

Install NVIDIA drivers

Update & upgrade

sudo apt update && sudo apt upgrade

Remove previous NVIDIA installation

@LostKobrakai
LostKobrakai / form_live.ex
Last active June 3, 2025 14:28
Phoenix LiveView form with nested embeds and add/delete buttons
defmodule NestedWeb.FormLive do
use NestedWeb, :live_view
require Logger
defmodule Form do
use Ecto.Schema
import Ecto.Changeset
embedded_schema do
field :name, :string
@jmatsushita
jmatsushita / README
Last active October 20, 2025 02:23
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.

Genetic Algorithm in Nx

Preface

After writing Genetic Algorithms in Elixir, I had no real hopes or expectations that numerical computing would become a focus for Elixir. However, to my surprise, the Nx project developed rather quickly, and proved that Elixir could be used for practical machine learning and numerical computing applications. While I don't have any plans (yet) of reworking the examples in my book to take advantage of the acceleration enabled by Nx, EXLA, and other projects, I feel it's necessary to show how you could go about rewriting your genetic algorithms to take advantage of Elixir's new numerical computing libraries.

Introduction

Nx is a numerical computing library for Elixir which supports the creation and manipulation of multi-dimensional arrays (called tensors in the API), automatic differentiation, and just-in-time (JIT) compilation to CPU, GPU, and other accelerators via pluggable backends and compilers. Nx opens up a realm of possibilities for Elixir dev

@mcrumm
mcrumm / app.js
Last active March 4, 2025 13:07
flatpickr + LiveView example
// assets/js/app.js
// ...
import Pickr from "./pickr"
const hooks = {
Pickr
}
// ...
@m-root
m-root / vsa.py
Last active July 22, 2024 15:16
Volume Spread Analysis
import talib
import statsmodels.api as sm
import pandas as pd
def initialize(context):
context.security = symbol('AAPL')
#set_universe(universe.DollarVolumeUniverse(floor_percentile=98.0,ceiling_percentile=100.0))
def bar_data(OHLC_type, bars_nr):
bar_data_func = (history((bars_nr + 1), '1d', OHLC_type).iloc[0]).astype('float')
@trestrantham
trestrantham / periodic_task.ex
Created January 27, 2016 05:19
Run a task periodically natively in Elixir
defmodule MyApp.Periodically do
use GenServer
def start_link do
GenServer.start_link(__MODULE__, %{})
end
def init(state) do
Process.send_after(self(), :work, 2 * 60 * 60 * 1000) # In 2 hours
{:ok, state}
@cawhitworth
cawhitworth / countdown.py
Last active November 1, 2023 15:57
Countdown solver in Python
import random
add = lambda a,b: a+b
sub = lambda a,b: a-b
mul = lambda a,b: a*b
div = lambda a,b: a/b if a % b == 0 else 0/0
operations = [ (add, '+'),
(sub, '-'),
(mul, '*'),
@mprymek
mprymek / gist:8379066
Last active July 22, 2022 09:18
Elixir metaprogramming example
# This is an example of metaprogramming in the Elixir language.
#
# We will define a domain specific language (DSL) for the definition
# of a service which is watched by several sensors.
# Each sensor watches some property/functionality of the service and
# returns the result of the check.
#
# To determine if the service is functioning properly, we need functions
# to run all the sensors' code and gather the returned data.
#
@rjkat
rjkat / FFT.hs
Created April 9, 2012 05:56
Haskell Fast Fourier Transform
import Data.Complex
import Control.Arrow
import Control.Monad
fft :: [Complex Double] -> [Complex Double]
fft = fft' . pad
-- perform a fast fourier transform
fft' :: [Complex Double] -> [Complex Double]
fft' [x] = [x]