Skip to content

Instantly share code, notes, and snippets.

View nrk's full-sized avatar
🤔
はい、猫のように見えます。

Daniele Alessandri nrk

🤔
はい、猫のように見えます。
View GitHub Profile
@nrk
nrk / event.lua
Created March 28, 2009 13:52
Events in Lua. That is, something like the multicast delegates (synchronous) of C#... well, sort of.
local _G = _G
module('Event')
local ERROR_FUN_NOT_FUNCTION = 'Wrong parameter type: must be a function'
local function is_function(fun)
if fun and _G.type(fun) == 'function' then
return true
else
@nrk
nrk / gist:93723
Created April 11, 2009 20:41
Hpricot 0.8.1 test suite executed against the master branch of ironruby-hpricot
Hpricot 0.8.1 test suite executed against the 0.7_experimental
branch of ironruby-hpricot (updated to commit f98ec80)
-----------------------------------------------------------------
Loaded suite test_alter
Started
.........
Finished in 0.667969 seconds.
IronRuby 0.4.0.0 on .NET 2.0.50727.4918
Copyright (c) Microsoft Corporation. All rights reserved.
>>> load_assembly "test"
=> true
>>> source = open("data.xml")
=> #<File:data.xml>
>>> Test::Nrk.read(source)
C:\Development\ironruby\working-nrk\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:87:in `Bind': The result type 'System.Object' of the binder 'read(C,0)' is not compatible with the result type 'IronRuby.Builtins.MutableString' expected by the call site. (TypeError)
from C:\Development\ironruby\working-nrk\ndp\fx\src\Core\Microsoft\Scripting\Actions\C
@nrk
nrk / redis-lua_basic-example.lua
Created May 31, 2009 12:14
A basic example of how to use redis-lua
require 'redis'
local redis = Redis.connect("127.0.0.1", 6379)
redis:ping() -- true
redis:increment_by("my_key", 10) -- 10
redis:increment_by("my_key", 10) -- 20
redis:exists("my_key") -- true
redis:exists("another_key") -- false
[MissingMethodException: undefined method `create_user' for #<AccountMembershipService:0x0000298 @repo=IrTodo.Models.Lightspeed.IrTodoRepository>]
IronRuby.Builtins.KernelOps.MethodMissing(RubyContext context, Object self, SymbolId symbol, Object[] args) in c:\tools\ironruby\merlin\main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\KernelOps.cs:460
CallSite.Target(Closure , CallSite , RubyScope , Object , Object , Object , Object ) +232
System.Dynamic.UpdateDelegates.UpdateAndExecute5(CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) in c:\tools\ironruby\ndp\fx\src\core\microsoft\scripting\Actions\UpdateDelegates.Generated.cs:759
ℑℜ;register;account_controller.rb;46;550$421.ℑℜ;register;account_controller.rb;46;550(Object #self, Proc #block) in C:\projects\irtodo.koolkraft.net\Controllers\account_controller.rb:60
CallSite.Target(Closure , CallSite , Object ) +144
System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) in c:\tools\ironruby\ndp\fx\src\core\microsof
@nrk
nrk / bencode.io
Created June 20, 2009 19:09
Dead-simple bencoding using the Io language
# See http://en.wikipedia.org/wiki/Bencode for reference
# encoding objects
Number asBencode := method(
Sequence with("i", self asString, "e")
)
Sequence asBencode := method(
require 'win32/process'
process_info = Process.create(
:app_name => "notepad.exe",
:creation_flags => Process::DETACHED_PROCESS,
:process_inherit => false
)
@nrk
nrk / sinatra_global_scope.lua
Created July 15, 2009 09:21
A sinatra-like DSL for Lua (actually an hack, but I'm starting to like it)
-- defining you application in the global scope
require 'sinatra'
module('nrk', package.seeall, sinatra.application)
get("/", function()
return "<h1>Welcome to " .. APP_NAME .. "!</h1>"
--[[
URL: http://127.0.0.1/
C:\Development\ironruby\working-nrk\Merlin\Main\bin\Debug>ir -v
IronRuby 0.9.0.0 on .NET 2.0.0.0
C:\Development\ironruby\working-nrk\Merlin\Main\bin\Debug>ir termtter\run_termtter.rb
your twitter user name: JoL1hAHN
your twitter password:
generated: ~/.termtter/config
enjoy!
←[31m[ERROR] ArgumentError: wrong number of arguments (2 for 1)
@nrk
nrk / mercury-xavante.lua
Created August 2, 2009 06:32
Short code snippet that shows how to launch Mercury's greetings sample using Xavante.
--[[
Short code snippet that shows how to launch Mercury's greetings sample using Xavante.
Mercury: http://github.com/nrk/mercury/
Xavante: http://www.keplerproject.org/xavante/
]]
require 'luarocks.require'
require 'xavante'
require 'wsapi.xavante'