Skip to content

Instantly share code, notes, and snippets.

View countless-integers's full-sized avatar

Adrian countless-integers

View GitHub Profile
@countless-integers
countless-integers / bash_arg_parser.sh
Last active July 28, 2022 15:08
Bash argument parser supporting long options and positional arguments alike
#!/bin/bash
# @source: https://medium.com/@Drew_Stokes/bash-argument-parsing-54f3b81a6a8f
PARAMS=""
while (( "$#" )); do
case "$1" in
-a|--my-boolean-flag)
MY_FLAG=0
shift
@countless-integers
countless-integers / update-ide-helper-files
Created July 23, 2020 12:40
slow and round-about way of updating my ide-helper files
#!/bin/bash
COMPOSER_MEMORY_LIMIT=-1 composer require --dev barryvdh/laravel-ide-helper
php artisan ide-helper:generate
php artisan ide-helper:meta
COMPOSER_MEMORY_LIMIT=-1 composer remove barryvdh/laravel-ide-helper
@countless-integers
countless-integers / check-expiring-certificates-template.py
Created July 8, 2020 15:48
A quick and dirty script to help with checking page certificate expiry dates. It's in Python2 for compatibility reasons, so logic was redacted to serve as a template and not ready-made solution.
#!/usr/bin/env python2
from os import environ
import datetime
import socket
import ssl
import logging
from urllib2 import Request, urlopen, URLError, HTTPError
import json
@countless-integers
countless-integers / kube-log.sh
Created January 6, 2017 12:23
tail logs from kubernetes pod
#!/bin/bash
podId=$(kubectl get pod -o name | \
grep --color=never -o -E \
"\/.*$(echo $@ | tr '_ ' '.').*" \
)
podId=$(echo $podId | sed 's/ .*//g' | tr -d '/')
echo Showing logs from $podId
kubectl logs $podId --tail=20 -f
@countless-integers
countless-integers / mongo_collections_counts.js
Created January 4, 2017 12:41
Dummy collection count in mongodb
var collections = db.getCollectionNames();
collections.forEach(function (item) {
print(item + ": " + db[item].stats().count);
});
@countless-integers
countless-integers / remove_strict_types_spaces
Created August 16, 2016 13:00
remove whitespace from strict type declarations in php7
#!/bin/bash
ag -l 'strict_types = 1' src tests | xargs -I{} sed -i "" 's/strict_types = 1/strict_types=1/' {}
@countless-integers
countless-integers / docker-run
Created June 9, 2016 12:05
run command inside a docker container assuming your container is named the same as the current folder (very specific, I know :))
#!/bin/bash
docker exec -it $(basename `pwd`) $@
#!/bin/bash
# head -n200 /dev/urandom | cksum :: get output from urand and 'convert' it to dec; not exactly perfect
# sed :: remove anything that's NaN (e.g. spaces)
# head :: make the generated rand number 10 digits long
head -n200 /dev/urandom | cksum | sed -E 's/[^0-9]+//' | head -c 10
set @i = 1;
update table
set field = @i := @i + 1
where field2 = 11;
@countless-integers
countless-integers / replacer
Created May 2, 2016 07:57
refactoring aid [WIP]
#!/bin/bash
ag -l '$1' | xargs -I{} sed -ibak 's/$1/$2/' {}