Skip to content

Instantly share code, notes, and snippets.

@shibason
shibason / quineaa.rb
Created September 19, 2010 08:09
QuineAA Generator Generator
MAIN_CODE = %w~
_quine_template_ = ->(_data_, _zipped_, _padding_, _width_, _height_) {
%`
#{(_zipped_) ? "require 'zlib';" : ''}
_aa_data_ = Marshal.load(#{(_zipped_) ? 'Zlib::Inflate.inflate(' : ''}
'#{_data_}'.unpack('m')[0]#{(_zipped_) ? ')' : ''});
_self_ = 'eval$s=%w' << 96 << ($s * #{_padding_});
_result_ = '';
_index_ = -1;
#{_width_ * _height_}.times { |_counter_|
@shibason
shibason / mikusan.rb
Created September 19, 2010 05:52
AA Quine & AA Quine generator (Hatsune Miku)
eval$s=%w~
a=->(b,c, d,e,f){%`#{(c)?"re quire'zlib';":'
'}g=Marshal.load(#{ (c)?'Z lib::Inflate.infl
ate(':''}'#{b}'. unpack('m')[0]#{(c)?')':
''});h= 'eval$s =%w'<<126<<($s*#{d} );i='
';j=- 1; #{ e*f}.times{|k|i<< (g[
k]== 1? h[j+=1]:32);i<<10i f
(k% #{e} ==#{e-1})};i[-7,6]
=' ' < <126<< '.join';puts(i)#`};
$*[ 0]? ( require' RMagick';include(Ma
@shibason
shibason / rspec_sample.rb
Created July 31, 2010 16:43
RSpec sample: Stubbing a Kernel method in a constructor
# Stubbing a Kernel method in a constructor
class Sample
def initialize
puts 'Hello world!'
end
end
describe Sample do
it '#initialize call puts' do
@shibason
shibason / nicovideo_pixiv_crosspedia.user.js
Created March 15, 2010 11:00
ニコニコ大百科⇔ピクペディアを相互参照するGreasemonkeyスクリプト
// ==UserScript==
// @name NicoVideo-Pixiv CrossPedia
// @namespace http://d.hatena.ne.jp/shibason/
// @description ニコニコ大百科⇔ピクペディアの相互参照
// @include http://www.nicovideo.jp/watch/*
// @include http://dic.nicovideo.jp/a/*
// @include http://www.pixiv.net/member_illust.php*
// @include http://dic.pixiv.net/a/*
// @author shibason
// @version 1.0