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 "uri" | |
require 'net/http' | |
require "rss" | |
require "openssl" | |
keywords = ['旅順', '203高地'] | |
news_feed_uri = URI.parse("https://news.google.com/news?output=rss&q=" + keywords.join('+')) |
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
import random | |
import time | |
import functools | |
from multiprocessing import Pool | |
def Timer(func): | |
@functools.wraps(func) | |
def Wrapper(*args, **kw): | |
stime = time.clock() | |
ret = func(*args, **kw) |
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
avg_keys = ['res1', 'res2'] | |
def aggregate | |
aggregate_results = [] | |
for cond in conds: | |
aggregated_result = cond.copy() | |
vals = { | |
v: [] for v in avg_keys | |
} | |
for r in self.flatten_result_set: |
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
# condは検索条件となるdictで、{'param1': 0.1, 'param2': 0.2} | |
# といったように検索条件となるキーしか持たないdict | |
# dict_itemはそのcondと一致するかどうか判定されるdicで、 | |
# {'param1': 0.1, 'param2': 0.2, 'res1': 2.5, 'res': 8.2} | |
# というように集計する値を持つ方 | |
def comp(cond, dict_item): | |
for k in self.merge_keys: | |
if not cond[k] == dict_item[k]: | |
return False | |
return True |
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
merge_keys = ['param1', 'param2'] | |
flatten_result_set = [{...}, {...}, {...}] | |
# キーとなるパラメーターの組み合わせを全部リストアップする | |
# この際重複を除くため一旦セットに | |
key_patterns = set( | |
tuple(r[c] for c in merge_keys) for r in flatten_result_set | |
) | |
# => set( (0.1, 0.5), (2.4, 5.2),....) | |
# というように現れたparam1-param2の全組み合わせになる |
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
def shori(args): | |
arg = args[0] | |
... | |
(実際の処理) | |
... | |
return result | |
itr = [(i, arg) for i in range(n)] # nは並列させたい個数 | |
with Pool() as pool: | |
results_set = pool.map(shori, itr) |
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"> | |
<link href="../assets/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet"> | |
<script src="../src/lib/jquery-1.11.3.min.js"></script> | |
<script src="../src/lib/jquery_convert.js"></script> | |
<script src="../assets/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script> | |
<title>mangarack</title> | |
</head> |
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
'use strict' | |
var glob = require('glob'); | |
var appData = require('./../appData').appData; | |
var setting = require('./setting').setting; | |
var libraryWatcher = { | |
fetchFileList: function(cb) { | |
glob(setting.watch_dir[0], function(err, matches) { | |
console.log(setting.watch_dir); |
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
var appData = (function() { | |
var instance; | |
function init() { | |
return { | |
appName: "mangarack", | |
} | |
}; | |
return { |
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
'use strict'; | |
var mkdirp = require('mkdirp'); | |
var fs = require('fs-extra'); | |
var path = require('path'); | |
var appData = require('./../appData').appData; | |
var setting = (function() { | |
var instance; | |
var settingJSON = path.join(process.env[(process.platform == 'win32') ? 'APPDATA' : 'HOME'], appData.appName, 'setting.json'); |