Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
everyday I'm hustlin'

Alex Ausch aausch

💭
everyday I'm hustlin'
View GitHub Profile
@aausch
aausch / bash_args_template.sh
Created Jun 3, 2019
OSX/Bash argument parsing
View bash_args_template.sh
#!/bin/bash -e
# cobbled together from various of stackoverflow posts
# saner programming env: these switches turn some bugs into errors
set -o errexit -o pipefail -o noclobber -o nounset
# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
! getopt --test > /dev/null
View ubuntu_snippets
# disk usage
sudo du -cha --max-depth=1 / | grep -E "M|G"
# ubuntu boot log, for previous boot
journalctl -b-1 --no-pager
@aausch
aausch / bash_snippets
Created Feb 11, 2017
osx effective bash snippets
View bash_snippets
# remove spaces from files
for f in *\ *; do mv "$f" "${f// /_}"; done
@aausch
aausch / bash_snippets
Created Feb 11, 2017
osx effective bash snippets
View bash_snippets
# remove spaces from files
for f in *\ *; do mv "$f" "${f// /_}"; done
View test_data.tsv
date close
1-May-12 582.13
30-Apr-12 583.98
27-Apr-12 603.00
26-Apr-12 607.70
25-Apr-12 610.00
24-Apr-12 560.28
23-Apr-12 571.70
20-Apr-12 572.98
19-Apr-12 587.44
View iterate_gzipped_s3_file.py
#!/usr/bin/env python3
import boto3
import gzip
import io
import sys
import tempfile
BUCKET = 'SOME_BUCKET'
@aausch
aausch / contact_generator.rb
Last active Aug 29, 2015
easy to understand, and use, ruby based, contact generator
View contact_generator.rb
# Copyright 2014, Alex Ausch
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/
puts ARGV.count
if ARGV.count < 1
puts "Missing argument - number of contacts"
exit
end
View check_and_restart.sh
#!/usr/bin/perl
#from this post: http://www.linuxquestions.org/questions/programming-9/script-to-see-if-a-process-ir-running-if-not-start-it-339618/
open PROS, "ps -ef|grep process |";
while ($line = <PROS>){
unless ($line =~ m/grep/){
exit;
}
@aausch
aausch / static_file_scanner_demo.py
Last active Dec 27, 2015
usage demo for a StaticFileScanner resource for twisted (StaticFileScanner @ https://gist.github.com/aausch/7284664)
View static_file_scanner_demo.py
# Copyright 2013, Alex Ausch
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/
from twisted.web.resource import Resource
from twisted.application import service
from StaticFileScanner import StaticFileScanner
root = Resource()
root.putChild('static',