Skip to content

Instantly share code, notes, and snippets.

View rkennesson's full-sized avatar
:octocat:
I may be slow to respond.

Richard Kennesson rkennesson

:octocat:
I may be slow to respond.
View GitHub Profile
@rkennesson
rkennesson / escaped-shutdown-message.sh
Created September 22, 2019 18:53
create message argument for shutdown command without manually escaping characters
sudo shutdown -r 15 $(cat <<EOF;
2015-11-07T03:34:41Z app[postgres.0000]: [TAG] text-search query doesn't contain lexemes: ""
EOF)
timeout 300s bash -c "until ping -c10 hostother; do false; done"
#https://serverfault.com/a/510931
def my_round(x, prec=2, base=0.05): return (base * (np.array(x) / base).round()).round(prec)
Make a POST Request (TLDR: Use -X POST argument)
Add POST Data to a Request (TLDR: Use -d var=val argument)
Construct a Query String (TLDR: Use -G argument)
Add HTTP Headers (TLDR: Use -H 'Header: Value' argument)
Change the User Agent (TLDR: Use -A 'User Agent' argument)
Set Cookies (TLDR: Use -b name=value argument)
Add a Referrer (TLDR: Use -e URL argument)
Follow a 3XX Redirect (TLDR: Use -L argument)
Use the Basic HTTP Authentication (TLDR: Use -u user:pass argument)
Print the Response Headers (TLDR: Use -i argument)
@rkennesson
rkennesson / gitsize.sh
Last active August 14, 2019 22:03
get size of git repo
#!/usr/bin/env bash
#https://stackoverflow.com/a/30494746
if [ "$#" -eq 2 ]; then
echo "$(echo "$(curl https://api.github.com/repos/$1/$2 2>/dev/null | grep size | tail -1 | tr -dc '[:digit:]')") KB"
elif [ "$#" -eq 1 ]; then
echo "$(echo "$(curl $1 2>/dev/null | grep size | tail -1 | tr -dc '[:digit:]')") KB"
#elif [ "$#" -eq 3 ] && [ "$1" == "-z" ]; then
# edit: Content-Length doesn't appear to show up anymore for a git repo. A 404 repo shows Content-Length of 15 but otherwise the
# field is non-existant
//https://www.jennyscrayoncollection.com/2018/10/complete-list-of-retired-crayola-crayon.html
[
{
"name": "Almond",
"value": "#EFDECD",
},
{
"name": "Antique Brass",
"value": "#CD9575",
},
--[[
#=====================================================================================
# arcolinux
# Date : package-date
# Author : Erik Dubois at http://www.erikdubois.be
# Version : package-version
# License : Distributed under the terms of GNU GPL version 2 or later
# Documentation : http://erikdubois.be/
#======================================================================================
# CONKY
#!/usr/bin/env bash
if ps aux | grep qemu | grep "guest="; then
mode='performance'
else
mode='powersave'
fi
cpus=$(grep -c processor /proc/cpuinfo 2>/dev/null)
date=$(date "+%d.%m.%Y %T")
#
# 4chan Webm Downloader
# Fetches all webms from a thread
# filters out all the .webm files
# and downloads to a custom path
# using wget
#
# Requires
# nokogiri: gem install nokogiri
#
function topcommands () {
#usage: topcommands [n]
# default is top 10 commands
if [ "$1" == "" ]; then
history | awk '{c[$2]++}END{for(i in c){print c[i] " " i}}' | sort -rn | head
else
history | awk '{c[$2]++}END{for(i in c){print c[i] " " i}}' | sort -rn | head -n "$1"
fi
}