Skip to content

Instantly share code, notes, and snippets.

@Grynn
Grynn / ip_address_list.py
Last active April 12, 2024 13:46
Show all IP addresses with scope in a nice table format
#!/usr/bin/env python
import sys
import os
import json
import pandas as pd
import ipaddress
private_ranges = [
ipaddress.IPv4Network("10.0.0.0/8"),
ipaddress.IPv4Network("172.16.0.0/12"),
@Grynn
Grynn / post_receive
Created March 12, 2023 17:02
post_receive_hook
#!/bin/bash
# Post recv. hook to run deploy.sh from within repo in checkout dir
set -e -u -o nounset
echo "ARGS****************"
read oldrev newrev ref
echo "OLD=$oldrev" "NEW=$newrev" "REF=$ref"
echo "********************"
@Grynn
Grynn / get-ip-addresses.sh
Created February 3, 2023 10:00
Get list of global IP addresses on a computer using ip2 command line
#!/bin/bash
set -eu -o pipefail
ip -j a | jq -r '.[] | .addr_info | map(select(.scope == "global")) | .[] | [ .family, .local ] | @csv'
@Grynn
Grynn / pve-ssl-renew.sh
Created September 14, 2020 19:28
Script to renew Proxmox 3.4 SSL Cert (for proxmox management interface)
#!/bin/bash
#Tested with pve-manager/3.4-16/40ccc11c Promox 3.4
servername="your.server.here"
set -e -x
/usr/local/sbin/certbot-auto --no-self-upgrade renew >> /var/log/le-renew.log
cp /etc/letsencrypt/live/${servername}/fullchain.pem /etc/pve/local/pve-ssl.pem
cp /etc/letsencrypt/live/${servername}/privkey.pem /etc/pve/local/pve-ssl.key
@Grynn
Grynn / tails.sh
Created September 6, 2020 10:56
Install tailscale
curl https://pkgs.tailscale.com/stable/ubuntu/`lsb_release -cs`.gpg | sudo apt-key add -
curl https://pkgs.tailscale.com/stable/ubuntu/`lsb_release -cs`.list | sudo tee /etc/apt/sources.list.d/tailscale.list
sudo apt update
sudo apt install tailscale
@Grynn
Grynn / download-origins.sh
Last active July 20, 2020 16:29
crux-extract-origins
#!/bin/zsh
##Does not work with glocud version 298-301 (should be fixed in 302)
##https://github.com/GoogleCloudPlatform/gsutil/issues/1052
set -e -x -o pipefail
#Check tools
function check() {
which $1 >/dev/null || ( echo "$1 is needed; try brew install $1" ; exit 77 ; );
if [ "$?" -eq 77 ]; then exit; fi
@Grynn
Grynn / work-in-progress.js
Created May 15, 2020 15:47
Backup House Creatives
googletag.cmd.push(function() {
googletag.pubads().addEventListener('slotRenderEnded', function(e) {
let node = document.getElementById(e.slot.getSlotElementId());
if (e.isEmpty)
{
node.innerHTML = `
<p>NO CREATIVE</p>
<ul><li>Fade background?</li>
<li>Put a fake creative / hardcoded?</li>
</ul>
@Grynn
Grynn / queue.sh
Created November 22, 2017 18:54
flock
#!/bin/bash
> log.txt
for i in {1..10}; do
flock /root/lockfile -c "./worker $i >> log.txt" &
done;
@Grynn
Grynn / brew_me_up.sh
Created July 12, 2016 18:52
Homebrew + Cask + VSCode
#!/bin/bash
# Install Homebrew, Cask, git and some gnu tools (gsed == Gnu sed, gawk = Gnu awk, gfind = Gnu find)
set -e
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew install git gawk gsed gfind
brew cask install visual-studio-code

Deployment Note

To deploy code you need SSH access to the server on which code is to be deployed. In particular the server need not have any private or deployment keys which give it access to github. The server merely needs to be configure with public keys.

Directory structure on deployment server:

We assume the deployment server is Debian or a derivative like Ubuntu. By convention web-apps are deployed to /var/www/sitename.com. This will work with both Apache & Nginx.

/var/www/sitename.com: