Skip to content

Instantly share code, notes, and snippets.

Steven Hollingsworth shollingsworth

Block or report user

Report or block shollingsworth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shollingsworth
shollingsworth / glucose_brain_burn_rate.py
Last active Nov 30, 2018
Convert weight in lbs to stats about glucose replacement for your brain.
View glucose_brain_burn_rate.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Convert weight in lbs to stats about glucose replacement for your brain."""
# After reading reading "Thinking, Fast and Slow"
# by Daniel Kahneman
#
# Based docs from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3900881/
# and
# https://www.nutritionix.com/food/light-corn-syrup
from __future__ import unicode_literals
@shollingsworth
shollingsworth / slack-create-pyclass.py
Last active Jun 26, 2018
Create a slack data object given the raw json output ` ./slack-create-pyclass.py -f user.json User`
View slack-create-pyclass.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import argparse
import json
import select
import sys
LOG = logging.getLogger()
LOG.setLevel(logging.DEBUG)
@shollingsworth
shollingsworth / duration_string_to_seconds.py
Created Dec 21, 2017
convert duration string like: 2d3h5m30s into seconds only (python)
View duration_string_to_seconds.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
test_str = "1h5m"
test_str = "5d3h2m50s"
keys = {
'd' : 60 * 60 * 24,
'h' : 60 * 60,
'm' : 60,
@shollingsworth
shollingsworth / duration_string_to_seconds.sh
Created Dec 21, 2017
convert duration string like: 2d3h5m30s into seconds only (bash)
View duration_string_to_seconds.sh
#!/usr/bin/env bash
test_str="1h5m"
test_str="5d3h2m50v" #bad
test_str="5d3h2m50s"
declare -A keys
keys[d]=$((60 * 60 * 24))
keys[h]=$((60 * 60))
keys[m]=60
keys[s]=1
@shollingsworth
shollingsworth / .vimrc
Created Jul 12, 2017
my vimrc script editing environment wrappers
View .vimrc
autocmd FileType * exe('let comp_cmd="!~/.vim/bin/build_' . &filetype . '.sh ' . expand("%:p") . '"')
autocmd FileType * exe('let run_cmd="!~/.vim/bin/build_' . &filetype . '.sh ' . expand("%:p") . ' \|less -cN"')
map z :exec comp_cmd<enter><enter>
map R :exec run_cmd<enter><enter>
View gist:7ee0572274e42af97df156cea1f3ca2d
hello_world/
echo "hello world"
current_working_directory/
pwd
list_files/
ls
print_file_contents/
cat access.log
last_lines/
tail -n5 access.log
@shollingsworth
shollingsworth / gist:80eab8ec07ae9edffe97
Created Aug 3, 2015
find all file extension types in current directory
View gist:80eab8ec07ae9edffe97
find -type f | while read i; do bn=$(basename ${i}); echo ${bn##*.}; done | tr 'A-Z' 'a-z' | sort | uniq
@shollingsworth
shollingsworth / RedCache.php
Last active Aug 29, 2015
initial Redis Thinger (RedCache)
View RedCache.php
<?php
/**
* RedCache : Redis Cacher Interface
* @version 2014-10-20 13:16
* @author Steven Hollingsworth <steven.hollingsworth@fresno.gov>
*/
/** Set Constants and default path for all includes */
if(!@include_once("{$_SERVER['PHP_REPORT_BASE_DIR']}/include/_constants.php")) { print "Could not Load standard include file. Bailing...\n<br>"; exit(99); }
@shollingsworth
shollingsworth / gist:f34205663345e2b31682
Created Oct 12, 2014
bash find files in current directory sorted by last modified time
View gist:f34205663345e2b31682
#find and sort by modified time
find . -type f -printf "%T@::%t::%p\n" | sort -n
#Grab the last 5 modified files
find . -type f -printf "%T@::%t::%p\n" | sort -n | awk -F '::' '{print $3}' | tail -n5
You can’t perform that action at this time.