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
bundle update | |
for m in `git d Gemfile.lock | egrep '^\+ \w' | sed -e 's/^\+ //' -e 's/ (.*//' | sort -u`; do | |
git checkout Gemfile.lock | |
bundle update $m | |
git add -u Gemfile.lock | |
git commit -m ":up: $m" | |
git push origin HEAD | |
echo "============== $m ===============" | |
done |
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
class StoneTori | |
class Stones | |
def initialize(count) | |
@count = count | |
end | |
def empty? | |
@count.zero? | |
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
since = '2016/3/22' | |
path = 'app/assets/stylesheets' | |
`git log --pretty="format:%ad %h" --date=short --since="#{since}" #{path}`.split("\n").reverse.each do |line| | |
date, rev = line.split | |
system("git checkout #{rev} 2> /dev/null") | |
count = `find #{path} -type f -exec wc -l {} \\; | awk '{n+=$1} END{print n}'`.chomp.to_i | |
puts [date, rev, count].join(',') | |
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
gzcat tmp/sitemaps/sitemap.xml.gz | ruby -rnokogiri -e 'Nokogiri::XML($stdin.read).search("url/loc").each {|n| puts n.text }' |
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
vals = { | |
type: ['wood','iron','other'], | |
length: [1,2,3,4,5], | |
width: [1,2,3], | |
} | |
class Hash | |
def combination | |
keys.reduce([{}]) do |r, key| | |
r = _add_to_combination(r, key) |
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
# Fill with nil, until list will be the size. | |
# | |
# [:a].nilfil(4) #=> [:a, nil, nil, nil, nil] | |
# [:a,:b,:b,:d,:e].nilfil(4) #=> [:a, :b, :b, :d, :e] | |
class Array | |
def nilfil(size) | |
me = self.dup | |
me[size - 1] = me[size - 1] | |
me |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
# 結論 | |
# | |
# ContentTag >>>>> Inline Erb >> Inline HAML | |
# | |
# 可読性とパフォーマンスのどちらを取りたいか考えて選択しましょう | |
# | |
# | |
# Inline HAML | |
# |
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
class AddColumnIdToLogs < ActiveRecord::Migration | |
def up | |
add_column :logs, :id, :integer, null: false # FIXME: Add column to head of columns | |
execute 'SET @rownum = 0' | |
execute 'UPDATE `access_logs` SET `id` = @rownum := @rownum + 1' | |
execute 'ALTER TABLE `logs` ADD PRIMARY KEY(`id`, `date`)' # Partitioning key () must be primary key. | |
execute 'ALTER TABLE `logs` CHANGE `id` id INT(11) AUTO_INCREMENT' | |
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
# Usage: | |
# Book.new('foo.ods').sheet('first sheet').each do |row| | |
# puts "first column => " + row["first column"] | |
# puts "second column => " + row["second column"] | |
# end | |
# | |
# Write gem 'roo' at Gemfile | |
module Foo | |
class Book | |
def initialize(file) |