Skip to content

Instantly share code, notes, and snippets.

View agladysh's full-sized avatar

Alexander Gladysh agladysh

View GitHub Profile
@agladysh
agladysh / check_pipeline_multi.lua
Created March 22, 2011 22:46
MULTI/EXEC crashes inside PIPELINE
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'
@agladysh
agladysh / gist:790225
Created January 21, 2011 19:15
Popping up a message box on Windows
-- Popping up a message box on Windows with LuaJIT2 Git HEAD:
-- (Example by Mike Pall)
local ffi = require("ffi")
ffi.cdef[[
int MessageBoxA(void *w, const char *txt, const char *cap, int type);
]]
ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)
@agladysh
agladysh / check_hkeys_pipeline.lua
Created October 24, 2010 04:24
HKEYS is broken
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'
@agladysh
agladysh / check_hvals_pipeline
Created October 24, 2010 04:23
HVALS is broken
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'
@agladysh
agladysh / check_del_key_list.lua
Created October 24, 2010 01:54
DEL with key list is broken
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'
@agladysh
agladysh / declarative.lua
Created December 6, 2009 01:39
Example to Article on Lua Declarative Programming
local function build_message_box_imperative(gui_builder)
local my_dialog = gui_builder:dialog()
my_dialog:set_title("Message Box")
local my_label = gui_builder:label()
my_label:set_font_size(20)
my_label:set_text("Hello, world!")
my_dialog:add(my_label)
local my_button = gui_builder:button()
@agladysh
agladysh / ghg-preview.xml
Created November 28, 2009 23:22
GitHub Gist Gadget Draft
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="GitHub Gist Gadget">
<Require feature="wave" />
<Require feature="dynamic-height" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<div id="content_div">
luamarca $ ./run_benchmark.sh bench/sort-fedin.lua 1e5
Results:
luajit -O
-------------------------------------------------------------------
name | rel | abs s / iter = us (1e-6 s) / iter
-------------------------------------------------------------------
bubble_nocallback_s | 1.0000 | 0.51 / 100000 = 5.100000 us
bubble_nocallback | 1.0000 | 0.51 / 100000 = 5.100000 us
@agladysh
agladysh / luabins-example.lua
Created November 21, 2009 14:09
Silly example on how to use luabins
local luabins = require "luabins"
local status, a, b, c = assert(
luabins.load(luabins.save("A", "B", "C"))
)
print(a, b, c) --> A B C