Skip to content

Instantly share code, notes, and snippets.

View jaeyson's full-sized avatar
🎯
Focusing

Jaeyson Anthony Y. ⚗️ jaeyson

🎯
Focusing
View GitHub Profile
@jaeyson
jaeyson / firewall.sh
Created October 30, 2024 13:18 — forked from andrasbacsai/firewall.sh
Update a Hetzner Firewall rule with your IP address
#!/bin/bash
# Script to update a firewall rule in a Hetzner Firewall with your current IP address.
# Good if you would like to restrict SSH access only for your current IP address (secure).
#################
# WARNING: This script will overwrite all rules in the firewall rules, so make sure you
# added all the required rules.
# I use a separate firewall rule just for SSH access.
#################
@jaeyson
jaeyson / observer.md
Created August 9, 2024 08:35 — forked from pnc/observer.md
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
@jaeyson
jaeyson / file_upload_using_req.exs
Created July 18, 2024 02:41
File Uploads Using the Req Elixir Library
defmodule Uploader do
@moduledoc """
Source: https://samrat.me/til-file-uploads-using-the-req-elixir-library
v0.4.5 of Req don't support file upload. Might as well use multipart
"""
def transcribe_audio(file_path, token) do
model = "whisper-1"
filename = Path.basename(file_path)
{:ok, file_contents} = File.read(file_path)
@jaeyson
jaeyson / zed_keybindings.json
Created June 14, 2024 06:26
Zed editor keybindings
[
{
"context": "Pane",
"bindings": {
"cmd-1": ["pane::ActivateItem", 0],
"cmd-2": ["pane::ActivateItem", 1],
"cmd-3": ["pane::ActivateItem", 2],
"cmd-4": ["pane::ActivateItem", 3],
"cmd-5": ["pane::ActivateItem", 4],
"cmd-6": ["pane::ActivateItem", 5],
<?php
ini_set('display_errors', 0);
include('includes/config.php');
include('includes/helpers/locale.php');
include('includes/helpers/integrations/zapier/triggers/functions.php');
include('includes/helpers/integrations/rules.php');
include('includes/helpers/subscription.php');
include('includes/helpers/EmailAddressValidator.php');
//--------------------------------------------------------------//
defmodule SchemaChecker do
def find_field_discrepancies do
schema_modules()
|> Enum.map(fn mod ->
{mod.__schema__(:source), check_module(mod)}
end)
end
defp schema_modules do
{:ok, modules} = :application.get_key(:core, :modules)
@jaeyson
jaeyson / test.exs
Created October 7, 2022 07:39
Submarine route command
data =
"""
forward 5
down 5
forward 8
up 3
down 8
forward 2
"""
-module(ring).
-export([start/0]).
% start/0 top function to run.
% c(ring).
% ring:start().
start() ->
% trace who (process) called the func (mod:func)
@jaeyson
jaeyson / diy-create-service-account.md
Created November 22, 2021 13:29
Roll-your-own gcp service account key

Roll-your-own gcp service account key

You can see the reason listed here -> source

TLDR; generate service account key file without transporting the private key.

1. Create service account

gcloud iam service-accounts create look-no-keys