Skip to content

Instantly share code, notes, and snippets.

View nickgnd's full-sized avatar
👨‍💻
Hacking my way

Nicolò G. nickgnd

👨‍💻
Hacking my way
View GitHub Profile
@nickgnd
nickgnd / Dockerfile
Created July 23, 2023 14:40
Dockerfile to deploy livebook with `exgboost` to huggingface
FROM ghcr.io/livebook-dev/livebook:latest-cuda11.8
ENV LIVEBOOK_APP_SERVICE_NAME "🐳 Hugging Face - $SPACE_TITLE"
ENV LIVEBOOK_APP_SERVICE_URL "https://huggingface.co/spaces/$SPACE_AUTHOR_NAME/$SPACE_REPO_NAME"
ENV LIVEBOOK_UPDATE_INSTRUCTIONS_URL "https://livebook.dev"
ENV LIVEBOOK_WITHIN_IFRAME "true"
ENV LIVEBOOK_APPS_PATH "/public-apps"
ENV LIVEBOOK_DATA_PATH "/data"
ENV LIVEBOOK_PORT 7860
@nickgnd
nickgnd / chapter3.livemd
Created July 18, 2023 14:15
Reply to Kenichi (Programming ML - chapter 3 with nx)

Chapter 3: Walking the Gradient

Mix.install([
  {:vega_lite, "~> 0.1.6"},
  {:kino, "~> 0.8.1"},
  {:kino_vega_lite, "~> 0.1.7"},
  {:explorer, "~> 0.5.6"},
@nickgnd
nickgnd / telller_bank_challenge.livemd
Last active April 21, 2023 13:52
Teller Bank Challenge

Teller Bank Challenge

Mix.install([:req, :jason, :kino])
@nickgnd
nickgnd / slow_model_run.ex
Last active January 24, 2023 22:06
Livebook to reproduce strange behaviour when running a model after binding a variable
# elixir ./slow_model_run.ex
# Title: Debugging: slowness 2nd model execution after binding variable
Mix.install(
[
{:exla, "~> 0.4"},
{:nx, "~> 0.4"},
{:axon, "~> 0.4.1"}
],
@nickgnd
nickgnd / eprof_to_csv.ex
Created December 19, 2022 14:01
Parse eprof result and create a CSV out of it
# eprof_results is the output printed by the `eprof` profiler
# with the "extra" lines already stripped (e.g. "Profile done over XXX matching functions")
eprof_results
|> String.split("\n", trim: true)
|> Enum.map(fn
"anonymous fn" <> _rest = row ->
[anonymous_fn, rest] =
String.split(row, ~r{anonymous fn/\d+ in .*/\d+}, trim: true, include_captures: true)
[anonymous_fn] ++ String.split(rest, ~r/\s/, trim: true)
@nickgnd
nickgnd / WITHOUT_global_compilation_option_debug.log
Last active December 12, 2022 11:36
Axon - slower when setting compilation options globally
12:27:55.731 [debug] Axon.Loop started initializing loop state
12:27:55.733 [debug] EXLA defn evaluation #Function<135.40305314/2 in Nx.Defn.Compiler.fun/2> cache miss in 2.1ms
12:27:55.992 [debug] EXLA compilation #Function<135.40305314/2 in Nx.Defn.Compiler.fun/2> cache miss in 258.2ms
12:27:55.992 [debug] EXLA device 0 lock in 0.0ms
12:27:55.992 [debug] EXLA execution on device 0 in 0.2ms
12:27:55.992 [debug] Axon.Loop finished initializing loop state in 260.8ms
12:27:55.992 [debug] Axon.Loop started running epoch 0
12:27:55.993 [debug] Axon.Loop started batch step execution
12:27:55.993 [debug] EXLA defn evaluation #Function<2.47039548/4 in Axon.Loop.build_batch_fn/2> cache miss in 0.8ms
12:27:56.170 [debug] EXLA compilation #Function<2.47039548/4 in Axon.Loop.build_batch_fn/2> cache miss in 176.5ms
<!-- livebook:{"persist_outputs":true} -->
# Random Normal - issue with defn
## Section
```elixir
Mix.install([
{:exla, "~> 0.1.0-dev", github: "elixir-nx/nx", sparse: "exla"},
{:nx, "~> 0.1.0-dev", github: "elixir-nx/nx", sparse: "nx", override: true}
@nickgnd
nickgnd / poodir-notes.md
Created March 12, 2016 13:51 — forked from speric/poodir-notes.md
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
@nickgnd
nickgnd / Sublime Settings
Last active July 29, 2016 09:37
Sublime Text 3.0 config
// Standard user configurations
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
@nickgnd
nickgnd / jenkins_rvm.Dockerfile
Last active March 21, 2018 21:10
Jenkins and RVM with Ruby 2.2.3 - Docker image
# v1.0
# November 21, 2015
FROM jenkins:latest
MAINTAINER NickGnd "nick.gnd@gmail.com"
# https://github.com/jenkinsci/docker/blob/4fa9ebc13069fa8186728622cd63702cddf11162/Dockerfile
ENV RUBY_VERSION 2.2.3
# --handlerCountStartup = set the no of worker threads to spawn at startup. Default is 5