Skip to content

Instantly share code, notes, and snippets.

View keymon's full-sized avatar

Hector Rivas Gandara keymon

  • London, UK
  • 03:57 (UTC +01:00)
View GitHub Profile
@keymon
keymon / very secret stuff
Created December 17, 2020 17:10
my secret
-
@keymon
keymon / dns-check.go
Created May 5, 2020 08:05
DNS check of LB services
package main
import (
"context"
"fmt"
"net"
"sort"
"strings"
"time"
)
@keymon
keymon / hcl-set-value.rb
Created April 27, 2020 23:33
Set a value in HCL code with ruby
#!/usr/bin/env ruby
require 'tf/hcl'
require 'open3'
def terraform_fmt(input)
o, s = Open3.capture2(*%w[terraform fmt -], :stdin_data=>input)
return o
end
@keymon
keymon / release-binaries.sh
Created January 11, 2020 02:18
Release binaries to github using hub
#!/bin/bash
set -e -o pipefail -u
if [ "$#" -lt 1 ]; then
echo "Attaches files to the latest tag in github" 1>&2
echo "Usage: $0 [files...]" 1>&2
exit 1
fi
@keymon
keymon / gist:ce19faca07200ed16e0beb582eb193a9
Last active February 26, 2020 10:31
Whatsapp nativifier
# wget https://userstyles.org/styles/userjs/142096/dark-whatsapp-theme-by-mew.user.js -O Downloads/dark-whatsapp-theme-by-mew.user.js
wget https://userstyles.org/styles/userjs/142096/dark-whatsapp-by-vednoc.user.js -O Downloads/dark-whatsapp-by-vednoc.user.js
wget https://raw.githubusercontent.com/DocBox12/WhatsApp-nativefier-fix/master/whatsapp_fix.js -O Downloads/whatsapp_fix.js
cat Downloads/dark-whatsapp-by-vednoc.user.js Downloads/whatsapp_fix.js > Downloads/whasapp_inject.js
nativefier -n "whatsapp" --inject Downloads/whasapp_inject.js --tray --title-bar-style hidden --width 500 --height 400 --single-instance https://web.whatsapp.com/ nativefier-apps/
@keymon
keymon / gist:4da5ca73dda3fadd961160cdf6c2e87b
Last active July 13, 2022 08:46
Signing the kernel in ubuntu
# https://ubuntu.com/blog/how-to-sign-things-for-secure-boot
# generate the key and enroll it
cd /var/lib/shim-signed/mok
cat <<EOF > openssl.cnf
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
RANDFILE = \$ENV::HOME/.rnd
[ req ]
distinguished_name = $(hostname)
@keymon
keymon / gist:f0f8cf8ed386d69fa0d41b11eb42a3be
Created July 2, 2019 17:14
Check date of AWS token in bash
get_token_ttl() {
if [ -n "${AWS_CREDENTIAL_EXPIRE}" ]; then
if date --version 2>&1 | grep -q GNU; then
token_epoch="$(date -d "${AWS_CREDENTIAL_EXPIRE}" +%s)"
elif date --version 2>&1 | grep -q ymwdHMS; then
token_epoch="$(date -j -u -f '%Y-%m-%dT%H:%M:%SZ' "${AWS_CREDENTIAL_EXPIRE}" +%s)"
fi
current_epoch="$(date +%s)"
echo "$(( token_epoch - current_epoch ))"
fi
@keymon
keymon / rds-dbs.json
Created January 3, 2019 11:41
Small graphana dashboard for RDS metrics from CF with paas-rds-metrics-collector + paas-prometheus-exporter
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
#!/bin/bash
# s3-compare-last-versions.sh
set -eu -o pipefail
if [[ $# -ne 2 ]]; then
echo "Usage: `basename $0` <bucketName> <fileKey> "
exit 1
fi
@keymon
keymon / cf-curl-iterator.sh
Created December 10, 2018 13:21
Iterate `cf curl` responses page by page and group all the underlying `.resources[]`
#!/bin/bash
SCRIPT="$0"
set -eu -o pipefail
help() {
cat <<EOF
Executes a cf curl and iterates across all the pages returned by CF,
aggregating the resources in a big json.