Skip to content

Instantly share code, notes, and snippets.

View yssk22's full-sized avatar

yssk22 yssk22

View GitHub Profile
@yssk22
yssk22 / gist:1553571
Created January 3, 2012 05:04
pt2 installation recipe on ubuntu 10.04
# install prerequisites
%w(libpcsclite-dev build-essential autoconf pcsc-tools pcscd).each do |p|
package p do
action :install
end
end
package "linux-headers-#{`uname -r`}" do
action :install
end
@yssk22
yssk22 / gist:1378865
Created November 19, 2011 14:09
node-mongodb-native について(エラーがでるコード)
> var server = new (require('mongodb').Server)('localhost', 27017);
> var db = new (require('mongodb').Db)('foo', server);
> db.open(function(){
... db.collection('foo', function(_, collection){
... collection.insert([{"_id": 'foo'}, {"_id": 'foo'}], {safe:true}, function(e){ console.log(e); })
... });
... });
> { stack: [Getter/Setter],
arguments: undefined,
type: undefined,
@yssk22
yssk22 / gist:1378832
Created November 19, 2011 13:17
node-mongodb-native について
// insertの結果を待たずに実行
col.insert({}, function(){}); // (a)
col.insert({}, function(){}); // (b)
// async.parallel を使って a, b は非同期で実行するが、 a, b, のりょうほうが終わったら c を呼ぶ
async.parallel({
"a": function(cb){
col.insert(..., cb);
},
"b": function(cb){
@yssk22
yssk22 / https-with-http-proxy.js
Created September 15, 2011 14:25
Node.js: access https URI via http proxy
var http = require('http');
var tls = require('tls');
var crypto = require('crypto');
var opts = {
host: 'proxy.com',
port: 8080,
method: 'CONNECT',
path: 'securehost.com:443',
headers: {
@yssk22
yssk22 / link-addons.js
Created September 8, 2011 14:50
Example: running node application with C-based add-on modules on CloudFoundry
@yssk22
yssk22 / paralell.js
Created December 14, 2010 12:48
parallel middleware for Express/Connect.
/***
* @function make the parallel request filters and finish with the last filter.
*
* @example
*
* misc.parallel(
* func1, func2, func3, func4
* );
*
* func1 ---+
@yssk22
yssk22 / express+couch.js
Created December 8, 2010 15:32
what I want.
exports.application = function(server){
server.get('/',
newsFeeds,
misc.title('Home'), misc.renderWithBindings('index.ejs'));
server.get('/login', authorized, misc.redirect('/'));
server.get('/logout', oauth.logout, misc.redirect('/'));
server.get('/profiles/', authorized, misc.renderWithBindings('profiles/index.ejs'));
server.get('/archives/', authorized, misc.renderWithBindings('archives/index.ejs'));
server.get('/schedules/list',
@yssk22
yssk22 / couchdb_proxy_middleware
Created December 5, 2010 07:23
CouchDB proxy middleware
/*******************************************
* Connect middleware to proxy request to
* the specified path on CouchDB.
*
* Usage:
*
* app.use(express.bodyDecoder());
* app.use(function(req, res, next){
* res.bindings = res.bindings || {};
* });
@yssk22
yssk22 / redis.js
Created November 14, 2010 08:19
Redis sample program (retwis) ported to node.js
/**
* retwis-js.js
*
* Description:
*
* redis tutorial program impelmented by node.js
*
* Usage:
*
* node redis.js
function copy(fileUrl, docUrl, event, trace){
if( !trace ){
trace = 0;
}
if( !trace ){
event = new EventEmitter();
}
if( trace == MAX_TRACE ){
logger.error('Max trace exceeded. ({fileUrl} -> {docUrl})'.format({fileUrl: fileUrl, docUrl: docUrl}));
return undefined;