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
<<DATA.split.shuffle.each do |i| p i end | |
1 | |
2 | |
3 | |
DATA |
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
require 'open-uri' | |
require 'nokogiri' | |
page = Nokogiri::HTML(open('http://kzrb.doorkeeper.jp/events/8563')) | |
page.css('.user-name').children.to_a.shuffle.each do |name| | |
puts name.content | |
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
# Ignore bundler config. | |
/.bundle | |
# Ignore the default SQLite database. | |
/db/*.sqlite3 | |
/db/*.sqlite3-journal | |
# Ignore all logfiles and tempfiles. | |
/log/*.log | |
/tmp |
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
require 'uri' | |
require 'net/http' | |
tco = "https://t.co/DyfjrVazCG" | |
res = Net::HTTP.get_response(URI.parse(tco)) | |
p res["location"] |
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
require 'active_support/all' | |
target_day = Date.new(2014, 4) | |
month = target_day.beginning_of_month.upto(target_day.end_of_month) | |
month.each do |d| | |
puts "#{d} cwday: #{d.wday} wday: #{d.cwday} cweek: #{d.cweek}" | |
end | |
=begin | |
2014-04-01 cwday: 2 wday: 2 cweek: 14 |
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 DSL | |
module DSL | |
def my_attr_accessor(name) | |
define_method name do | |
instance_variable_get("@#{name}") | |
end | |
define_method "#{name}=" do |value| | |
instance_variable_set("@#{name}", value) | |
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
require 'open-uri' | |
require 'nokogiri' | |
page = Nokogiri::HTML(open('http://kzrb.org/meetup/')) | |
dates = page.css('header ul li').map(&:text).reverse | |
YEAR = 2014 | |
dates = dates.map do |date| | |
date =~ /(#{YEAR}-\d\d-\d\d)/ |
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
ary1 = [1, 2, 3] | |
ary2 = [1, 1, 3] | |
p 'uniq' | |
p ary1.uniq | |
p ary2.uniq | |
p 'uniq!' | |
p ary1.uniq! |
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
require 'nokogiri' | |
require 'open-uri' | |
connected_shop_name = '' | |
hanbey = Nokogiri::HTML(open('http://www.hanbey.com/info/')) | |
hanbey.css('.table_shopname strong').each do |all_shop_name| | |
all_shop_name.children.each do |divided_shop_name| | |
connected_shop_name += divided_shop_name.content.strip | |
end | |
puts connected_shop_name unless connected_shop_name.empty? |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>D3.js の練習</title> | |
</head> | |
<body> | |
<p>Hello 1</p> | |
<p>Hello 2</p> | |
<p>Hello 3</p> |
OlderNewer