Skip to content

Instantly share code, notes, and snippets.

View leobessa's full-sized avatar

Leonardo Bessa leobessa

View GitHub Profile
@leobessa
leobessa / 2024-cusip-prices.csv
Last active January 28, 2025 02:15
2024 asset closing prices by date and cusip
We can't make this file beautiful and searchable because it's too large.
2024-01-02,00123Q104,9.6600000000
2024-01-02,00130H105,19.3400000000
2024-01-02,00206R102,17.2500000000
2024-01-02,00206RHJ4,983.1800000000
2024-01-02,00206RKG6,886.8200000000
2024-01-02,00206RMM1,809.1800000000
2024-01-02,00214Q104,50.5000000000
2024-01-02,00214Q302,32.7200000000
2024-01-02,00214Q708,26.3300000000
2024-01-02,00215W100,9.0800000000
@rmtbb
rmtbb / ChatGPT Canvas HTML Renderer from Clipboard.url
Last active January 23, 2025 22:45
Bookmarklet that lets you render a full HTML page with any included css and javascript that is currently copied to your clipboard. Also works for SVG code. Useful with ChatGPT Canvas
javascript:(function(){try{navigator.clipboard.readText().then(function(t){if(t){var e=window.open("","_blank","width=800,height=600");e.document.open(),e.document.write(t),e.document.close()}else alert("Clipboard is empty. Please copy some text to the clipboard first.")}).catch(function(t){console.error("Failed to read clipboard contents: ",t),alert("An error occurred while trying to access the clipboard. Please ensure your browser allows clipboard access.")})}catch(t){console.error("An error occurred:",t),alert("An error occurred while trying to open the new window with the clipboard content.")}})();//bookmarklet_title: HTML Preview from Clipboard
@YurkoHoshko
YurkoHoshko / ollama_example.livemd
Last active September 27, 2024 19:04
Gist to run simple Livebook-based app that allows one-shot prompting with Ollama. Enjoy :) https://x.com/DJTechDebt/status/1818205498384036019

One-shot prompt with Ollama

Mix.install(
  [:ollama, :kino]
)

Simple one-shot chat :)

defmodule MyApp.Books.Book do
use Ecto.Schema
import Ecto.Query, warn: false
import Ecto.Changeset
import MyApp.ChangesetHelpers
schema "books" do
field :name, :string
field :genres, {:array, :string}, default: []
@brentjanderson
brentjanderson / README.md
Created June 14, 2022 15:53
Elixir runtime-controlled supervision tree using feature flags (circuit breaker)

These snippets provide a foundation for starting and stopping supervision trees at runtime using feature flags (e.g. Launch Darkly).

Some things to note when adapting these snippets:

  1. application.ex needs to be adapted into an existing application. The important part is that each child spec provided is compliant, and that there is a feature flag (ld_key) specified.
  2. As written, if a feature flag fails for some reason, it defaults to starting all children. There is room for adaptation here as needed.
  3. This implementation will still require a FeatureFlags module to be available that implements is_on?/2. Adjust as needed to accomodate your own feature flag setup.
@zblanco
zblanco / getting_lazy_with_dataflow_graphs_in_elixir.livemd
Last active January 30, 2025 00:49
Getting Lazy with Dataflow Graphs in Elixir

Getting Lazy with Dataflow Graphs in Elixir

Intro

What do Tensorflow, Apache Airflow, Rule Engines, and Excel have in common?

Under the hood they all use DAGs to model data-flow dependencies of the program. Using graphs to model programs is great because you can modify the program at runtime. Lets talk about doing this in Elixir for great good.

@LostKobrakai
LostKobrakai / form_live.ex
Last active April 16, 2025 10:08
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
@mrdotb
mrdotb / ex
Last active August 20, 2024 00:39
Phoenix hosts management
defmodule AppWeb.Host do
@moduledoc """
Conveniences for working with host.
"""
def root do
Keyword.get(get_config(), :root)
end
def root_uri do
Keyword.get(get_config(), :root_uri)
@angelikatyborska
angelikatyborska / gettext.ex
Last active October 9, 2024 21:10
A custom `gettext_with_link` macro for easily putting inline links into gettext strings
# Has one external dependency except for Gettext: https://github.com/rrrene/html_sanitize_ex
defmodule MyApp.Gettext do
@doc """
A helper for translations with links.
Pass in the translation string which must include
`%{link_start}`/`%{link_end}`. For multiple URLs, use
`%{link_start_<0,1,2...>}`.
@PJUllrich
PJUllrich / big-o.md
Last active February 13, 2025 23:48
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements