Skip to content

Instantly share code, notes, and snippets.

View Wigny's full-sized avatar

Wígny Almeida Wigny

View GitHub Profile
@ChristianAlexander
ChristianAlexander / reqllm.livemd
Last active November 28, 2025 05:31
req_llm Demo Livebook

ReqLLM Demonstration

Mix.install([
  {:zoi, "0.8.1"},
  {:req_llm, github: "agentjido/req_llm", ref: "main"},
  {:kino, "~> 0.17.0"}
])
@rhcarvalho
rhcarvalho / batcher_demo.exs
Created August 29, 2024 09:20
Phoenix LiveView event batching
# Single-file Phoenix LiveView demo showing how to batch events to reduce/control the flow of UI updates.
#
# Run with `elixir batcher_demo.exs`, then open a browser at http://localhost:5001/.
#
# For comparison, the "inc" event is batched while the "dec" event is not.
#
# References
#
# https://github.com/phoenixframework/phoenix_live_view/blob/main/.github/single-file-samples/main.exs
# https://elixirforum.com/t/optimizing-liveview-for-realtime-applications-by-marlus-saraiva-elixirconf-eu-2023/59265?u=rhcarvalho
@velzie
velzie / manifest-v2-chrome.md
Last active November 27, 2025 19:57
How to keep using adblockers on chrome and chromium

NOTE

by the time you're reading this, this probably no longer works since the policy has been removed. I reccomend you to check out https://github.com/r58Playz/uBlock-mv3 instead

How to keep using adblockers on chrome and chromium

  1. google's manifest v3 has no analouge to the webRequestBlocking API, which is neccesary for (effective) adblockers to work
  2. starting in chrome version 127, the transition to mv3 will start cutting off the use of mv2 extensions alltogether
  3. this will inevitably piss of enterprises when their extensions don't work, so the ExtensionManifestV2Availability key was added and will presumably stay forever after enterprises complain enough

You can use this as a regular user, which will let you keep your mv2 extensions even after they're supposed to stop working

@chrismccord
chrismccord / dev.exs
Created May 8, 2024 20:06
Live Reload LiveView notify
config :wps, WPSWeb.Endpoint,
live_reload: [
notify: [
live_view: [
~r"lib/wps_web/core_components.ex$",
~r"lib/wps_web/(live|components)/.*(ex|heex)$"
]
],
patterns: [
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
Mix.install([:mint, :castore])
defmodule Main do
def run() do
total =
Stream.resource(
fn ->
{:ok, conn} = Mint.HTTP.connect(:https, "ftp.bit.nl", 443, mode: :passive)
{:ok, conn, _ref} = Mint.HTTP.request(conn, "GET", "/speedtest/10mb.bin", [], nil)
{conn, true}
@mcrumm
mcrumm / component_under_test.ex
Last active December 4, 2025 16:59
Testing Phoenix.LiveComponent in Isolation
# lib/party_web/components/example_component.ex
defmodule PartyWeb.ExampleComponent do
@moduledoc """
An example LiveComponent under test.
"""
use Phoenix.LiveComponent
def render(assigns) do
~H"""
<div>
@kamiaka
kamiaka / duration.ts
Last active September 29, 2024 05:38
Convert time durations on TypeScript (JavaScript)
export class DurationUnit {
constructor(public readonly value: number, public readonly name: string) {}
}
export const nanoSecond = new DurationUnit(1, 'ns');
export const microSecond = new DurationUnit(1000 * nanoSecond.value, 'µs');
export const milliSecond = new DurationUnit(1000 * microSecond.value, 'ms');
export const second = new DurationUnit(1000 * milliSecond.value, 's');
export const minute = new DurationUnit(60 * second.value, 'm');
export const hour = new DurationUnit(60 * minute.value, 'h');
@sharunkumar
sharunkumar / adb-dns.bat
Created February 7, 2020 07:08
Enabling / Disabling private DNS in android via ADB
rem to disable private dns
adb shell settings put global private_dns_mode off
rem to enable private dns with hostname (example with dns.adguard.com)
adb shell settings put global private_dns_mode hostname
adb shell settings put global private_dns_specifier dns.adguard.com
@char0n
char0n / api_data_structure.ex
Last active August 1, 2022 16:03
Model example how to use Ecto to validate nested JSON data in you API payloads
defmodule ApiDataStructure do
defmodule User do
use Ecto.Schema
import Ecto.Changeset
alias ApiDataStructure.Profile
embedded_schema do
field :username, :string
@seocam
seocam / csv2contabilizei_ofx.py
Last active December 28, 2024 21:20
Converte CSV para um arquivo OFX aceito pela contabilizei
#!/usr/bin/env python
import argparse
import calendar
import itertools as it
from datetime import datetime
from csv2ofx import utils
from csv2ofx.mappings.default import mapping
from csv2ofx.ofx import OFX