Skip to content

Instantly share code, notes, and snippets.

@aymanosman
aymanosman / epub.ex
Created May 6, 2025 11:15
EPUB parser
defmodule Epub do
def parse_container(xml) do
import SweetXml
xml
|> configure_parse()
|> xmap(
rootfile: [~x"//rootfile"l, full_path: ~x"./@full-path", media_type: ~x"./@media-type"]
)
end

SVM bug

Mix.install([
  {:scholar, "~> 0.3.1"},
  {:tucan, "~> 0.4.1"},
  {:kino_vega_lite, "~> 0.1.13"}
])
@aymanosman
aymanosman / emlx-bug.exs
Created November 29, 2024 20:15
emlx bug
Mix.install([
{:emlx, github: "elixir-nx/emlx"},
{:axon, github: "elixir-nx/axon"},
{:scidata, "~> 0.1.11"}
])
Nx.default_backend(EMLX.Backend)
Nx.default_backend({EMLX.Backend, device: :gpu})
{images, labels} = Scidata.MNIST.download()
@aymanosman
aymanosman / study-machine-learning-in-elixir.livemd
Created August 26, 2024 18:20
study-machine-learning-in-elixir.livemd

Machine Learning in Elixir

Mix.install([
  {:axon, "~> 0.5"},
  {:nx, "~> 0.5"},
  {:exla, "~> 0.5"},
  {:explorer, "~> 0.5"},
  {:kino, "~> 0.8"},
  {:kino_explorer, "~> 0.1.21"},
@aymanosman
aymanosman / nllb-demo.livemd
Created August 14, 2024 20:25
NLLB in Bumblebee demo

Try NLLB

Mix.install(
  [
    {:bumblebee, github: "aymanosman/bumblebee", branch: "m2m100-and-nllb"},
    {:exla, ">= 0.0.0"}
  ],
@aymanosman
aymanosman / nx-stack.livemd
Last active August 12, 2024 18:52
How Nx.stack works

Nx.stack

Mix.install([
  {:nx, "~> 0.7.3"}
])
@aymanosman
aymanosman / bug-view-undefined.exs
Last active April 19, 2024 07:47
bug-view-undefined.exs
Application.put_env(:sample, Example.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
@aymanosman
aymanosman / monorepo.el
Created March 11, 2024 15:29
monorepos in project.el
;; -*- lexical-binding: t; -*-
(defvar monorepo-root-markers '(("package.json"
(ignores . ("node_modules")))
("mix.exs"
(ignores . ("_build/" "deps/")))
"*.asd"))
(defun monorepo-try-find-project (dir)
(let* ((found (monorepo--find-project dir)))
@aymanosman
aymanosman / input-line-eff.lisp
Last active March 28, 2023 16:17
Restarts in Common Lisp
;; https://github.com/ocaml-multicore/ocaml-effects-tutorial/blob/master/sources/input_line_eff.ml
(define-condition conversion-failure (error)
((string :initarg :string))
(:report (lambda (condition stream)
(format stream "Conversion failure ~S" (slot-value condition 'string)))))
(defun int-of-string (string)
(handler-case
(parse-integer string)