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
// "httpRequest" [ url, body, headers ] | |
// httpRequest = parseURI(method, uri); | |
function _parseQuery (uriObj) { | |
var buf = []; | |
if (! uriObj) return null; | |
if (typeof uriObj === 'string') return uriObj; | |
if (typeof uriObj === 'object') { | |
if (uriObj.length && uriObj.length > 0) { | |
uriObj.foreach(function (keyVal, i) { |
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
function foreach (arry, func) { | |
var i = 0, len = arry.length; | |
if (len) { | |
for (; i < len; i += 1) { | |
func(arry[i], i); | |
} | |
} | |
} | |
Array.prototype.foreach = function (func) { |
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
package WWW::Search::Scrape::Toranoana; | |
use strict; | |
use utf8; | |
use Carp; | |
use Encode; | |
use LWP::UserAgent; | |
use URI; | |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
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
// 関数の返す結果が想定した結果と同等かをチェックする test メソッド | |
// Func.test(thisObj, argsArray, forecast); | |
if (! Function.prototype.test) { | |
Function.prototype.test = function (that, args, forecast) { | |
var result = this.apply(that, args); | |
result = JSON.stringify(result); | |
forecast = JSON.stringify(forecast); | |
// return (result === forecast) ? true : false; 本当はこっち |
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
function qw (str, cut) { | |
if (typeof str !== 'string') return null; | |
cut = cut || /\s+/; | |
cut = (typeof cut === 'string') ? new RegExp(cut) : cut; | |
return str.replace(/^\s+/,'').replace(/\s+$/,'').split(cut); | |
} | |
var ARRY = qw( " G E f b a D c " ); |
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
// javascriptの配列でソートした結果を取得する場合 | |
// arrayORG.sort(); | |
// | |
// すると、元々の配列(arrayORG)がソートした並びに代えられてしまって具合が良くない場合がある。 | |
// arrayCOPY = arrayORG.sort(); | |
// | |
// みたいにできないので、そういう場合には | |
// arrayCOPY = arrayORG.slice(0).sort(); | |
// | |
// すると、arrayORGのコピーを作って、それをソートすることになるので、(コストは安くないけど) |
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
// javascript 1.6 以上だと filteredArray = array.filter(callback[, thisObject]) を使うといい。 | |
// 使えない場合に grep を実装する | |
// | |
// var FuncOfGrepRule = function (itemOfArray) { | |
// return (itemOfArray.match(/condition/)) ? true : false; | |
// }); | |
// | |
// var newArray = orgArray.grep(FuncOfGrepRule); | |
// |
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
// 配列の重複した値を間引いた新しい配列を返す | |
if (! Array.prototype.uniq) { | |
Array.prototype.uniq = function () { | |
var that = this.slice(0), len = that.length, storage = {}; | |
for (len--; len >= 0; len--) { | |
if (! storage[that[len]]) { | |
storage[that[len]] = true; | |
} else { | |
that.splice(len, 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
package WWW::Search::Scrape::Zin; | |
use strict; | |
use utf8; | |
#use Encode; | |
use Carp; | |
use URI; | |
use URI::Escape; | |
use Web::Scraper; | |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
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
package AnyEvent::Search::Scrape::Toranoana; | |
use strict; | |
use Carp; | |
use utf8; | |
use Encode; | |
use AnyEvent; | |
use AnyEvent::HTTP; | |
use URI::Escape; |