Skip to content

Instantly share code, notes, and snippets.

View cosimo's full-sized avatar
🇳🇴

Cosimo Streppone cosimo

🇳🇴
View GitHub Profile
@cosimo
cosimo / migrate-templates.py
Created May 8, 2024 15:52
Migrate Sendgrid templates between different accounts
"""
Migrates SendGrid templates from one account to another.
Requires a `.env` file with the following variables:
- SOURCE_SENDGRID_API_KEY
- DESTINATION_SENDGRID_API_KEY
There is not much error handling here. This is not a place of honor.
It turned out to run quite smoothly still.
"""
@cosimo
cosimo / Dockerfile
Created May 6, 2024 12:28
Dockerfile to build varnish modules and vmod_dynamic
# Build the dynamic and vsthrottle Varnish modules from source.
FROM ubuntu:20.04
ENV TZ=Etc/UTC
ENV VARNISH_VERSION 7.4
# Avoid tzdata terminal configuration that would halt the build
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
@cosimo
cosimo / parse-options.sh
Created September 21, 2012 09:31
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@cosimo
cosimo / Dockerfile
Last active March 25, 2024 15:42
Dockerfile to build libvmod-dynamic 7.4 (https://github.com/nigoroll/libvmod-dynamic)
# Build libvmod_dynamic.so from source (https://github.com/nigoroll/libvmod-dynamic@7.4)
FROM ubuntu:20.04
ENV TZ=Etc/UTC
ENV VARNISH_VERSION 7.4
# Avoid tzdata terminal configuration that would halt the build
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
@cosimo
cosimo / hetzner.vimrc
Last active February 29, 2024 13:03
Hetzner rescue mode /root/.vimrc file
"=======================================================================
" Vim settings file by Andreas Schneider <mail at cynapses.org>
" with parts from Ciaran McCreesh <ciaranm at gentoo.org>
" and Sven Guckes <setup-vimrc.forall at guckes.net>
"
" Most recent update: Do Mär 01 11:35:54 CET 2007
"
" Get the latest version from:
" http://www.cynapses.org/tmp/setup/
"
@cosimo
cosimo / find-unused-css-selectors.pl
Created July 26, 2012 14:09
Find unused CSS selectors across a list of URLs
#!/usr/bin/env perl
#
# Find unused CSS selectors by crawling a list of URLs
# (--url, even more than one) and matching all elements in
# a page to find out which selectors are never used across
# all given URLs
#
# Usage:
# ./find-unused-css-selectors.pl --css file.css --url http://some.url [--url http://some.other.url ...]
#
@cosimo
cosimo / disable_cb_access_scanner.sh
Created June 24, 2021 13:24
Disable the Couchbase Bucket Access Scanner to avoid micro outages
#!/bin/bash
#
# Disables the Couchbase access scanner on a list of buckets
# Access scanner can cause short outages when buckets are very large.
#
set -e -x
USER='Administrator'
@cosimo
cosimo / wget-exit-codes.txt
Last active September 15, 2023 10:09
wget exit codes
This is the list of exit codes for wget:
0 No problems occurred
1 Generic error code
2 Parse error — for instance, when parsing command-line options, the .wgetrc or .netrc…
3 File I/O error
4 Network failure
5 SSL verification failure
6 Username/password authentication failure
7 Protocol errors
@cosimo
cosimo / wss.py
Created August 29, 2023 08:44
Python: connect to a websocket and send a message without any asyncio complications
#
# Requirements:
# - websocket-client==1.6.2
#
from websocket import create_connection
def select_origin_header(extra_headers):
origin = None
@cosimo
cosimo / py3-poetry-ci.yml
Created March 30, 2023 15:36
GHA ci workflow for Python 3 projects based on Poetry
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
ci:
strategy: