Skip to content

Instantly share code, notes, and snippets.

View nogorilla's full-sized avatar

Gabriel Smith nogorilla

  • Procter & Gamble
  • Cincinnati, Oh
View GitHub Profile
git log --format=format: --name-only --since="1 year ago" | sort | uniq -c | sort -nr | head -20
git shortlog -sn --no-merges
git log --format='%ad' --date=format:'%Y-%m' | sort | uniq -c
// go to https://twitter.com/settings/your_twitter_data/twitter_interests
var timer=1000; document.querySelectorAll( "div > input[type='checkbox']:checked" ).forEach((interest) => { setTimeout( function(){interest.click(); interest.scrollIntoView()},timer ); timer+=2000; });
@nogorilla
nogorilla / bucket.py
Created September 17, 2021 14:12
Delete all versions in S3 bucket
import boto3
session = boto3.Session()
s3 = session.resource(service_name='s3')
bucket = s3.Bucket('bucket-name')
bucket.object_versions.delete()
@nogorilla
nogorilla / script-template.sh
Last active October 3, 2024 16:52 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
Usage: $(basename "$0") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@nogorilla
nogorilla / log.sh
Last active July 9, 2019 14:21
Project Log via Git
git log --shortstat --pretty=tformat: --numstat --since="1 Jul, 2018" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "Commit stats:\n- Files changed (total).. %s\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", files, inserted, deleted, delta, ratio }' -
find . -name '*.php' -print0 | xargs -0 sed -i "" 's/{Number}/{Integer}/g'
@nogorilla
nogorilla / ES6.js
Created May 1, 2017 18:36
ES6 one-liners
// NodeList to Array:
var headings = [ ... document.querySelectorAll('h1') ];
// Unique Arrays:
[ ...new Set(array) ]
// Destructuring:
var {foo, bar} = {foo: "lorem", bar: "ipsum"};
// foo => lorem and bar => ipsum
@nogorilla
nogorilla / roman-numerals.js
Created April 10, 2017 18:15
Solution to whiteboard exercise
function getValue(char) {
numerals = {
'i': 1,
'v': 5,
'x':10,
'l':50,
'c':100,
'd':500,
'm':1000
}
@nogorilla
nogorilla / python.py
Last active May 4, 2019 01:38
Python
# Single line comments start with a number symbol.
""" Multiline strings can be written
using three "s, and are often used
as comments
"""
####################################################
# create
pg_dump -U {user} {database_name} > ~/file.dump
#restore
psql {database_name} < ~/file.dump