Skip to content

Instantly share code, notes, and snippets.

View heri16's full-sized avatar

Heri Sim heri16

View GitHub Profile
@heri16
heri16 / erlang-macos.sh
Created July 27, 2023 19:45
Erlang for bun:ffi
# Install asdf
brew install coreutils git
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.12.0
cat <<EOF >> ~/.zshrc
. "$HOME/.asdf/asdf.sh"
# append completions to fpath
fpath=(${ASDF_DIR}/completions $fpath)
# initialise completions with ZSH's compinit
autoload -Uz compinit && compinit
EOF
@heri16
heri16 / cloud-config.yml
Last active July 3, 2023 14:36
RancherOS cloud-init
#cloud-config
# Validate: sudo ros config validate -i cloud-config.yml
# Usage: sudo ros install -c https://bit.ly/ros-cloud-config -d /dev/sda -s --append "rancher.autologin=tty1 rancher.autologin=ttyS0"
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCsnVbSuI95xB2jvcTysn0tAeQfm0zVNWYuqB0xVWiAQIyMWjSbDiXGHxHlP980Dqz1Yq3rOjXQBK2Dfi9FnpLXybQZr/VwOxPOLfisbez49UgI1uPfg/bzQB8ezqn0qDgnnLxEOldeoE0w0gUwQs1tMw5kt9wvsACc2VdYiT1B3iKmckPUfNT0SikkZ5yW/YBrvLP2M1m3Ip4i8MGRi8CfpuRuH6Yt6da9MPe7FK4IsSpVUbQPwKF0TUB0mA5SFtZvjnqgQUxLAANGQcwPDXqiOiXZYb2yRPDeuSerN35BcX2NtS0yW+bgqOfTDA9BXWBdSZ1JLzhSHmgPNmgeHOqzcEhXGPa7qtPACKgg8C9zaevFCENBlCo8ybIi00SICLiEGKPhgfr8UPT6+z5B6k+HinMKvCMfn5LcaTOeGXxS/BNDnQveToOZ0wcD3hA8/OZlP7hth55BNJoscornj0Vma9qQUeY6UxffypbY4uo4eZA+i8su9Sv01XMFQO0SdBg00l+dPM6wugtVOUwDuKrBwKb0kubZsWKz5jxKcsgABoxUUPiN/7a3KbToYeRi8zxZKkD5HFpvMT1AGqOHv0aIMc+iyFPXYk1MIrvPnTuViJ/haLHdMdDbw9fuKLfNQcGi07Xb4AfE7caAGJyGgjMcTaQ3lu8eJbVJNpjK/nIfyw== Heri-no-iPhone
rancher:
console: ubuntu # https://rancher.com/docs/
@heri16
heri16 / Caddyfile.sh
Last active April 29, 2023 00:13
Self-signed Cert for Netflix
#!/bin/bash
cat <<EOF > /usr/local/etc/Caddyfile
https://ipv4-c001-sin001-ix.1.oca.nflxvideo.net {
tls /usr/local/etc/oca.nflxvideo.net.crt /usr/local/etc/oca.nflxvideo.net.key
proxy / https://$(dig @208.67.222.222 -p 443 +tcp +short ipv4-c001-sin001-ix.1.oca.nflxvideo.net) {
header_upstream Host {host}
insecure_skip_verify
}
}
@heri16
heri16 / Dockerfile
Last active April 6, 2023 08:53
Automate login to keybase using Expect TCL
FROM keybaseio/client:stable-slim
RUN apt-get update && apt-get install -y expect
COPY keybase-provision.sh /provision.sh
RUN chmod +x /provision.sh
CMD ["/provision.sh", "keybase", "chat", "send", "--channel", "'#general'", "stockbitcrypto", "'Hello World from bot'"]
package main
import (
"fmt"
"net/http"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
@heri16
heri16 / bgpd.conf
Last active February 21, 2023 05:40
AWS VPC VPN StrongSwan Virtual Tunnel Interface (VTI)
#@ /etc/quagga/bgpd.conf (Centos & Ubuntu)
hostname <Local OS hostname>
password <Any random phrase>
enable password <Any random phrase>
!
log file /var/log/quagga/bgpd
!debug bgp events
!debug bgp zebra
debug bgp updates
@heri16
heri16 / slice.go
Created July 26, 2021 10:50
Golang - convert slice such as []string to []interface{}
module slice
func InterfaceSlice(slice interface{}) []interface{} {
switch slice := slice.(type) {
case []string:
new := make([]interface{}, len(slice))
for i, v := range slice {
new[i] = v
}
return new
@heri16
heri16 / README.md
Last active March 23, 2022 04:02
Download / Record Youtube Live stream
@heri16
heri16 / NetwatchGatewayStates.rsc
Last active December 19, 2021 11:13
Mikrotik RouterOS Script to do proper uplink failover/failback (more reliable than Netwatch)
# Mikrotik RouterOS Script to do proper uplink failover/failback (more reliable than Netwatch).
# Supports both Generic and PPPoE interfaces.
# Policy: read, write, policy, test
### Configuration ###
# Define Names of all Interfaces that will be checked:
:local "interface-names" { "internet-speedy";"internet-biznet" };
@heri16
heri16 / flatten_array.ex
Created August 26, 2021 16:19
Elixir Flatten array (with tail recursion)
defmodule FlattenArray do
@doc """
Accept a list and return the list flattened without nil values.
## Examples
iex> FlattenArray.flatten([1, [2], 3, nil])
[1,2,3]
iex> FlattenArray.flatten([nil, nil])