Skip to content

Instantly share code, notes, and snippets.

View davisdude's full-sized avatar

Davis davisdude

  • North Carolina, United States of America
View GitHub Profile
# Requires py-slippi to be installed
#
# Usage:
# python airtime.py path/to/file.slp
#
# Output:
# {0: 0, 1: 0, 2: 7403, 3: 5645}
# (e.g. player in port 3 was in the air for 7403 frames, player in port 4
# was in the air for 5645 frames)
l,m=love,math g,f,s,b,x,o,no,p=l.graphics,m.floor,20,' ',0,0,0,{'^ppp','^...ppp','ppp$','p..p..p','p...p...p','^..p.p.p'}P,z=g.print,{b,b,b,b,b,b,b,b,b}l.window.setMode(800,600,{resizable=1})function e(c)for i=1,6 do i=p[i]:gsub('p',c)if v:find(i)then return c end end return not v:find' 'and'no'end function l.draw()w,h=g.getDimensions()d,v=m.min(w/80,h/80),''g.setFontNewFont(12*d)for i=1,9 do P(z[i],((i-1)%3*s+6)*d,((m.ceil(i/3)-1)*s+5)*d)v=v..z[i]end O=e'x'or e'o'if O then _G[O]=_G[O]+(not c and 1 or 0)P(O..' won x:'..x..' o:'..o,0,60*d)c=true end P(not t and'x'or'o',70*d,0)g.scale(d)g.line(0,s,3*s,s)g.line(0,2*s,3*s,2*s)g.line(s,0,s,3*s)g.line(2*s,0,2*s,3*s)end function l.mousepressed(x,y)if not O then x,y=f(x/d/s),f(y/d/s)if x<3 and y<3 then i=y*3+x+1 if z[i]==' 'then z[i],t=not t and'x'or'o',not t end end else z,t,c={b,b,b,b,b,b,b,b,b}end end
@davisdude
davisdude / to-last.vim
Last active January 10, 2017 04:34
A vim motion for "to-last"
" Add 'last' motion
" <count> is the number from last, i.e. 2gtl goes to the 2nd to last l with the `t` motion
" <mode> is the mode, i.e. 2vgtl visually selects from the cursor to the second to last l
" <count><mode>g<motion><char>
function s:strfind( str, find, start, stop, increment )
let l:i = a:start
let l:len = len( a:str )
let l:lenfind = len( a:find )
while ( a:increment > 0 && l:i < a:stop ) || ( a:increment < 0 && l:i > a:stop )
@davisdude
davisdude / plugin.vim
Last active June 26, 2021 15:25
Launch LOVE from vim
" Vim plugin for running LOVE
" Last Change: 2015 May 26
" Maintainer: Davis Claiborne <davisclaib@gmail.com>
" License: This file is placed under public domain.
let s:save_cpo = &cpo
set cpo&vim
if exists( 'g:loaded_lovelaunch' )
finish