Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

David Yerrington dyerrington

💭
I may be slow to respond.
Block or report user

Report or block dyerrington

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
View gist:1bcbd0378d65f6562cd9
from geopy.geocoders import Bing
geolocator = Bing("your key here")
location = geolocator.geocode('your location here')
try:
if not location: continue
geo_location = {
'origin_address': location.address,
'origin_latitude': location.latitude,
'origin_longitude': location.longitude
@dyerrington
dyerrington / Count all words in text files - *nix
Created Mar 24, 2015
This snippet does a quick count of words of all text files found in subdirectories from where it's run.
View Count all words in text files - *nix
find . -name "*.txt" -exec cat {} \; | tr " " "\n" | wc -l
@dyerrington
dyerrington / Shellshock Test
Created Mar 25, 2015
Shellshocker vulnerability test
View Shellshock Test
#!/bin/bash
EXITCODE=0
# CVE-2014-6271
CVE20146271=$(env 'x=() { :;}; echo vulnerable' 'BASH_FUNC_x()=() { :;}; echo vulnerable' bash -c "echo test" 2>&1 | grep 'vulnerable' | wc -l)
echo -n "CVE-2014-6271 (original shellshock): "
if [ $CVE20146271 -gt 0 ]; then
echo -e "\033[91mVULNERABLE\033[39m"
EXITCODE=$((EXITCODE+1))
@dyerrington
dyerrington / bi-gram
Created Apr 14, 2015
Find bi-grams, filter on frequency, return PMI
View bi-gram
import nltk
from nltk.collocations import *
bigram_measures = nltk.collocations.BigramAssocMeasures()
trigram_measures = nltk.collocations.TrigramAssocMeasures()
# change this to read in your data
finder = BigramCollocationFinder.from_words(
nltk.corpus.genesis.words('/var/www/htdocs/rapstats/data/albums/wutang_all.txt'))
# only bigrams that appear 3+ times
View gist:3add35926496c5c552fa
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
@dyerrington
dyerrington / rootonly.sh
Created Apr 25, 2015
Forbid user account from running script
View rootonly.sh
if [ `id -u` != 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@dyerrington
dyerrington / removeblank.sh
Created Apr 25, 2015
Remove blank lines and comments
View removeblank.sh
grep -v '^[ \t]*$\|^[ \t]*#' /etc/ssh/sshd_config
@dyerrington
dyerrington / removeext
Created Apr 25, 2015
Remove files with specific extension, recursively.
View removeext
find . -type d -name .ext | xargs rm -rf
@dyerrington
dyerrington / word_counts
Created May 1, 2015
Count words in files recursively
View word_counts
find . -type f -print0 | xargs -0 cat | wc -w
@dyerrington
dyerrington / reject_outliers
Created May 6, 2015
Pandas remove +/- 3 std
View reject_outliers
sql_df[np.abs(sql_df['score'].values - sql_df['score'].values.mean())<=(3*sql_df['score'].values.std())]
You can’t perform that action at this time.