Skip to content

Instantly share code, notes, and snippets.

openssl s_client -showcerts -connect github.com:443
# Or check a file:
openssl x509 -text -noout -in cartificate.crt
@jbruggem
jbruggem / sort-git-branches.sh
Last active September 20, 2019 18:44
Sort git branches by age
# source: https://stackoverflow.com/a/5188364
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
@jbruggem
jbruggem / prune_repos.sh
Created May 17, 2019 20:20
Prune git repository branches
#!/bin/bash
cd $(dirname $0)
find -name .git -type d \
| xargs -i dirname "{}" \
| xargs -i bash -c '
cd {};
echo -e "\n\n==========="
echo -e " {} "
@jbruggem
jbruggem / debug.exs
Created April 18, 2019 12:31
Debugging Elixir Registry
# Taken from: https://stackoverflow.com/a/50907591
registry_module = My.Registry
{_kind, _partitions, table, _pid_ets, _} = :ets.lookup_element(registry_module, -1, 2)
:ets.select(table, [{:"$1", [], [:"$1"]}])
@jbruggem
jbruggem / running_processes.ex
Last active September 20, 2019 12:43
Elixir running processes
("================\n"
<> (Process.list()
|> Enum.map(&Process.info/1)
|> Enum.map(&(&1 |> Access.get(:registered_name)))
|> Enum.filter(&(&1))
|> Enum.join("\n"))
<> "\n================")
|> IO.puts()
@jbruggem
jbruggem / bluetooth_reconnect.sh
Last active April 17, 2020 11:54
Disconnect / Reconnect bluetooth because there's a bug with WH-1000XM2
#!/usr/bin/expect -f
set prompt "#"
set address [lindex $argv 0]
spawn bluetoothctl
expect -re $prompt
send "disconnect $address\r"
expect "Successful disconnected"
expect -re $prompt
// ==UserScript==
// @name WaPo accept GDPR
// @version 1
// @grant none
// @include https://www.washingtonpost.com/gdpr-consent/*
// @namespace https://symzo.be/gm
// ==/UserScript==
function waitForContinueButton(then){
# at the end of ~/.bashrc
// ==UserScript==
// @name hubic delete
// @version 1
// @grant none
// @include https://hubic.com/home/*
// @require https://cdn.jsdelivr.net/npm/async@2.6.0/dist/async.min.js
// ==/UserScript==
var originalLocation;
// TODO: where does it hang ?
# use after a long running task to be notified using notify-send
# e.g.: `./tests.sh; notifydone`
alias notifydone="RES=\$?; while true; do echo \"done. Return value: \${RES}. Ctrl-C to stop notifications\"; notify-send 'Run ended' \"Execution return val: \${RES}\"; sleep 60; done"