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> | |
| 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...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
| 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
| # 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
| # coding: UTF-8 | |
| #require "./tools" | |
| require "open-uri" | |
| require "pp" | |
| require "nokogiri" | |
| class VCard | |
| @@cookie_changed = true | |
| @@cookies = {} | |
| @@ua = "" |
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 "./tools2" | |
| require "pp" | |
| require 'json' | |
| require "nokogiri" | |
| VCard.set_ua | |
| baseurl = "http://vcard.ameba.jp/battle/battle-detail?enemyId=" | |
| 10.times do | |
| io = VCard.getio("/battle/ajax/battle-user-search?cond=level") |
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 | |
| loop do | |
| num = gets.chomp | |
| #puts num | |
| puts 'ERROR 'if num.length != 6 | |
| puts ( if /97085$/ =~ num | |
| '1等' | |
| elsif /2344$/ =~ num | |
| '2等' | |
| elsif /(72|74)$/ =~ num |
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
| #usage: xpath = mobilizer(html) | |
| require 'nokogiri' | |
| require 'kconv' | |
| def search_equal(pathes) | |
| return pathes[0] if pathes.size == 1 | |
| pathes.map! { |path| path.split('/') } | |
| fullsize = pathes.size | |
| path = [] |
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 'net/http' | |
| require 'uri' | |
| utid13 = 'your id' | |
| password = 'your password' | |
| url = 'https://webauth03.cc.tsukuba.ac.jp:8443/cgi-bin/adeflogin.cgi' | |
| res = Net::HTTP.post_form(URI.parse(url), {'name' => utid13, 'pass' => password }) | |
| puts res.body.scan(/Login.+?</) do |match| |