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: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 / 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"
socket = require "socket"
bm_mix = (tests, iterations=100, ...) ->
totals = {k, 0 for k in pairs tests}
print "Running with", ...
for i=1,iterations
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)
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
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
zip 1836
unity3d 603
exe 435
swf 302
rar 165
apk 122
jar 64
png 54
gz 39
jpg 37
@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
-- vacuum and analyze stats
SELECT relname, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze FROM pg_stat_user_tables;
-- scan vs index rate
select relname, seq_scan, idx_scan, round(seq_scan::numeric/(seq_scan + idx_scan),4) ratio
from pg_stat_user_tables order by ratio desc;
@leafo
leafo / web.lua
Last active August 29, 2015 13:59
-- LuaJIT 2.1.0-alpha 27c453e
-- jit.off() -- no error when jit is off
local t = {
msg = "hello",
}
local function breaks(parts)
local out = ""
if parts.msg then