Skip to content

Instantly share code, notes, and snippets.

View leafo's full-sized avatar
🐔
bock bock

leaf leafo

🐔
bock bock
View GitHub Profile
@leafo
leafo / gist:9577854
Created March 16, 2014 02:49
selenium snapshots
#!/usr/bin/env python2.7
from xml.dom import minidom
import urllib2
import os
import shutil
import random
import re
import sys
zip 1836
unity3d 603
exe 435
swf 302
rar 165
apk 122
jar 64
png 54
gz 39
jpg 37
select
jam_users.user_id,
games.title,
jam_users.rated_count - jam_games.rating_count as score,
(jam_users.rated_count - jam_games.rating_count)::float / (jam_games.rating_count + 1) as score2,
jam_users.rated_count as rated,
jam_games.rating_count as ratings
from jam_games
inner join games on games.id = jam_games.game_id
inner join jam_users on jam_users.user_id = games.user_id and jam_users.jam_id = jam_games.jam_id
package.preload['moonscript.transform.names'] = function()
local build
do
local _table_0 = require("moonscript.types")
build = _table_0.build
end
local unpack
do
local _table_0 = require("moonscript.util")
unpack = _table_0.unpack
httperf --uri=/ --port=8080 --num-conns=8 --num-calls=100000
Connection rate: 203.5 conn/s (4.9 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 4.7 avg 4.9 max 5.2 median 4.5 stddev 0.2
Connection time [ms]: connect 0.0
Connection length [replies/conn]: 100.000
Request rate: 20550.3 req/s (0.0 ms/req)
socket = require "socket"
bm_mix = (tests, iterations=100, ...) ->
totals = {k, 0 for k in pairs tests}
print "Running with", ...
for i=1,iterations
@leafo
leafo / gist:8813608
Created February 4, 2014 22:25
find missing candyjam games
import GamesSearch, JamGames from require "models"
import get_all_pages from require "util"
pager = GamesSearch\text "candy"
all_games = get_all_pages pager
game_ids = table.concat [game.id for game in *all_games], ", "
print "Games #{#all_games}"
jgs = JamGames\select "where jam_id = 1"
@leafo
leafo / gist:8152626
Created December 27, 2013 21:06
moonscript linter
(master) ~/code/sites/itch.io > moonc -l applications/downloads.moon
./applications/downloads.moon
line 146: accessing global storage
=================================================================================
> url: storage\signed_url bucket_name, @upload\bucket_key!, os.time! + 10
line 146: accessing global bucket_name
=================================================================================
> url: storage\signed_url bucket_name, @upload\bucket_key!, os.time! + 10
@leafo
leafo / moonscript.lua
Created December 22, 2013 18:53
all of moonscript
package.preload['moonscript.transform.names'] = function()
local build
do
local _obj_0 = require("moonscript.types")
build = _obj_0.build
end
local unpack
do
local _obj_0 = require("moonscript.util")
unpack = _obj_0.unpack
this.is.a.long.line
-- in coffee script we can do this:
this
.is.a
.long.line
-- but in moonscript, with's syntax uses the . as prefix for line
with something