Skip to content

Instantly share code, notes, and snippets.

View countless-integers's full-sized avatar

Adrian countless-integers

View GitHub Profile
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
Tail project log
OPTIONS:
@countless-integers
countless-integers / PHP memoization test #1
Created May 26, 2015 14:42
PHP memoization test using static function var
<?php
class Broom
{
public function rememberMe()
{
static $outcome;
if ($outcome) return $outcome;
return $outcome = rand();
}
@countless-integers
countless-integers / listBranchesAge.sh
Last active January 14, 2016 08:57
listing git branches with their age ordered from oldest
for k in `git branch -a | grep origin | grep -v HEAD | sed s/^..//`; do
echo -e `git log -1 --pretty=format:"%ci %cr" "$k"`\\t"$k";
done | sort
@countless-integers
countless-integers / delete_branches_older_than.sh
Last active April 10, 2020 13:26 — forked from antonio/delete_branches_older_than.sh
Script to delete branches older than a certain date
#!/bin/bash
dry_run=0
usage()
{
cat << EOF
usage: $0 [-n] ["string_to_date"]
Remove branches older than specified, human-readable date passed as a param
@countless-integers
countless-integers / objectElipsis.js
Created March 4, 2016 08:07
object values elipsis using lodash
if (typeof _ !== 'function') {
throw new Error('This is only intended for lodash use');
}
// "test" object
var obj = {
name: {
last: "Hello",
nofd: ['nope', 'hoope'],
},
@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/' {}
set @i = 1;
update table
set field = @i := @i + 1
where field2 = 11;
#!/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
@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`) $@
@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/' {}