Skip to content

Instantly share code, notes, and snippets.

View matsumotory's full-sized avatar
:octocat:
manager now

Ryosuke Matsumoto / @matsumotory matsumotory

:octocat:
manager now
View GitHub Profile
@matsumotory
matsumotory / gist:4284512
Created December 14, 2012 10:45
mod_mruby hello world.
Apache.rputs("hello mod_mruby world!")
@matsumotory
matsumotory / gist:4317977
Created December 17, 2012 12:34
reuse irep[n]
mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
mrb_gc_arena_restore(mrb, ai);
if (mrb->exc)
ap_mrb_raise_file_error(mrb, mrb_obj_value(mrb->exc), r, mruby_code_file);
(snip)
mrb->irep_len = n;
if (!(mrb->irep[n]->flags & MRB_ISEQ_NO_FREE))
@matsumotory
matsumotory / gist:4334810
Created December 19, 2012 06:26
Sample: zabbix 2.0 API client for mruby
$cat mrbgems/g/mruby-zabbix/example/zabbix-api-client.rb
config = {
:url => "http://127.0.0.1/zabbix/api_jsonrpc.php",
:ua => "mruby-zabbix",
:user => "api-admin",
:pass => "api-admin",
}
z = Zabbix::Client.new(config)
@matsumotory
matsumotory / gist:4350595
Last active August 29, 2024 22:46
mymruby.sh
set -e
git clone git://github.com/mruby/mruby.git
cd mruby/mrbgems/g/
git clone git://github.com/mattn/mruby-uv.git
git clone git://github.com/mattn/mruby-http.git
git clone git://github.com/mattn/mruby-json.git
git clone git://github.com/matsumoto-r/mruby-redis.git
git clone git://github.com/matsumoto-r/mruby-simplehttp.git
@matsumotory
matsumotory / uv_resolv.c
Created December 21, 2012 06:47
uv_resolv.c
//
// gcc -o uv_resolv uv_resolv.c -luv -lpthread -ldl -lrt -lm
//
#include <uv.h>
#include <stdio.h>
#include <stdlib.h>
uv_loop_t *loop;
@matsumotory
matsumotory / gist:4452687
Created January 4, 2013 13:44
mruby-config
desc "view mruby-config"
task :view_mruby_config do
all_mruby_libs, all_mruby_ldflags, all_mruby_cflags, all_mruby_includes = [], [], [], []
MRuby.targets.each do |t|
t.gems.map do |g|
all_mruby_libs << g.mruby_libs
all_mruby_ldflags << g.mruby_ldflags
all_mruby_cflags << g.mruby_cflags
all_mruby_includes << g.mruby_includes
end
@matsumotory
matsumotory / gist:4454387
Last active December 10, 2015 15:28
twitter home_timeline example using mruby
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_TOKEN_SECRET = ''
GET_API_URL = 'http://api.twitter.com/1/statuses/home_timeline.json?count='
tweet_num = 10
interval = 60
twitter = OAuth.new(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
@matsumotory
matsumotory / gist:4964941
Created February 16, 2013 01:04
mruby-capability example
c = Capability.new
cap = [Capability::CAP_SETUID, Capability::CAP_SETGID]
c.set Capability::CAP_PERMITTED, cap
pid = Process.fork {
loop do
c.get_proc
c.set Capability::CAP_EFFECTIVE, cap
sleep 2
uid = Random::rand 1000
@matsumotory
matsumotory / gist:4993058
Created February 20, 2013 05:08
embeddable microhttpd
//
// gcc -lmicrohttpd mhd.c
//
#include <string.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <microhttpd.h>
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self 合計
time seconds seconds calls ms/call ms/call 名前
78.45 43.33 43.33 385 112.55 126.32 mrb_run
5.08 46.13 2.81 204668409 0.00 0.00 kh_get_mt
4.16 48.44 2.30 204668365 0.00 0.00 mrb_method_search_vm
4.06 50.68 2.25 mrb_class
3.50 52.62 1.94 cipush