Skip to content

Instantly share code, notes, and snippets.

@nazomikan
nazomikan / public_index.html
Created March 17, 2014 05:41
render in browser
<html>
<head>
<style type="text/css">
div {
width: 600px;
height: 50px;
}
.blue { background-color: blue; }
.green { background-color: green; }
var fs = require('fs'),
path = require('path');
(function scan(dir) {
fs.readdirSync(dir).forEach(function (item) {
var stat = fs.statSync(path.join(dir, item));
if (stat.isFile()) require(path.join(dir, item));
else if (stat.isDirectory()) scan(path.join(dir, item));
});
})('./lib/some/dir');
@nazomikan
nazomikan / app.js
Last active January 3, 2016 03:29
expire-test
var http = require('http')
, connect = require('connect')
, app
;
app = connect()
.use(assetsExpire(1000 * 60 * 3))
.use(connect.static('public'))
.use(function(req, res){
res.end(' \
var http = require("http")
, server
;
server = http.createServer(function (req, res) {
res.writeHead(200);
res.end("<html><body><p>hi i am hidakaya</p></body></html>");
});
module.exports = server;
@nazomikan
nazomikan / app.js
Last active December 31, 2015 08:29
var path = require('path')
, mode = process.env.NODE_ENV || 'development'
, env = require(path.resolve('resources/environments', mode))
;
console.log(env.WHOAMI);
// output: dev太郎

npm start コマンドを実行すると、 package.json の script.start コマンドが実行される

"scripts": {
  "start": "NODE_ENV=production NODE_PATH=lib node --harmony_typeof --harmony"
}

http://d.hatena.ne.jp/Jxck/20120410/1334071898 Node.js の起動オプション、環境変数、npm start の話

ChangeLog を支える英語

ChangeLog を書く際によく使われる英語をまとめました。

ほとんど引用です。

基本形

function Window() {
....
}
Window.prototype.build = function () {
this.setWidet();
}
Wondow.prototype.setWidget = function () {
this.root.add(this.widget.tabMenue);
@nazomikan
nazomikan / interop.md
Created February 10, 2013 07:02 — forked from domenic/interop.md

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.

@nazomikan
nazomikan / division.js
Created September 21, 2012 17:24
Processing division < javascript1.7
(function () {
var queue;
queue = createQueue(0, 0, 100, 100, 25, function (xMin, yMin, xMax, yMax) {
var x, y;
for (x = xMin; x < xMax; x++) {
for (y = yMin; y < yMax; y++) {
// do someThing
}
}
});