Skip to content

Instantly share code, notes, and snippets.

#!ruby
if false
class C
def m
xxxx
end
end
def mm
yyyy
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
#!/bin/sh
# https://gist.github.com/nurse/6101638
export U=naruse
export PUBKEY_URL=http://nalsh.jp/ssh.pub
## before running this script
### Debian
# edit /etc/network/interfaces with dns-nameservers
# sudo aptitude update && sudo aptitude safe-upgrade
@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__)
@nurse
nurse / gist:4324519
Last active February 28, 2018 11:53
ぼくの考えた最強のRuby新機能案

ぼくの考えた最強のRuby新機能案

野心的な新機能案や、互換性等の理由でおよそ採用されないであろう夢を書き連ねています。

Remove Fixnum and Bignum

Fixnum と Bignum を削除して、Integer クラスに統合する。両者は Flonum のように内部的に切り替えられる。

1 / 2 is Rational

Integer#/ の結果を Rational で返すようにする。 https://bugs.ruby-lang.org/issues/5512#change-37021

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.

@nurse
nurse / gist:3015253
Last active February 23, 2017 06:00
プログラミングを悟るための公案集

プログラミング公案集

「公案」とは禅で用いられ、なんたら かんたら。 この公案を考えることでオブジェクト指向プログラミングの悟りをなんたらかんたら。

変数

  • Q: 変数とは何か?
  • A: 箱である
  • B: ラベルである
@nurse
nurse / gist:2779978
Created May 24, 2012 07:07
chkbuild用config.ru for sqale
class Rack::File
alias _serving serving
def serving(env)
_serving(env).tap do |status, headers, body|
path = env['PATH_INFO']
if path.end_with?('/rss')
headers["Content-Type"] = 'application/rss+xml'
elsif path.end_with?('.gz')
headers["Content-Type"] = Rack::Mime.mime_type(::File.extname(path[0..-4]), 'text/plain')
headers["Content-Encoding"] = 'gzip'