Skip to content

Instantly share code, notes, and snippets.

@nurse
nurse / yarv-profile.rb
Last active July 9, 2016 18:02
Profile perf(3)'s report into YARV instructions
#!/usr/bin/env ruby
require 'pp'
files = {'vm.inc' => [], 'insns.def' => []}
current_insn = nil
current_filename = 'vm.inc'
lineno_offset = 0
IO.foreach('vm.inc') do |line|
case line
when /^INSN_ENTRY\((\w+)\)/
@nurse
nurse / gist:99adc8a91972c915380b
Last active June 9, 2016 08:37
Windowsに欲しいUnix互換機能メモ
Original:
Performance counter stats for './miniruby -e@v=42; n=100_000_000;while n>0; x=@v; x=@v; x=@v; n-=1;end':
5675.422561 task-clock (msec) # 0.998 CPUs utilized
159 context-switches # 0.028 K/sec
2 cpu-migrations # 0.000 K/sec
889 page-faults # 0.157 K/sec
16521817067 cycles # 2.911 GHz
4121915626 stalled-cycles-frontend # 24.95% frontend cycles idle
@nurse
nurse / chkbuild.yml.erb
Created September 13, 2015 18:02
template for chkbuild with serverkit
resources:
- type: package
name: zsh
- type: package
name: screen
- type: package
name: subversion
- type: group
name: <%= user %>
require 'nokogiri'
# XMLLexer - SAX with scanner like API
class XMLLexer
def initialize(path)
@f = Fiber.new do
parser = Nokogiri::HTML::SAX::Parser.new(DocProxy.new)
parser.parse_file(path)
raise EOFError
end
@nurse
nurse / gist:5027888
Last active December 14, 2015 04:28
僕の考えた最強の Binary Pack 仕様

僕の考えた最強の Binary Pack 仕様

追加する format

  • annotation
  • bignum (多倍長整数)
  • decimal
  • rational
  • raw inf (64でいい?)
  • array inf (64でいい?)
@nurse
nurse / gist:5002610
Last active December 14, 2015 00:59
常識の無いメイド卿に贈るやっておくべきエロゲ百選

常識の無いメイド卿に贈るやっておくべきエロゲ百選

(製作中です)

elf

  • EVE
  • YU-NO

Leaf

@nurse
nurse / thread_stack_pcs.patch
Created February 5, 2013 07:37
A patch for darwin's Libc-825.25, which fixes a bug that backtrace(3) doesn't work if it is called from signal handler when it uses alternate signal stack. http://www.opensource.apple.com/source/Libc/Libc-825.25/gen/thread_stack_pcs.c
--- gen/thread_stack_pcs.c.orig 2013-02-04 15:51:02.000000000 +0900
+++ gen/thread_stack_pcs.c 2013-02-05 14:45:47.000000000 +0900
@@ -37,6 +37,7 @@
#endif
#define INSTACK(a) ((a) >= stackbot && (a) <= stacktop)
+#define INALTSTACK(a) ((a) >= altstackbot && (a) <= altstacktop)
#if defined(__ppc__) || defined(__ppc64__) || defined(__x86_64__)
#define ISALIGNED(a) ((((uintptr_t)(a)) & 0xf) == 0)
#elif defined(__arm__)
% time ./miniruby -e'a=100;i=0;while i<0xffffff;i+=1;a*=557;a+=2;a%=100000;end'
./miniruby -e'a=100;i=0;while i<0xffffff;i+=1;a*=557;a+=2;a%=100000;end' 2.64s user 0.01s system 99% cpu 2.649 total
% ruby -e'puts RubyVM::InstructionSequence.compile(%q{a=100;i=0;while i<0xffffff;i+=1;a*=557;a+=2;a%=
100000;end}).disasm'
== disasm: #<ISeq:<compiled>@<compiled>>================================
== catch table
| catch type: break st: 0015 ed: 0060 sp: 0000 cont: 0060
| catch type: next st: 0015 ed: 0060 sp: 0000 cont: 0012
| catch type: redo st: 0015 ed: 0060 sp: 0000 cont: 0015
|------------------------------------------------------------------------

Requirements of the Ruby Standard Specification

Patch Level

The spec defines behavior of each release versions like 1.9.2, 1.9.3, 2.0.0. It mustn't see patch level.

Implementation Defined Behavior

Implementations have some their specific features like objspace, RubyVM, TracePoint of MRI.