Skip to content

Instantly share code, notes, and snippets.

View brettinternet's full-sized avatar
👋

Brett brettinternet

👋
View GitHub Profile
@aricart
aricart / README.md
Last active August 11, 2024 06:20
Sharing Jetstream

JetStream Stream Sharing

This is an incremental tutorial on how to share JetStream assets between accounts. The options are not going to be fully explained unless they are vital. The tools used are nats cli and nsc, and both have excellent --help.

Note that this tutorial is expected to be followed in sequence.

Prerequisites

  • Understand imports and exports and JWT
def accept(port) do
{:ok, socket} =
:gen_tcp.listen(port, [:binary, active: false, reuseaddr: true, packet: 0, nodelay: true])
Logger.info("Accepting connections on port #{port}")
loop_acceptor(socket)
end
defp loop_acceptor(socket) do
{:ok, client_conn} = :gen_tcp.accept(socket)
@G33kDude
G33kDude / EasyStreamDeck.ahk
Created March 12, 2022 19:20
Launch AutoHotkey code from a StreamDeck efficiently using GET requests
#NoEnv
#Persistent
SetBatchLines, -1
#Include <Socket>
/*
Launch AutoHotkey code from a StreamDeck efficiently using GET requests
@Th3Whit3Wolf
Th3Whit3Wolf / arch_sec_install.sh
Last active August 26, 2024 04:24
Install arch on btrfs(w/ swapfile) on luks with rEFInd bootloader
#!/bin/bash
# 0 - SSH
# This isn't necessary but if you ssh into the computer all the other steps are copy and paste
# Set a password for root
passwd
# Get network access
iwctl
"""
@fabiolimace
fabiolimace / UUIDv6.sql
Last active September 16, 2024 08:02
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023-2024 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
  1. Open Automator.app
  2. Create new Quick Action
  3. Select Run AppleScript
  4. Add this:
set inputVolume to input volume of (get volume settings)
if inputVolume = 0 then
	set inputVolume to 100
	display notification "Volume set to 100" with title "✅ Microphone is on"
@atomkirk
atomkirk / hungarian.ex
Last active January 8, 2023 20:25
Hungarian/Munkres algorithm in Elixir
defmodule Hungarian do
@moduledoc """
Written by Adam Kirk – Jan 18, 2020
Most helpful resources used:
https://www.youtube.com/watch?v=dQDZNHwuuOY
https://www.youtube.com/watch?v=cQ5MsiGaDY8
https://www.geeksforgeeks.org/hungarian-algorithm-assignment-problem-set-1-introduction/
@alvises
alvises / app.exs
Created November 22, 2019 17:42
app.exs test script which connects two Elixir nodes running in two containers
IO.puts("I'm here! Sleeping for 2 seconds")
Process.sleep 2_000 # waiting for the other node
nodes = MapSet.new([:app@app1, :app@app2])
other_node =
nodes
|> MapSet.delete(Node.self())
|> MapSet.to_list()
|> List.first()
@sb8244
sb8244 / cluster_loader_balancer.ex
Created July 30, 2019 19:59
ClusterLoadBalancer for balancing anything (WebSocket) across a cluster
# We use this ClusterLoadBalancer to prevent hot nodes in our load balanced setup.
# The WebSockets are provided by Phoenix through the PushEx application https://github.com/pushex-project/pushex/
# The load balancer's `Worker` module is where the bulk of the cluster orchestration happens, using pg2 for cross node communication
defmodule ClusterLoadBalancer.Behavior do
@moduledoc """
Behavior for implementing a ClusterLoadBalancer compatible tool.
"""
@callback count() :: number
@ysimonson
ysimonson / bluetooth_sleep.lua
Last active June 29, 2024 18:25
Hammerspoon script to disable bluetooth when the computer is put to sleep. Requires `blueutil` to be installed (`brew install blueutil`).
require "string"
function checkBluetoothResult(rc, stderr, stderr)
if rc ~= 0 then
print(string.format("Unexpected result executing `blueutil`: rc=%d stderr=%s stdout=%s", rc, stderr, stdout))
end
end
function bluetooth(power)
print("Setting bluetooth to " .. power)