Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🦁

Takuto Wada twada

💭
🦁
View GitHub Profile
View gist:10564
#
# usage: ruby this_script.rb | git am --3way
#
require 'net/imap'
require 'rubygems'
require 'activesupport'
id = 'your.gmail.id'
pass = 'your.gmail.pass'
View gist:30410
;;;;;;;;;; functions
(defun funcall-replace-region (start end func)
"replace region with funcall result. region content(between start/end) is passed to func as string"
(let ((orig (buffer-substring start end)))
(save-excursion
(save-restriction
(narrow-to-region start end)
(delete-region start end)
(insert-string (funcall func orig))))))
View gist:37864
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'amazon/aws/search'
require 'erb'
hatena_template = <<-EOT
*** <%= book.item_attributes.title %>
ASIN:<%= book.asin %>:detail
View gist:65020
# -*- coding: utf-8 -*-
require 'net/telnet'
module Filetter
class MozRepl
def self.run
begin
telnet = Net::Telnet.new("Port" => 4242) {|c| print c}
telnet.cmd("content.location.reload(true)")
View gist:186565
require 'yaml'
require 'active_record'
class ActiveRecord::Migrator
class << self
TARGET_METHODS = %w[up down]
TARGET_METHODS.each do |name|
define_method("#{name}_with_database_dump") do |*args|
dump_current_database
View js18_reduce_for_prototype.js
/*
* (c) 2009 Takuto Wada; MIT License
* JavaScript 1.8 compliant Array#reduce that also works with old prototype.js
* usage: load this AFTER prototype.js
*/
(function () {
// prototype.js's Array#reduce is removed since 1.6.1_rc2
// see: http://github.com/sstephenson/prototype/commit/b34355653e1a663764fd8f69b4915f966c58cf55
if (typeof Prototype !== 'undefined' && /^1\.(?:[0-5]\.\S+|6\.(?:0(?:\.\d)?|1_rc1))$/.test(Prototype.Version)) {
View 1 test_helper.js
exports = module.exports = global;
var path = require('path');
QUnit = require(path.join(path.dirname(require.resolve('qunit-tap')), '..', 'vendor', 'qunit', 'qunit', 'qunit')).QUnit;
require("qunit-tap").qunitTap(QUnit, require("sys").puts, { noPlan: true });
QUnit.init();
QUnit.config.updateRate = 0;
exports.assert = QUnit;
@twada
twada / jojo_rush_formatter.rb
Created May 11, 2011
突き(ラッシュ)の速さ比べ
View jojo_rush_formatter.rb
require 'spec/runner/formatter/progress_bar_formatter'
class JojoRushFormatter < Spec::Runner::Formatter::ProgressBarFormatter
def example_failed(example, counter, failure)
@output.print colorize_failure('無駄', failure)
@output.flush
end
def example_passed(example)
@output.print green('オラ')
@output.flush
@twada
twada / shibuya-el-position-paper.md
Created Sep 6, 2012 — forked from ainame/shibuya-el-position-paper.md
shibuya.elのポジションペーパーです。githubアカウントをお持ちの方はforkしてお使いください。
View shibuya-el-position-paper.md

Shibuya.el#1 ポジションペーパー

Personal

View wikipedia_ja.rb
# -*- coding: utf-8 -*-
# Find japanese entry for each en.wikipedia.org link in TARGET_URL (quick & dirty hack)
# USAGE: ruby wikipedia_ja.rb TARGET_URL
require 'rubygems'
require 'nokogiri'
require 'open-uri'
def ja_url_for(url)
link_ja = Nokogiri::HTML(open(url)).css('li.interlanguage-link.interwiki-ja a').first