Skip to content

Instantly share code, notes, and snippets.

View capitalist's full-sized avatar
🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
View GitHub Profile
#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)

Have GPT-4 write a song

Mix.install(
  [
    {:midiex, "~> 0.6.1"},
    {:instructor, "~> 0.0.5"}
  ],
  config: [
    instructor: [
@hugobarauna
hugobarauna / kino_json_input_poc.livemd
Last active April 9, 2024 15:06
Kino JSON input with syntax highlight

Kino JSON Input Proof of Concept

Mix.install([
  {:kino, "~> 0.12.3"},
  {:jason, "~> 1.4"}
])
@adtac
adtac / Dockerfile
Last active April 13, 2024 22:33
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@mxgrn
mxgrn / lv_modal_close_confirm.md
Last active April 11, 2024 06:42
LiveView modal close confirmation on dirty form
@bratsche
bratsche / notes.txt
Created December 11, 2023 16:25
Notes for why I think Elixir is worth using
Notes on why I think Elixir is worth using for us
* Phoenix Channels - able to support 2 million concurrent clients on a single server.
* Node.js has an equivalent feature called SocketIO
* Ruby on Rails has an equivalent feature called ActionCable
* Not aware of any similar feature in Python
* Concurrency
* Ruby, restricted by a GIL
* Python, restricted by a GIL, but there is a proposal to remove it. Not sure how long it will take to remove it.
* Node.js, single-threaded async
@brainlid
brainlid / index.ex
Last active February 14, 2024 21:22
Example files for a LiveView blog post that starts an async process using Phoenix Async Assigns to perform work and send message back to the LiveView. https://fly.io/phoenix-files/abusing-liveview-new-async-assigns-feature/
defmodule MyAppyWeb.TaskTestLive.Index do
use MyAppyWeb, :live_view
require Logger
alias Phoenix.LiveView.AsyncResult
@impl true
def mount(_params, _session, socket) do
socket =
socket
|> assign(:async_result, %AsyncResult{})
@brainlid
brainlid / index.ex
Last active November 14, 2023 17:23
Example files for a LiveView blog post that starts an async Task to perform work and send message back to the LiveView. https://fly.io/phoenix-files/star-cross-live-view-processes/
defmodule MyAppyWeb.TaskTestLive.Index do
use MyAppWeb, :live_view
require Logger
@impl true
def mount(_params, _session, socket) do
# Trap exits to catch when a Task is forcibly cancelled.
Process.flag(:trap_exit, true)
socket =
@toranb
toranb / speech_to_text.exs
Created April 23, 2023 16:53
single liveview file showing speech to text with bumblebee and whisper
Application.put_env(:sample, PhoenixDemo.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 8080],
server: true,
live_view: [signing_salt: "bumblebee"],
secret_key_base: String.duplicate("b", 64),
pubsub_server: PhoenixDemo.PubSub
)
Mix.install([
{:plug_cowboy, "~> 2.6"},

Ecto Vis

Mix.install([
  {:kino, "~> 0.6.2"},
  {:kino_vega_lite, "~> 0.1.1"},
  {:ecto, "~> 3.8"},
  {:libgraph, "~> 0.16.0"}
])