Skip to content

Instantly share code, notes, and snippets.

@ishiduca
ishiduca / gist:1239076
Created September 24, 2011 07:27
COMIC ZIN検索の結果を ハッシュリファレンスで返す based AnyEvent
package AnyEvent::Search::Scrape::Zin;
use strict;
use utf8;
use Carp;
use Encode;
use AnyEvent;
use AnyEvent::HTTP;
use URI::Escape;
use Web::Scraper;
@ishiduca
ishiduca / gist:1239483
Created September 24, 2011 16:01
メロンブックス検索の結果を ハッシュリファレンスで返す
package WWW::Search::Scrape::Melon;
use strict;
use Carp;
use utf8;
use Encode;
use LWP::UserAgent;
use URI::Escape;
use Web::Scraper;
use Data::Dumper;
@ishiduca
ishiduca / gist:1240706
Created September 25, 2011 15:13
Node.js && npm install memo
install node.js v0.4.11 && install npm
[参照]「node.js」 http://nodejs.jp/nodejs.org_ja/docs/v0.4/
[参照]「Building and Installing Node.js - GitHub」 https://github.com/joyent/node/wiki/Installation
# ここから
$ git clone --depth 1 git://github.com/joyent/node.git
$ cd node
$ git checkout v0.4.11
$ export JOBS=2
@ishiduca
ishiduca / gist:1250015
Created September 29, 2011 05:02
Node.js ファイルのダウンロード
var fs = require('fs');
var path = require('path');
var http = require('http');
// リンク先は .mp3 ファイル
var options = {
method : 'GET',
host : 'm.friendfeed-media.com',
port : '80',
path : '/0c5e82d9e6a0d5e60a1a85609adbe0e7f02976a6'
@ishiduca
ishiduca / gist:1252940
Created September 30, 2011 07:15
httpClientRequestのラッパー
var url = require('url');
var http = require('http');
var path = require('path');
// httpRequest('POST', 'http://xxx.com/post', { 'connection' : 'keep-alive' }, "mode=write&data=foo", function (res, req) {
// console.log(res.statusCode);
// console.log(JSON.stringify(res.headers));
// console.log(JSON.stringify(req));
//
// var data = '';
@ishiduca
ishiduca / gist:1254094
Created September 30, 2011 15:23
pixivへのログインから画像ダウンロード #Node.js #HttpClient
var HttpClient = require('../lib/httpClient.js').HttpClient;
var client = new HttpClient ();
var body = require('querystring').stringify({
mode : 'login', pixiv_id : 'your pixiv id', pass : 'your pixiv pass'
});
var pixivHome = 'http://www.pixiv.net';
var loginPhp = [ pixivHome, '/login.php' ].join('');
@ishiduca
ishiduca / gist:1258811
Created October 3, 2011 10:05
チェーンメソッドを使う HTTPClient #Node.js
var http = require('http'),
url = require('url');
var _version = '0.001'; // 2011.10.03
function HTTPClient (config) {
config = config || {};
var storage = {};
this['redirect'] = config['redirect'] || false; // redirect: not ok
// https://gist.github.com/1258811 のサンプル
var HTTPClient = require('./lib/http/client.js').HTTPClient;
var body = require('querystring').stringify({
mode : 'login', pixiv_id : 'your pixiv id', pass : 'your pixiv pass'
});
try {
@ishiduca
ishiduca / gist:1263830
Created October 5, 2011 07:04
Function#papply と Function#lessCurry
var sum = function () {
for (var v = 0,i = 0,l = arguments.length; i < l; v += arguments[i++]); return v;
};
console.log(sum(2,3,4)); // 9
// これは部分適用というらしい
if (! Function.prototype.papply) {
Function.prototype.papply = function () {
var slice = Array.prototype.slice,
@ishiduca
ishiduca / gist:1270236
Created October 7, 2011 13:06
部分適用メソッドを使って遅延評価
// 部分適用メソッド
if (! Function.prototype.papply) {
Function.prototype.papply = function (thisObject, args) {
var slice = Array.prototype.slice;
var func = this;
return function () {
args = args.concat(slice.apply(arguments));
return func.apply(thisObject, args);
};
};