Skip to content

Instantly share code, notes, and snippets.

View hotchpotch's full-sized avatar
🏠
Working from home

Yuichi Tateno (secon) hotchpotch

🏠
Working from home
View GitHub Profile
/*
* for webkit (Safari4, Google Chrome2) bookmarklet
*
* javascript:(function(){var s=document.createElement("script");s.charset="UTF-8";s.src="http://gist.github.com/raw/156276/f7ef79b8da5514f44b84cf00367a92185747244d/gistfile1.js";s.onload=function(){_anim("div > * > * > * > *")};document.body.appendChild(s)})();
*/
window._anim = function _anim (selector) {
var elements = document.querySelectorAll(selector);
var s = document.createElement("script");s.charset="UTF-8";
var sprintf = function (str) {
var args = Array.prototype.slice.call(arguments, 1);
return str.replace(/%0(\d+)d/g, function(m, num) {
var r = String(args.shift());
var c = '';
num = parseInt(num) - r.length;
while (--num >= 0) c += '0';
return c + r;
}).replace(/%[sdf]/g, function(m) { return sprintf._SPRINTF_HASH[m](args.shift()) });
};
__jsloader__ = function(scripts, callback, errorback) {
var now = (new Date()) - 0;
if (typeof errorback != 'function')
errorback = function(url) { alert('jsloader load error: ' + url) };
var load = function(url) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.charset = 'utf-8';
class String
def blize
self.split('').join('/')
end
end
# $KCODE = 'u'
# puts 'ちょよんご'.blize #=> ち/ょ/よ/ん/ご
# Newbie programmer
$input=<>;
sub factorial {
$s=1;
$r=1;
while ($s <= $input) {
$r *= $s;
$s++;
}
if($input == 0)
#!/usr/bin/env ruby
class DigitConvertor
attr_reader :n
def initialize(chars)
@n = chars.size
@chars = chars
@chars_hash = Hash[*(@chars).zip((0..@n).to_a).flatten]
end
// ==UserScript==
// @name drag & drop fotolife uploader
// @namespace http://rails2u.com/*
// @description フォトライフでローカルファイルから drag & drop でファイルアップロード (HTML5 File API 対応ブラウザのみ)
// @include http://f.hatena.ne.jp/*/up*
// ==/UserScript==
var upForm = document.getElementById('upload');
// ==UserScript==
// @name Firefox to Phone
// @namespace http://rails2u.com/
// @description Send to Android phone
// @include http://*
// @include https://*
// ==/UserScript==
/*
* Original code by http://code.google.com/p/chrometophone/
// LDRize (c) id:snj14
function addStyle(css, id){ // GM_addStyle is slow
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'data:text/css,' + escape(css);
document.documentElement.childNodes[0].appendChild(link);
}
#!/usr/bin/env ruby
require 'rubygems'
require 'pathname'
gem 'bundler'
require 'bundler'
files = Bundler.load.specs.map do |spec|
path = Pathname.new(spec.full_gem_path)
spec.lib_files.map {|file| path.join(file).to_s }