Skip to content

Instantly share code, notes, and snippets.

View rosylilly's full-sized avatar
🕊️
Happy Hacking

Sho Kusano rosylilly

🕊️
Happy Hacking
View GitHub Profile
@rosylilly
rosylilly / fileWatch.rb
Created June 18, 2011 22:35
ファイルの更新を検知するFile.watchメソッドを生やす
require 'thread'
class File
# ファイルの更新を検知して、渡されたブロックを実行する
# 更新検知部分のコードは[ここ](http://ja.doukaku.org/comment/387/)のを丸パクリ
def self.watch(fileName, &function)
raise AugumentsError if(!File.exist?(fileName) || !function)
thread = Thread.new(fileName, function){ | _fileName, _function |
Thread.pass
last_mtime = File.mtime(_fileName)
@rosylilly
rosylilly / lyric_manage.user.js
Created December 30, 2010 19:23
ニコニコ動画歌詞メンテ支援Greasemonkey
// ==UserScript==
// @name NicoLyricManager
// @namespace NicoLyricManager
// @description ニコ動の歌詞職人支援ツール
// @include http://www.nicovideo.jp/watch/*
// @include http://nine.nicovideo.jp/watch/*
// @excludes
// ==/UserScript==
(function(){
class Array
def nindex(n)
p self
_index = self.index(n)
if _index.nil?
return []
else
if _index == (self.size - 1)
return [_index]
else
# 実現したいこと
puts "0"
# Golf
p 0
# 縛り
# 英数字禁止
$><<"#$.#$/"
@rosylilly
rosylilly / atmark_variables.rb
Created October 8, 2009 10:58
理解不能
class Foo
@baz = 1
@@bar = 2
def self.baz; @baz; end
def self.baz=(n); @baz=n; end
def self.bar; @@bar; end
def self.bar=(n); @@bar=n; end
end
class Hoge < Foo
#nil# Public local sketchbook
Desktop Templates log src
Documents Videos obj themes
Examples bin page-speed-images tmp
Firefox_wallpaper.png dev page-speed-javascript デスクトップ
Music hsptmp salasaga 編集中のドキュメント 1
Pictures j602 server
Class.class_eval do
undef :allocate
end
begin
p Class.new
rescue => e
p e
end
# => <Class:0x*******>
class Object
def self_methods
methods.map{|m|
m=method(m.to_sym)
(m.owner == self.class ? m.name : nil )
}.compact
end
end
p ''.methods.sort
@rosylilly
rosylilly / index.cgi
Created July 5, 2009 03:34
違う、違うんだ。俺が悪いんじゃない。アイツが俺を殺そうとしたから……!
#!ruby path
ENV['GEM_HOME'] = "gem path"
require 'rubygems'
require 'cgi'
require 'RMagick'
require 'kconv'
print "Content-Type: text/html\n\n"
@rosylilly
rosylilly / prototype.rb
Created April 12, 2009 16:41
Prototypical Objects on ruby
class Prototype
def new(member = {}, &block)
prototype(member || {}, self,&block)
end
def respond_to?(name)
return self if methods.include?(name.to_s)
__proto__ = @proto.respond_to?(name)
return __proto__ if __proto__
false