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 Sequelize = require('Sequelize'); | |
var sequelize = new Sequelize('dbname', 'username', 'password'); | |
sequelize.connectorManager.client.query('select * from tablename', function(err, results) { | |
if (!err) { | |
console.log(results); | |
// you'll get an array of objects | |
// [{id: 1, ...}, {id: 2, ...}] | |
} else { | |
console.log(err); | |
} |
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 async = require('async'); | |
function normalizeParamsAttributesNullValue (params, callback) { | |
async.forEachSeries(Object.keys(params), function(k, cb) { | |
if (params[k] === null) { | |
params[k] = ''; | |
} | |
cb(); | |
}, function() { | |
callback(params); |
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
ps alx | grep node | awk '{printf ("%d\t%s\n", $8,$13)}' |
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
// entry.js | |
function Entry (title) { | |
this.title = title; | |
} | |
Entry.prototype = { | |
title: null; | |
} |
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 dates = ['2003-12-13T18:30:02Z' | |
, '2003-12-13T18:30:02.25Z' | |
, '2003-12-13T18:30:02+01:00' | |
, '2003-12-13T18:30:02.25+01:00' | |
, '1980' | |
, 'invalid' | |
, null | |
] | |
function toISOString (string, callback) { |
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 querystring = require('querystring'); | |
var original = 'http://example.com/product/abcde.html'; | |
var escaped = querystring.escape(original); | |
console.log(escaped); | |
// http%3A%2F%2Fexample.com%2Fproduct%2Fabcde.html | |
var unescaped = querystring.unescape(escaped); | |
console.log(unescaped); |
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
compareObjects = function(obj1, obj2, callback) { | |
var paramName; | |
var compare = function(objA, objB, param) { | |
var paramObjA = objA[param] | |
, paramObjB = (typeof objB[param] === 'undefined') ? false : objB[param]; | |
switch (typeof objA[param]) { | |
case "object" : return (compareObjects(paramObjA, paramObjB)); | |
case "function" : return (paramObjA.toString() === paramObjB.toString()); |
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 async = require('async') | |
, childProcess = require('child_process'); | |
var commands = ['ls -l', 'echo hello']; | |
async.forEachSeries(commands, function(command, cb) { | |
childProcess.exec(command, function(err, stdout, stderr) { | |
if (!err) { | |
console.log(stdout); | |
console.log(stderr); |
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
$ node build-opds.js | |
<?xml version="1.0" encoding="UTF-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:opds="http://opds-spec.org/2010/catalog"><id>urn:uuid:433a5d6a-0b8c-4933-af65-4ca4f02763eb</id><title>feed title</title><updated>2010-01-10T10:01:11Z</updated><author><name>Feed author</name><uri>http://opds-spec.org</uri><email>[email protected]</email></author><link rel="self" type="application/atom+xml;profile=opds-catalog;kind=acquisition" href="/opds-catalogs/unpopular.xml"/><entry/></feed> | |
$ node build-opds.js | xmllint --format - | |
<?xml version="1.0" encoding="UTF-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:opds="http://opds-spec.org/2010/catalog"> | |
<id>urn:uuid:433a5d6a-0b8c-4933-af65-4ca4f02763eb</id> | |
<title>feed title</title> |
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
# --------------------------------------------------------------------- | |
# YAMLからOPDS取得フィードを生成するためのサンプルのYAML | |
# --------------------------------------------------------------------- | |
# 行頭に「#」がある行はコメントです。そこに何を書いてもパソコンには処理されません。 | |
# インデント(行の最初の空白)にタブを使うことはできません。2つの半角スペース(空白文字)を使ってください。 | |
# よく分からない場合はこのファイルの内容をコピーして、実際の内容で書き換えることが無難です。 | |
# YAMLの書き方については http://ja.wikipedia.org/wiki/YAML を参照してください。 |
OlderNewer