Skip to content

Instantly share code, notes, and snippets.

Avatar

Satoh, Hiroh cho45

View GitHub Profile
View worker.pl
#!/usr/bin/env perl
use utf8;
use strict;
use warnings;
use lib lib => glob 'modules/*/lib';
use constant MAX_WORKER => 2;
use constant MAX_REQUEST_PER_CHILD => 100;
use constant INTERVAL => $ENV{INTERVAL} || 5;
use constant NAMESPACE => 'MyApp::Worker';
View localize_method.rb
#!ruby
class Foo
def hello
puts "Hello"
end
end
def localize_method(klass, method, &block)
unbound = klass.instance_method(method)
View guard_scope.rb
require 'continuation'
class Guard
attr_reader :args
attr_reader :called
attr_reader :result
def initialize(&before_finish)
@args = nil
@guard_cc = nil
View guard.rb
def guard_scope(&block)
context = self
guards = []
context.define_singleton_method(:guard) do |&b|
guards << b
end
block.call
ensure
View guard.rb
module Guard
@@guards = []
def guard(&block)
set_trace_func(lambda {|event, file, line, id, binding, klass|
# p [event, file, line, id, binding, klass]
case event
when "call", "c-call"
for g in @@guards
g[:count] += 1
end
View mruby_build_test.rb
#!/usr/bin/env ruby
MRUBY_CONFIG = 'sketch_mruby_config.rb'
File.open(MRUBY_CONFIG, "w") do |f|
f.puts `git show HEAD:build_config.rb`
end
ENV['MRUBY_CONFIG'] = MRUBY_CONFIG
def enable_gems
warn "enable_gems"
View 01-signatures-args.t
#!./perl -Ilib
use v5.19;
use strict;
use warnings;
use feature 'signatures';
no warnings "experimental::signatures";
use Test::More;
View c.c
//#!gcc -O0 -g3 -gdwarf-2 -Wall c.c -o /tmp/a.out && /tmp/a.out 1 2
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/mman.h>
uint8_t* memory[255];
uint8_t program_counter;
View sketch.s
/*#!as --gstabs+ -o sketch.o sketch.s && ld -o sketch -e _start sketch.o && objdump -d -j .text -j .data sketch && ./sketch
*/
.global _start
.macro sys_exit
mov r7, $0x01 /* set system call number to 1 (exit) */
svc $0x00 /* supervisor call */
.endm
View sketch.s
/*#!as --gstabs+ -o sketch.o sketch.s && ld -o sketch -e _start sketch.o && objdump -d -j .text -j .data sketch && ./sketch
*/
.global _start
.macro sys_exit
mov r7, $0x01 /* set system call number to 1 (exit) */
svc $0x00 /* supervisor call */
.endm
You can’t perform that action at this time.