Skip to content

Instantly share code, notes, and snippets.

View dyerrington's full-sized avatar
💭
I may be slow to respond.

David Yerrington dyerrington

💭
I may be slow to respond.
View GitHub Profile
@dyerrington
dyerrington / controls_dialog
Last active December 21, 2015 03:38
Dealing with dialog actions in LUA
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 August 15, 2013 18:22
Detect obstacles based on layer properties.
--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 January 24, 2014 02:26
Basic setup for GML top/down player control
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 February 25, 2016 04:25
Something cool for the kids on the street...
$('.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 */
# 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 March 24, 2015 18:56
This snippet does a quick count of words of all text files found in subdirectories from where it's run.
find . -name "*.txt" -exec cat {} \; | tr " " "\n" | wc -l
@dyerrington
dyerrington / Shellshock Test
Created March 25, 2015 22:54
Shellshocker vulnerability 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 April 14, 2015 06:07
Find bi-grams, filter on frequency, return PMI
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
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
@dyerrington
dyerrington / rootonly.sh
Created April 25, 2015 00:37
Forbid user account from running script
if [ `id -u` != 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi