Skip to content

Instantly share code, notes, and snippets.

@tyzbit
tyzbit / bootstrap-ubuntu.sh
Last active July 17, 2023 14:03
bootstrap-ubuntu-server
#!/bin/bash
## Edit sudoers (add "NOPASSWD:" to the sudo line before ALL)
## Add optional: true to netplan and apply
## Add Google Kubernetes key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B53DC80D13EDEF05
# Install Docker
@zfarbp
zfarbp / arch.md
Last active April 8, 2024 21:32
Golang - Building Executables for Different Architectures

Golang - Building Executables for Different Architectures

env GOOS=target-OS GOARCH=target-architecture go build package-import-path

# Example
env GOOS=darwin GOARCH=amd64 go build
env GOOS=darwin GOARCH=amd64 go build main.go
env GOOS=darwin GOARCH=amd64 go build github.com/zoo/york/foo/bar
@mrfelton
mrfelton / unlock.sh
Last active July 30, 2019 07:29
Shell script to unlock lnd on system startup
#!/bin/bash
# Do nothing if the WALLET_PASSWORD var is not set.
if [ -z "$PASSWORD" ]; then
echo "[lnd_unlock] Please set PASSWORD in order to unlock wallet automatically."
s6-pause
fi
# output script content for easier debugging.
# set -x
# exit from script if error was raised.
set -e
@alexbosworth
alexbosworth / inotify-channel-backup.md
Last active March 29, 2024 01:33
Backup channel.backup file using systemd and inotify

LND backup script for channel.backup using inotify

Install inotify

sudo apt install inotify-tools

Create script to watch for changes and copy on change

@bretton
bretton / lightning-maps.md
Last active December 29, 2023 02:59
Visualisers of the Lightning Network (and some other explorers)

A (mostly) visual collection of the Lightning Network

Disclaimer

Network views tend to be the view of the network from a single node, or small selection of nodes. They are not complete views of the network. This is impossible to achieve. Even if many node views were combined, it would still be incomplete.

These network views, or network maps, have been termed 'visualisers' by the LN community.

Screenshots may reflect older visual styles, and are dated accordingly.

@bretton
bretton / monitor-lnd-balances.md
Last active January 24, 2018 21:33
monitor lnd wallet and channel balances

Short script to monitor walletbalance and channelbalance for LND, and log to csv file for later graphing. You need a working LND, and jq installed.

first setup by editing balances.txt and add a header line

date,walletbalance,channelbalance

add the following script, edit lndbalances.sh

#!/bin/bash
@knadh
knadh / zsh-elapsed-time.md
Last active April 20, 2024 06:35
Elapsed and execution time for commands in ZSH

Elapsed and execution time display for commands in ZSH

Append this to your ~/.zshrc file.

function preexec() {
 timer=$(($(date +%s%0N)/1000000))
^(?<timestamp>\w+\s+\d+,\s+\d+\s+\d+:\d+:\d+\.\d+)[^\]\n]*\]\s+(?<loglevel>\w+) - (?<full_message>(?:(?:Request: \[(?<request_ip>[^:]+).*Token \((?<username>[^)]+))?(?:\[?(?<status_source>[\w\s]+)((\]|: )))?(?:Adding (?<session_number>\d) sessions\.)?(?:Found session GUID of (?<session_guid>[^\s]+))??(?:Session (?<playback_session_guid>[^\s]+) \((?<playback_session_number>[^\)]+)\) is (?<placyback_session_status>\w+))?(?:using profile (?<transcode_profile>.*))?(?:.*\/transcode\/session\/(?<transcode_session_guid>[^\/]+))?(?:It took (?<time_taken>[\d\.]+) sec to (?<action_taken>.*))?)?(?:Content-Length of (?<file_path>.*\/(?<file_name>[\w\s]+\.(avi|mp4|mkv|m4v|wmv|mpg|mpeg|divx))(\s|$)))?.*)$
@acamino
acamino / README.md
Last active April 21, 2024 20:58
Shortcuts to Improve Your Bash & Zsh Productivity

Shortcut — Action

  • CTRL + A — Move to the beginning of the line
  • CTRL + E — Move to the end of the line
  • CTRL + [left arrow] — Move one word backward (on some systems this is ALT + B)
  • CTRL + [right arrow] — Move one word forward (on some systems this is ALT + F)
  • CTRL + U — (bash) Clear the characters on the line before the current cursor position
  • CTRL + U —(zsh) If you're using the zsh, this will clear the entire line
  • CTRL + K — Clear the characters on the line after the current cursor position
  • ESC + [backspace] — Delete the word in front of the cursor
@qizhihere
qizhihere / docker-entrypoint-example.sh
Created June 28, 2016 14:38
Run a process in a docker container with specific uid and gid. Take dropbox for example.
#!/usr/bin/env sh
has_gid () {
cut -d: -f1,4 /etc/passwd | grep -q "^${1}:${2}" || return 1
}
# example: ensure_user btsync 1000 1000
ensure_user () {
local user=$1
local uid=$2