Skip to content

Instantly share code, notes, and snippets.

View jaeyson's full-sized avatar
🎯
Focusing

Jaeyson Anthony Y. ⚗️ jaeyson

🎯
Focusing
View GitHub Profile
@thmsmlr
thmsmlr / README.md
Last active February 7, 2025 10:37
cmd+k for any terminal

These three scripts can provide you a cursor style CMD+K Like experience in any terminal.

How it works

  1. Set logged-shell to be your default shell for your terminal emulator. shell = /path/to/logged-shell in ~/.config/kitty/kitty.conf for kitty users.
  2. This will stream both the inputs and outputs of your terminal session into a file defined at $SHELL_LOG_FILE
  3. The ai-bash-command will take a user prompt, add the shell as context, and call OpenAI (with the ai command) to get the bash command that satisfies the prompt.
  4. It will type the results back into your terminal using wtype for wayland users.
@davydog187
davydog187 / bullshit.js
Last active October 12, 2024 14:34
Callback throttler
let timeout = null;
let requestCount = 0;
let queue = [];
function schedule(limit) {
if (!timeout) {
timeout = setTimeout(() => throttleQueue(limit), 1000)
}
}
@Innf107
Innf107 / data.md
Last active October 15, 2024 07:10
Programming is about information not data, or: you might not need dependent types

Programming is about information not data, or: you might not need dependent types

When I took "Fundamentals of Computer Science" in college, my professor was very adamant about the distinction between data and information and about how data doesn't have any inherent meaning. At the time, it seemed a bit silly to me how much emphasis he put on such a seemingly insignificant difference.

In retrospect, I think he was exactly right about this and I wish more programmers took it to heart.

Data is something you can store in a computer, such as, let's say, the byte 0b01000001.

defmodule AlchemistWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :alchemist
def call(conn, opts) do
conn
|> AlchemistWeb.ReplayPlug.call(AlchemistWeb.ReplayPlug.init(nil))
|> case do
%{halted: true} = conn -> conn
conn -> super(conn, opts)
end
@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)$",
@zachdaniel
zachdaniel / stream_distribute.ex
Last active June 15, 2024 14:06
A small demo to show how you might, given a stream, do a "fan out", processing different elements in separate streams. Powered by simple primitives like `Stream.resource` and `spawn_link`. Open in Livebook: https://livebook.dev/run?url=https%3A%2F%2Fgist.github.com%2Fzachdaniel%2Fd5ab06a9d2362fceeb6d27c37b206e28
<!-- livebook:{"persist_outputs":true} -->
# Distribute
## Section
A small toy to show how you might, given a stream, do a "fan out", processing different elements in separate streams. Powered by simple primitives like `Stream.resource` and `spawn_link`.
```elixir
defmodule Distribute do
@Valian
Valian / app.html.heex
Created May 2, 2024 17:34
Phoenix LiveView teleport hook
<.flash_group flash={@flash} />
<main>
<%= @inner_content %>
</main>
<%!-- We're doing teleport because navigation is rendered in root layout which is not updated --%>
<%!-- Notice "hidden" class, it's important because we're not really teleporting content, but duplicating it --%>
<div :if={@current_user} id="onboarding-render" phx-hook="teleport" data-teleport-target="onboarding" class="hidden">
<MyApp.Onboarding.onboarding current_user={@current_user} />

LiveView Forms

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)
)
@lucian
lucian / mostly-erlang-019-elixir-with-jose-valim-20131007.txt
Last active April 10, 2024 20:05
transcript for Mostly Erlang - episode 019 Elixir With José Valim / October 7, 2013
# --------------------------------------------------------------------------------------------
# Mostly Erlang - episode 019 Elixir With José Valim / October 7, 2013
#
# guests:
# - Joe Armstrong (@joeerl)
# - Robert Virding (@rvirding)
# - Jose Valim (@josevalim)
# - Fred Hebert (@mononcqc)
# - Eric Merit (@ericbmerritt)
#
defmodule MarkdownConverter do
import Phoenix.Component
def convert(filepath, body, _attrs, opts) do
convert_body(Path.extname(filepath), body, opts)
end
defp convert_body(extname, body, opts) when extname in [".md", ".markdown", ".livemd"] do
html =
Earmark.as_ast!(body, annotations: "%%")