This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nofity AR sql-log | |
# RAILS_ROOT/lib/log2n.rb | |
require 'n' | |
module ActiveRecord::ConnectionAdapters # :nodoc: | |
class AbstractAdapter | |
protected | |
def format_log_entry(message, dump) | |
n "%s %s" % [message, dump] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -wKU | |
# -*- coding: utf-8 -*- | |
require 'pp' | |
module Tictactoe | |
class Game | |
def initialize player1, player2, size=3 | |
@board = Board.new(size) | |
@players = [player1, player2,] | |
@players.map{ |p| p.board = @board } | |
@turn = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -wKU -rubygems | |
gem 'pauldix-typhoeus' | |
require 'typhoeus' | |
require 'rss' | |
require 'pp' | |
class Atnd | |
include Typhoeus | |
remote_defaults :on_success => lambda { |res| RSS::Parser.parse res.body, false }, | |
:on_failure => lambda { |res| nil }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /ruby/ruby187/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails_generator/options.rb 2009-07-23 18:56:58.000000000 +0900 | |
+++ /ruby/ruby191/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator/options.rb 2009-07-23 12:00:58.000000000 +0900 | |
@@ -137,7 +137,7 @@ | |
end | |
end | |
opt.on('-g', '--git', 'Modify files with git. (Note: git must be in path)') do | |
- options[:git] = `git status`.inject({:new => {}, :modified => {}}) do |opt, e| | |
+ options[:git] = `git status`.split($/).inject({:new => {}, :modified => {}}) do |opt, e| | |
opt[:new][e.chomp[14..-1]] = true if e =~ /new file:/ | |
opt[:modified][e.chomp[14..-1]] = true if e =~ /modified:/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -wKU | |
require 'benchmark' | |
dir = "/path/to/data" | |
Benchmark.bmbm do |job| | |
job.report('IO.foreach') do | |
File.foreach(File.join(dir, 'data.txt')) do |line| | |
uid, rid = line.chomp.split(/:/) | |
end | |
end | |
job.report('IO.readlines') do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def __DIR__ | |
File.dirname(caller(0)[1]) | |
end | |
end | |
puts __FILE__ | |
puts __DIR__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <limits.h> | |
#include <unistd.h> | |
void write_pid_file(const char* pid_file) | |
{ | |
// getcwd | |
FILE* fp = fopen(pid_file, "w"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Japanese translation of gitg. | |
# Copyright (C) 2009 gitg's COPYRIGHT HOLDER. | |
# This file is distributed under the same license as the gitg package. | |
# Yuki Miyauchi <[email protected]>, 2009. | |
msgid "" | |
msgstr "" | |
"Project-Id-Version: gitg master\n" | |
"Report-Msgid-Bugs-To: \n" | |
"POT-Creation-Date: 2009-08-29 13:49+0200\n" | |
"PO-Revision-Date: 2009-10-23 12:57+0900\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; vimのモードラインを読み込む | |
(defun load-vim-modeline-1 (matches) | |
(when matches | |
(dolist (match (split-string (match-string-no-properties 4))) | |
(when (or (string-match "^\\(tabstop\\|ts\\)=\\([0-9]+\\)$" match) | |
(string-match "^\\(shiftwidth\\|sw\\)=\\([0-9]+\\)$" match)) | |
(setq tab-width (string-to-number (match-string-no-properties 2 match)))) | |
(when (string-match "^\\(softtabstop\\|sts\\)=\\([0-9]+\\)$" match) | |
(setq tab-width (string-to-number (match-string-no-properties 2 match))) | |
(setq indent-tabs-mode nil)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -wKU | |
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'mechanize' | |
require 'logger' | |
isbns = DATA.readlines | |
isbns = isbns.map{ |isbn| isbn.chomp } | |
agent = WWW::Mechanize.new{ |a| a.log = Logger.new('input.log'); a.user_agent_alias = 'Mac Safari' } |
OlderNewer