Skip to content

Instantly share code, notes, and snippets.

local enemies = {}
local SumSpell = "SummonerFlash"
function onLoad()
for i, heroObj in pairs(GetEnemyHeroes()) do
if heroObj and heroObj.valid then
local curflash
if hero:GetSpellData(SUMMONER_1).name:find(SumSpell) then curflash = SUMMONER_1 end
if hero:GetSpellData(SUMMONER_2).name:find(SumSpell) then curflash = SUMMONER_2 end
enemies[heroObj.charName] = {curflash, nil}
@zvodd
zvodd / sexy_struct_strings.py
Created July 16, 2014 16:31
Make packing string more verbose and human readable.
def convert(instr, token=','):
longtoshort = {'pad' : 'x',
'char' : 'c',
'schar' : 'b',
'uchar' : 'B',
'byte' : 'B',
'bool' : '?',
'short' : 'h',
'ushort' : 'H',
'int' : 'i',
@zvodd
zvodd / xkcd captionator
Last active August 29, 2015 14:04
UserScript | xkcd.com | Show xkcd comic captions on the page. (Click the comic image to make it stay.)
// ==UserScript==
// @name xkcd captionator
// @namespace https://gist.github.com/zvodd/035e488f912aa18ba0c6
// @version 0.1
// @description Show xkcd comic captions on the page. (Click the comic image to make it stay.)
// @match http://xkcd.com/*
// @copyright 2014+, zvodd
// ==/UserScript==
var comic = $("#comic>img"),
@zvodd
zvodd / ascii2bin.py
Last active August 29, 2015 14:04
Simple Example Command Line Python App
#!/usr/bin/env python
import sys
def main():
if len(sys.argv) >= 2:
infile = sys.argv[1]
else:
infile = sys.stdin
if len(sys.argv) >= 3:
@zvodd
zvodd / LoL Average Game Time.js
Last active August 29, 2015 14:04
Average game times for League of Legends match history display.
function get_game_times() {
var durs = document.querySelectorAll('.date-duration-duration'),
games = Array();
for ( i in durs) {
var dtxt = durs[i].innerText;
if (dtxt != undefined) {
// Does it output hours? i have no appplicable data to test.
var tar = dtxt.match(/(\d\d):(\d\d)/),
tm = Number(tar[1]),
ts = Number(tar[2])/60, // convert seconds to percentage
@zvodd
zvodd / list_flatten.py
Created October 24, 2014 00:31
Flatten lists of lists. Including callback argument to filter iterable types.
import collections
# ignore functions
ignore_strings = lambda x: isinstance(x, basestring)
ignore_dicts = lambda x: isinstance(x, dict)
def list_flatten(*ilist, **kwargs):
"""
Flattens nested indexable iterables, i.e lists of lists
By default treats strings and dicts as scalar values
@zvodd
zvodd / chooser.sh
Created November 17, 2014 15:12
Bash Script: Recursive YES/NO user input with parameter for maximum retries.
#!/bin/bash
yesnochoose () {
# $1 is the maximum number of retries
max=$( [ "$1" -eq "$1" ] 2>/dev/null && echo $1 || echo 5 )
# $2 is the retry count and should not be set when called outside of recursion.
count=$( [ "$2" -eq "$2" ] 2>/dev/null && echo $2 || echo 0 )
read uchoose
uchoose=$(echo $uchoose | sed -e 's/\(.*\)/\U\1/' -e 's/ //g')
case "$uchoose" in
"YES"|"YE"|"Y")
@zvodd
zvodd / makeascr.py
Created March 27, 2015 18:32
Compile Actiona/Actionaz file from JavaScript files.
import argparse, os, os.path, subprocess, platform
# import inspect
# from pprint import pprint
ACTIONAZ_EXE = ""
ACTIONAZ_VERSIONS = {
'37': dict(script_version="1.0.0", version="3.7.0"),
'38': dict(script_version="1.1.0", version="3.8.0")
}
if platform.system().lower() == "windows":
@zvodd
zvodd / CartesianProduct.py
Created April 9, 2015 19:42
Indexed Cartesian Product
def cart_product_len(sets):
""" length of cartasien product space """
p = 1
for n_set in sets:
p *= len(n_set)
return p
def indexable_set_product(sets, index):
"""
@zvodd
zvodd / whereisyourgodnow.py
Created April 16, 2015 13:02
Average List of Numbers in a lambda.
average = lambda L: filter( float,
[[0 for acc in [sum(L) ]][-1],
[0 for avg in [acc / float(len(L))]][-1],
avg]
)[-1]
average([1,2,3,4,5])