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
package main | |
import "fmt" | |
var from int = 1 | |
var to int = 1000 / 4 * 100 // (1000/4コア*100) | |
var period int = 1000000 * 1000 // 1000倍重くする | |
func main() { | |
ch1 := make(chan bool) |
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
defmodule Multicore do | |
@moduledoc """ | |
Documentation for Multicore. | |
""" | |
@doc """ | |
Hello world. | |
## Examples |
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
HOGE = (1..10000000).to_a | |
EXPECTED_ORDER = 1000 | |
NUM_OF_CORES = 4 | |
PROCESSING_ORDER = EXPECTED_ORDER / NUM_OF_CORES | |
def sum | |
PROCESSING_ORDER.times do | |
p HOGE.sum | |
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 Hoge | |
class << self | |
def store(identificate: identificate) | |
hoges[identificate] ||= hoges.store(identificate, Hoge.new) | |
end | |
def hoges | |
@hoges ||= {} | |
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' | |
itiran = open("http://hayabusa.2ch.net/news4vip/subback.html").read | |
doc = Nokogiri::HTML.parse(itiran) | |
doc.css('a').each do |anchor| | |
p anchor[:href] | |
p anchor.children.first.text | |
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' | |
itiran = open("http://hayabusa.2ch.net/news4vip/subback.html").read | |
doc = Nokogiri::HTML.parse(itiran) | |
doc.css('a').each do |anchor| | |
p anchor[:href] | |
p anchor.children.first.text | |
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
encoding: utf-8 | |
# TODO ①URL解析 ②HTML取得 ③検索部分を抜き出す ④結果をparseする ⑤結果をcsvで表示 | |
require 'open-uri' | |
require 'csv' | |
url = ARGV[0] # URLを実行時引数から入力 | |
key_word = (ARGV[1]) # キワードの検索で使用する | |
html = open(url).read | |
# ここは使用するかビミョなので一旦コメントアウトする |
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 "csv" | |
require "uri" | |
class CreateScrapingCsv | |
def make(search_keys, url, file_name) | |
csv_body = [] | |
search_keys.each do |key| | |
csv_body << search(key,url) | |
end | |
make_csv(file_name, csv_body) |
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 'net/http' | |
require 'uri' | |
#スクリプト仕様 | |
# httpのみ対応 | |
# 検索結果はresult.csvに出力 | |
class Scribe | |
attr_accessor :url, :keywords |
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 'net/http' | |
require 'uri' | |
require 'optparse' | |
require "csv" | |
params = ARGV.getopts("k:", "u:") | |
uri = URI.parse params["u"] | |
document = Net::HTTP.start(uri.host, uri.port) do |http| | |
response = http.get("/") |
NewerOlder