Skip to content

Instantly share code, notes, and snippets.

#!/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 / pid2line.rb
Last active December 27, 2018 08:51
Show source files and line numers of given process's threads
#!/usr/bin/env ruby
#
# pid2line.rb
#
# Show source files and line numers of given process's threads
#
# This script works only on Linux.
# https://gist.github.com/nurse/0619b6af90df140508c2
#
@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

#!ruby
if false
class C
def m
xxxx
end
end
def mm
yyyy
@nurse
nurse / gist:3015253
Last active February 23, 2017 06:00
プログラミングを悟るための公案集

プログラミング公案集

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

変数

  • Q: 変数とは何か?
  • A: 箱である
  • B: ラベルである
@nurse
nurse / gist:555963
Last active January 24, 2017 05:45
JIS8 charset for emacs

IRC 等で用いられるいわゆる半角カナを含む ISO-2022-JP variant の emacs 用設定

文字セット

reg#  character set       ESC sequence  designated to
------------------------------------------------------
  6   US-ASCII            ESC ( B       G0
 13   JIS X 0201-Katakana ESC ( I       G0
 14   JIS X 0201-Roman    ESC ( J       G0

42 JIS X 0208-1978 ESC $ @ G0

@nurse
nurse / result.sh
Last active October 24, 2016 18:59
% ruby --disable-gems test.rb
{:T_HASH=>1, :T_DATA=>2}
{:T_ARRAY=>1, :T_HASH=>1, :T_DATA=>1}
@nurse
nurse / gist:f916e5ef81d59cfc7315
Last active October 24, 2016 07:30
OpenSSL commands
# p12ファイル内の秘密鍵に対応する公開鍵を表示
openssl pkcs12 -in foo.p12 -nodes | openssl rsa -passin pass: -pubout|openssl rsa -pubin -text
# 証明書を表示
openssl x509 -inform der -in ~/Downloads/ios_distribution.cer -text
openssl genrsa -des3 -out tls.2015.key 2048
openssl req -new -key tls.2015.key -out tls.2015.csr
mv tls.2015.key tls.2015.key.pass
openssl rsa -in tls.2015.key.pass -out tls.2015.key
@nurse
nurse / gist:f9a068c2e84f9324f7626795b212302e
Created September 12, 2016 08:58
Create large string
require 'fiddle'
def create_large_string(size)
func = Fiddle::Function.new(Fiddle::Handle::DEFAULT['rb_str_new'], [Fiddle::TYPE_VOIDP,Fiddle::TYPE_LONG], Fiddle::TYPE_VOIDP)
# returns fast on environments whose malloc delays the actual allocation
ptr = func.call(nil, size)
end
@nurse
nurse / gist:70ddf2b4e82537d71f066d8609853dc4
Created September 12, 2016 04:53
Benchmark result on Haswell
2016-09-12 07:02:10 +0900
target 0: ruby 2.4.0dev (2016-07-22 trunk 55727) [x86_64-linux] at "./miniruby55727 -I./lib -I. -I.ext/common --disable-gem"
target 1: built-ruby (ruby 2.4.0dev (2016-09-11) [x86_64-linux]) at "./miniruby -I./lib -I. -I.ext/common --disable-gem"
measure target: real
-----------------------------------------------------------
app_answer
def ack(m, n)
if m == 0 then