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
| # coding: UTF-8 | |
| require "open-uri" | |
| require "nokogiri" | |
| url = 'http://akb48matome.com/archives/51881418.html' | |
| page = Nokogiri::HTML(open(url)) | |
| File.write "matome.html" , page.to_html | |
| #page = Nokogiri::HTML(open('./matome.html')) | |
| items = page.xpath('//table/tbody/tr') | |
| sum = 0 |
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
| require "nokogiri" | |
| require "./collection-post" | |
| require 'open-uri' | |
| ua = "Mozilla/5.0 (Linux; U; Android 4.0.3; ja-jp; URBANO PROGRESSO Build/010.0.3000) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30" | |
| cookies = { "gameAuthId" => "Your own gameAuthId", "vcardPixelRatio" => "1" } | |
| cookie_str = cookies.map { |cookie| cookie.join('=') }.join(';') | |
| $header = { "Cookie" => cookie_str, "User-Agent" => ua } | |
| def vcard_getio( url ) |
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
| for i in 1...250 | |
| sum = 0 | |
| t = i | |
| while sum<500 | |
| sum += t | |
| if sum==500 | |
| puts i | |
| break | |
| end | |
| t += 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
| #include <stdio.h> | |
| int main(void) | |
| { | |
| int i,t,sum; | |
| for(i=1;i<250;i++) | |
| { | |
| sum = 0; | |
| for(t=i;sum<500;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
| for i in 1..200 | |
| puts i if i%7 == 3 && i%5 == 2 && i%3 == 1 | |
| end | |
| #=>52,157 |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main(int argc,char *argv[]) | |
| { | |
| unsigned int a,b,amari,i; | |
| if(argc<2) | |
| { | |
| printf("整数を入力してください。\n"); |
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
| require 'open-uri' | |
| Dir.mkdir("yosan_up") unless FileTest.exist? "yosan_up" | |
| ("01".."18").each do |i| | |
| url = "http://www.jr-eki.com/timetable/yosan_up-seto/img/#{i}.gif" | |
| image = open(url).read | |
| File.write("yosan_up/" + i + ".gif",image) | |
| 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
| #coding: UTF-8 | |
| module Totsuzen | |
| def totsuzen(str = "突然の死") | |
| str_length = 0 | |
| str.each_char do |c| | |
| str_length += (c.bytesize > 1) ? 2 : 1 | |
| end | |
| str_length /= 2 | |
| result = "_人#{ "人" * str_length }人_\n" | |
| result << "> #{str} <\n" |
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
| $ git status | ruby -ne '/modified:\s+(.+?\.rb)/ =~ $_ ; print $1," " if $1' | |
| => | |
| a.rb | |
| b.rb |
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
| require "pp" | |
| module MyTwitter | |
| def links_only(statuses) | |
| include_links_statuses = [] | |
| statuses.each do |status| | |
| include_links_statuses << status unless ( status.urls.empty? && status.media.empty? ) | |
| end | |
| # pp include_links_statuses |