Skip to content

Instantly share code, notes, and snippets.

@tmiller
tmiller / README.md
Last active February 2, 2024 20:41
A very simple example of using a map of channels for pub/sub in go.
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEYfa2iBYJKwYBBAHaRw8BAQdAozgbfu6aa4uXAglMgq9KYZ0dHnJxSFHxy/Bn
IM4Fc5+0H1RvbSBNaWxsZXIgPGdpdEBtZS50bWlsbGVyLmRldj6IkwQTFgoAOwUL
CQgHAgYVCgkICwIEFgIDAQIeAQIXgAIbARYhBNPyWk7Wje25hjqnVc8661gMX7YT
BQJh+Hv8AhkBAAoJEM8661gMX7YTugkBALKjXH4v/gagwmFvlotgvmNyGIfRy8yr
JTIzotEML7mBAP0UsV8o6VMzXTgqxumRmyUn0158sOMODqPFhP6T4Z8HBLgzBGH2
2LYWCSsGAQQB2kcPAQEHQIq4yLBAtPX2OMs/WoVclYL4xGtZU34E4R5epvmq9BBq
iPUEGBYIACYWIQTT8lpO1o3tuYY6p1XPOutYDF+2EwUCYfbYtgIbAgUJA8JnAACB
CRDPOutYDF+2E3YgBBkWCAAdFiEEkgbzn2DKoIjeAQwgprO6psG4YfwFAmH22LYA
@tmiller
tmiller / merge
Last active November 14, 2021 11:16
Bash script to merge master into all branches
#!/bin/bash
# Merges the master branch into all other branches
#
# Process:
#
# - Save the name of the current branch
# - If the current branch is not master then checkout master.
# - Pull the latest changes for master from its upstream branch.
# - Loop over each local branch.
diff --git a/io.c b/io.c
index 3707a69344..93b91e1450 100644
--- a/io.c
+++ b/io.c
@@ -20,6 +20,7 @@
#include <ctype.h>
#include <errno.h>
#include "ruby_atomic.h"
+#include <time.h>
# Configuration for Alacritty, the GPU enhanced terminal emulator
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty it self.
env:
# TERM env customization.
#
# If this property is not set, alacritty will set it to xterm-256color.
@tmiller
tmiller / init.sh
Last active July 19, 2018 12:35
DigitalOcean ubuntu 14.04 server configuration script.
#!/bin/bash
username="ubuntu"
ssh_pub_key=""
# Setup user
adduser $username
usermod -a -G sudo $username
sudo mkdir -p "/home/${username}/.ssh"
sudo echo "${ssh_pub_key}" > "/home/${username}/.ssh/authorized_keys"
@tmiller
tmiller / init.lua
Last active June 11, 2018 11:13
Replace moom and the likes with Hammerspoon
hs.window.animationDuration = 0
local screenMode = hs.hotkey.modal.new('cmd', 'm')
function screenMode:entered()
alertUuids = hs.fnutils.imap(hs.screen.allScreens(), function(screen)
return hs.alert.show('Move Window', hs.alert.defaultStyle, screen, true)
end)
end
function screenMode:exited()
defmodule TenderList do
def cons(x, y), do: fn(m) -> m.(x,y) end
def car(cell), do: cell.(fn(x, _) -> x end)
def cdr(cell), do: cell.(fn(_, y) -> y end)
def test do
list = cons(1, cons(2, cons(3, 4)))
IO.puts car(list)
defmodule ErrorMonad do
def return(x) do
{:ok, x}
end
def and_then(m, f) do
case m do
{:ok, v} -> f.(v)
err -> err
end
package main
import (
"bufio"
"crypto/tls"
"log"
"net"
)
func main() {