Skip to content

Instantly share code, notes, and snippets.

Avatar

John Reiser johnjreiser

View GitHub Profile
@johnjreiser
johnjreiser / downloadFakePeople.sh
Created Jun 12, 2019
Download Fake People - quick script to grab images from This Person Does Not Exist
View downloadFakePeople.sh
#!/bin/bash
MAX=10
if [[ ! -z "$1" ]]; then
MAX=$1
fi
for i in $( seq $MAX ); do
FILE=image${i}.jpg
curl 'https://thispersondoesnotexist.com/image' -H 'authority: thispersondoesnotexist.com' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'referer: https://thispersondoesnotexist.com/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' --compressed -o $FILE
@johnjreiser
johnjreiser / container_start.sh
Created Jun 1, 2019
Store container start time inside environment variable
View container_start.sh
export CONTAINER_START=$( stat /proc/1/cmdline | grep Modify | awk '{print $2 " " $3}' )
# run in shell through entrypoint or other cmd
@johnjreiser
johnjreiser / movefiles.sh
Created May 5, 2019
Sort extensionless files by type
View movefiles.sh
#!/bin/bash
TXT="text/plain; charset=us-ascii"
PNG="image/png; charset=binary"
JPEG="image/jpeg; charset=binary"
MOV="video/quicktime; charset=binary"
MP4="video/mp4; charset=binary"
GPP="video/3gpp; charset=binary"
for file in *; do
currfile=`file -b -i $file`
@johnjreiser
johnjreiser / AmazonLinux-InstallPostGIS.sh
Last active May 7, 2021
Script to install PostgreSQL 10 and PostGIS 2.5 on fresh Amazon Linux 2
View AmazonLinux-InstallPostGIS.sh
#!/bin/bash
# Script to install PostgreSQL 10 and PostGIS 2.5 on fresh Amazon Linux 2
# Installing from source:
# - GEOS 3.7.1
# - GDAL 2.4.0
# - PostGIS 2.5.1
set -e
sudo amazon-linux-extras install postgresql10 vim epel -y
@johnjreiser
johnjreiser / redate.sh
Created Nov 12, 2017
Rename files from MM-DD-YYYY to YYYY-MM-DD
View redate.sh
#!/bin/bash
for file in `ls -1 | grep -e "[0-9]\{2\}-[0-9]\{2\}-[0-9]\{4\}" ` ; do
if [[ $file =~ ([0-9]{2})-([0-9]{2})-([0-9]{4})(.*)$ ]] ; then
newname=${BASH_REMATCH[3]}-${BASH_REMATCH[1]}-${BASH_REMATCH[2]}${BASH_REMATCH[4]}
echo "$file -> $newname "
mv -i $file $newname
else
echo Skipping $file...
fi
View postgres_queries_and_commands.sql
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
View tricks.sh
####
# Stupid Shell Tricks
####
# find the largest files within a subdirectory (mac os x)
find . -type f -print0 | xargs -0 stat -f '%z %N' | sort -n | tail
View .vimrc
colorscheme solarized
syntax on
filetype indent plugin on
set tabstop=4
set expandtab
set shiftwidth=4
set softtabstop=4
View keybase.md

Keybase proof

I hereby claim:

  • I am johnjreiser on github.
  • I am johnjreiser (https://keybase.io/johnjreiser) on keybase.
  • I have a public key whose fingerprint is E152 5F50 2A5E 4044 B7B2 1C9A 5660 B872 03D7 B097

To claim this, I am signing this object:

@johnjreiser
johnjreiser / dbfschemacompare.py
Last active Jan 2, 2016
Generates a simple report showing matching schemas from a list of DBF files. Useful for seeing if a directory of shapefiles have similar attribute tables.
View dbfschemacompare.py
#!/usr/bin/env python
"""
Generates a simple report showing matching schemas from a list of DBF files.
"""
import sys, os, glob
from dbfpy import dbf
files = []