Skip to content

Instantly share code, notes, and snippets.

View agladysh's full-sized avatar

Alexander Gladysh agladysh

View GitHub Profile
@agladysh
agladysh / README.md
Last active August 29, 2015 14:21 — forked from mbostock/.block

A treemap recursively subdivides area into rectangles; the area of any node in the tree corresponds to its value. This example uses color to encode different packages of the Flare visualization toolkit. Treemap design invented by Ben Shneiderman. Squarified algorithm by Bruls, Huizing and van Wijk. Data courtesy Jeff Heer.

@agladysh
agladysh / nginx2csv.lua
Last active December 12, 2015 02:09
Released under MIT license
-- For nginx combined log format:
-- http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
local query = '^'
.. '(%d+%.%d+%.%d+%.%d+)%s' -- IP
.. '%-%s' -- separator
.. '(.-)%s' -- Remote user, TODO: Support
.. '%[(.-)%]%s' -- Date, time
.. '"(.-)"%s' -- request
.. '(%d+)%s' -- HTTP status code
.. '(%d+)%s' -- body_bytes_sent
@agladysh
agladysh / gist:1850707
Created February 17, 2012 04:35
Weird Lua crash with Adobe Alchemy
https://github.com/lua-alchemy/lua-alchemy/compare/ag/150/weird-bugs...ag/150/debug-output
[SWF] LuaAlchemyiOSTest.swf - 4,676,970 bytes after decompression
initializing 6...
0010 -- BEGIN
0020
0030
0040
0050
0051 -- luaL_openlibs BEGIN 1
@agladysh
agladysh / load_args.c
Created November 21, 2011 18:37
LJ2 lua_tolstring issue
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#define MAXARGS (256)
static int load_args(
lua_State * L,
int idx, /* index of first argument */
{
"f5e4d821-75b2-45ee-b255-ce72817ab774": {
"14893fe4-d878-4b53-8bd6-3dfb059bd9b8": 0,
"e0fc313e-7ad3-4fb3-9a68-0dc133fcdb54": 0,
"8240b7bd-e599-4beb-878a-b2e845cdee8a": 1,
"7f0a901f-a000-482c-bbcb-f346452e6b16": "69476aa8-c739-4442-969b-605df8ec4805"
},
"81c2051a-e824-45d2-82b9-68f9c13859ee": {
"16845c1f-a576-4c18-b8b2-d76dc7468182": {
"88464518-baf4-488d-87ba-8842660b8b36": {
@agladysh
agladysh / console.log
Created April 23, 2011 06:58
lua-zmq inverted pub-sub problem
# Spawn receiver 1
$ lua receiver.lua &
[1] 9728
R 9728 init
R 9728 create socket
R 9728 bind socket
R 9728 subscribe
R 9728 before receive msg loop
@agladysh
agladysh / with_coroutines.lua
Created April 18, 2011 20:59
Example for using coroutine-based workarounds for blocking callbacks in Lua Alchemy (issue #121)
-- See http://code.google.com/p/lua-alchemy/issues/detail?id=121
-- Example. Actual implementation should reuse as much resources as possible.
-- Code is not tested.
local sleep = function(interval)
local timer = as3.class.flash.utils.Timer.new(interval)
local function callback()
if timer then
timer.stop()
timer.removeEventListener(
@agladysh
agladysh / INFO
Created April 3, 2011 21:35
SELECT does not^H^H^H work while LOADING in Redis 2.2.2 (it does!)
$ redis-cli info
redis_version:2.2.2
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:32
multiplexing_api:epoll
process_id:3989
uptime_in_seconds:586
uptime_in_days:0
lru_clock:161962
@agladysh
agladysh / check_keys_escaped.lua
Created April 3, 2011 19:04
Redis keys are not escaped
pcall(require, 'luarocks.require')
local sidereal = require 'sidereal' -- sudo luarocks install sidereal --from=http://luarocks.org/repositories/rocks-cvs
--------------------------------------------------------------------------------
-- Some value printing code
--------------------------------------------------------------------------------
require 'lua-nucleo.module' -- sudo luarocks install lua-nucleo
require 'lua-nucleo.strict'
pcall(require, 'luarocks.require')
local sidereal = require 'sidereal' -- sudo luarocks install sidereal --from=http://luarocks.org/repositories/rocks-cvs
--------------------------------------------------------------------------------
-- Some value printing code
--------------------------------------------------------------------------------
require 'lua-nucleo.module' -- sudo luarocks install lua-nucleo
require 'lua-nucleo.strict'