// jQuery
$(document).ready(function() {
// code
})
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
# Check JAN(Japanse Area Number) is valid or not | |
class JanCheck | |
def self.valid?(number) | |
new(number).valid? | |
end | |
attr_reader :number | |
def initialize(number) | |
@number = number.to_s |
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
sudo netstat -ntulp | grep -v '127.0.0.1:' | egrep '(tcp|udp)' | ruby -anle 'print $_ + "\t" + open("/proc/#{$_.match(/ (\d+)\//)[1]}/cmdline", "r").gets' |
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) |
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
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
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
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
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
console.log('Loaded..'); | |
class Togglable { | |
constructor(th) { | |
this.th = th; | |
this.table = th.parentNode.parentNode.parentNode; | |
this.tds = this.table.querySelectorAll('td:nth-child(' + this._getColumnIndex(th) + ')') | |
} | |
toggle() { |