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
@dyerrington
dyerrington / controls_dialog
Last active Dec 21, 2015
Dealing with dialog actions in LUA
View controls_dialog
local ActionKey = display.newRect(controlGroup, DpadBack.x + 750, DpadBack.y - 37, 100, 100)
local function move( event )
if event.phase == "ended" or event.phase == "cancelled" then
movement = nil
elseif player.talking then
return false;
elseif event.target.id then
movement = event.target.id
player.lastMovement = event.target.id
@dyerrington
dyerrington / collision_layer
Created Aug 15, 2013
Detect obstacles based on layer properties.
View collision_layer
--DETECT OBSTACLES ------------------------------------------------------------
local obstacle = function(level, locX, locY)
local detect = mte.getTileProperties({level = level, locX = locX, locY = locY})
for i = 1, #detect, 1 do
-- I forget why I check the tile property...
if detect[i].tile then
-- does its layers property solid?
if layers[i].properties and layers[i].properties.solid and detect[i].tile > 0 then
detect = "stop"
player:pause()
@dyerrington
dyerrington / obj_player
Created Jan 24, 2014
Basic setup for GML top/down player control
View obj_player
if(keyboard_check(vk_nokey)) {
image_speed = 0;
}
if(keyboard_check(vk_left)) {
sprite_index = spr_right;
image_speed = 0.2;
image_xscale= 1;
x -= 4;
}
@dyerrington
dyerrington / gist:c70005ca2d55a8c32ced
Last active Feb 25, 2016
Something cool for the kids on the street...
View gist:c70005ca2d55a8c32ced
$('.bt-request-buffed').each(
function(index, value) { var el = $(this); var alpha = Math.floor((Math.random() * 8) + 3); setTimeout(function() { el.trigger('click'); }, (index * alpha) * 2500); });
/* Alternatively, you might try (index + alpha) * 1000 for a more natural sequence */
View gist:119719f40bb4783997ea
# pip install gmaps
import gmaps
""" Earthquake Example """
earthquake_data = gmaps.datasets.load_dataset('earthquakes')
earthquake_data[:5]
m = gmaps.heatmap(earthquake_data, max_intensity=10, point_radius=5)
# Set max_intensity to avoid a few strong earthquakes drowning out all the smaller ones.
@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
You can’t perform that action at this time.