Skip to content

Instantly share code, notes, and snippets.

View leafo's full-sized avatar
🐔
bock bock

leaf leafo

🐔
bock bock
View GitHub Profile
select username, email, games_count, user_data.data from users
inner join user_data on user_data.user_id = users.id
where (
select count(*) from games
where
games.user_id = users.id and
paid_status > 1 and published and
not deleted and classification = 0 and purchases_count > 0
) > 1 order by games_count desc;
class Test
__field_missing: (name) =>
print "method is missing:", name
old = @__base.__index
@__base.__index = (name) =>
old[name] or @__field_missing name
x = Test!
class FakeRedis
new: =>
@called = {}
for m in *{ "set_timeout", "connect", "multi", "sadd", }
@__base[m] = (...) =>
@called[m] = ...
true
import sleep from require "socket"
async_function = (fn) ->
fn!
-- async_function ->
-- print "first"
-- async_function ->
-- print "second"
-- async_function ->
lapis = require "lapis"
import capture_errors from require "lapis.application"
import assert_valid from require "lapis.validate"
import json_params from require "lapis.application"
class App extends lapis.Application
"/test": json_params capture_errors {
on_error: =>
json: @errors, status: 401
* << BeReq >> 32771
- Begin bereq 32770 fetch
- Timestamp Start: 1408054950.451976 0.000000 0.000000
- BereqMethod GET
- BereqURL /dump/Music%20Pack.rar
- BereqProtocol HTTP/1.1
- BereqHeader User-Agent: curl/7.37.1
- BereqHeader Accept: */*
- BereqHeader X-Forwarded-For: 206.169.213.106
- BereqHeader Host: leafo.net
@leafo
leafo / gist:990f574527a05e1dfcc0
Created August 20, 2014 20:20
top referrer domains
select domain, count(*) from (select (regexp_matches(purchase_referrers.referrer, '//(.*?)/'))[1] as domain from purchase_referrers inner join purchases on purchases.id = purchase_referrers.purchase_id where purchases.status = 1 and purchase_referrers.type = 2) as domains group by domain order by count desc;
worker_processes 1;
error_log stderr notice;
daemon off;
events {
worker_connections 1024;
}
http {
server {
(master) ~/code/cpp/enet-lua > luarocks upload enet-1.2-1.rockspec --api-key=xxx
/home/leafo/.luarocks/upload_config.lua
Warning: Your LuaRocks is out of date, consider upgrading.
Sending enet-1.2-1.rockspec ...
Packing enet
Cloning into 'lua-enet'...
remote: Counting objects: 21, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 21 (delta 1), reused 20 (delta 1)
Receiving objects: 100% (21/21), 12.58 KiB | 0 bytes/s, done.
@leafo
leafo / snap
Created October 19, 2014 17:09
#!/bin/bash
scrot '%Y-%m-%d_%H-%M-%S.png' -s -e 'pngquant --ext .png -f $f;scp $f [email protected]:www/shotsnb;echo -n "http://leafo.net/shotsnb/$f" | xclip; rm $f' && notify-send -u normal -t 1000 'Screenshot Ready'