This file contains hidden or 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 ActiveRecord::ConnectionAdapters::SchemaStatements | |
alias orig_add_index add_index | |
def add_index(table_name, column_name, options = {}) | |
orig_add_index(table_name, column_name, options || {}) | |
end | |
end |
This file contains hidden or 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
# create table users (id integer auto_increment, primary key (id)); | |
# create table items (id integer auto_increment, user_id integer, primary key (id)); | |
# insert into users (id) values (1); | |
# insert into items (user_id) values (1); | |
% cat a.rb | |
require 'rubygems' | |
require 'active_support/dependencies' | |
require 'active_record' |
This file contains hidden or 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
instance_eval <<_E | |
puts "\xe3\x81\x82".encoding # => ASCII-8BIT | |
_E | |
instance_eval <<_E | |
# coding: utf-8 | |
puts "\xe3\x81\x82".encoding # => UTF-8 | |
_E |
This file contains hidden or 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
ä | |
<%= @str %> |
This file contains hidden or 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
;; find-fileで*Completions*バッファに`../'と`./'を出さない | |
(defun find-file-read-args (prompt mustmatch) | |
(list (read-file-name prompt nil default-directory mustmatch nil | |
(lambda (name) | |
(and (file-exists-p name) | |
(not (member name '("../" "./")))) | |
)) | |
t)) |
This file contains hidden or 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/share/zsh/4.3.12/functions/VCS_INFO_bydir_detect 2011-08-08 04:59:41.001000000 +0900 | |
+++ VCS_INFO_bydir_detect 2012-01-19 21:52:35.293434600 +0900 | |
@@ -6,7 +6,7 @@ | |
local dirname=$1 | |
local basedir="." realbasedir file | |
-realbasedir="$(VCS_INFO_realpath ${basedir})" | |
+realbasedir="${basedir:A}" | |
while [[ ${realbasedir} != '/' ]]; do | |
[[ -r ${realbasedir} ]] || return 1 |
This file contains hidden or 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
a='VWXYZ' | |
${(l:3::abcdefg::1234567890:)a} # => XYZ | |
${(l:10::abcdefg::1234567890:)a} # => 67890VWXYZ | |
${(l:20::abcdefg::1234567890:)a} # => cdefg1234567890VWXYZ | |
${(r:3::abcdefg::1234567890:)a} # => VWX | |
${(r:10::abcdefg::1234567890:)a} # => VWXYZ12345 | |
${(r:20::abcdefg::1234567890:)a} # => VWXYZ1234567890abcde |
This file contains hidden or 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
function f { | |
local s='old' | |
echo -n "${(r:15:: :)1}${(e)1}" | |
s='' | |
echo -n "\t${(e)1}" | |
unset s | |
echo -n "\t${(e)1}" | |
echo | |
} |
This file contains hidden or 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
s | |
k | |
t | |
h | |
ka | |
m | |
sh | |
n | |
z | |
ko |
This file contains hidden or 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/env ruby | |
# usage: skk2migemo.rb SKK-JISYO.JIS3_4 > migemo-dict.jis3_4 | |
require 'iconv' | |
dict = Hash.new{[]} | |
ARGF.each_line do |line| | |
line.chomp! | |
line = Iconv.conv('UTF-8', 'EUC-JISX0213', line) | |
next if line =~ /\A;/ | |
if line =~ /\A([^ ]+) +(.*)\z/ | |
key, value = $1, $2 |
OlderNewer