Skip to content

Instantly share code, notes, and snippets.

@Grynn
Grynn / gist:23181f3e7c6b2273f5123901bfa0d28b
Last active November 30, 2024 11:12
Excel group by function
=LET(
groupColumn,D2:D9,
valueColumn,K2:K9,
uniqueGroups,UNIQUE(groupColumn),
aggregatedValues,SUMIF(groupColumn,uniqueGroups,valueColumn),
HSTACK(uniqueGroups,aggregatedValues)
)
@Grynn
Grynn / .profile
Last active November 1, 2024 10:10
VSCode remote quick launch
#Add to ~/.profile
function code() {
if ((( $# == 0 )) || [[ "$1" == "." ]]); then
echo "vscode://vscode-remote/ssh-remote+${USER}@gray:22${PWD}"
else
# convert relative path to absolute path
if [[ "$1" == /* ]]; then
echo "vscode://vscode-remote/ssh-remote+${USER}@gray:22$1"
else
echo "vscode://vscode-remote/ssh-remote+${USER}@gray:22${PWD}/$1"
@Grynn
Grynn / serve.sh
Created August 31, 2024 12:30
PHP live-reload dev helper
#!/usr/bin/env bash
set -e
trap_with_arg() { # from https://stackoverflow.com/a/2183063/804678
local func="$1"; shift
for sig in "$@"; do
trap "$func $sig" "$sig"
done
}
@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>