Skip to content

Instantly share code, notes, and snippets.

@nanha
nanha / chatServer.js
Created April 17, 2012 06:19 — forked from creationix/chatServer.js
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@nanha
nanha / nodetime_sampling.js
Created April 16, 2012 15:21 — forked from shigeki/nodetime_sampling.js
example to use nodetime module within local environment
// nodetime for local use
var uphttp = require('http');
var nodetime = require('nodetime');
var upload_port = 12345;
nodetime.on('sample', function(sample) {
var upload = uphttp.request({ port: upload_port,
method: 'POST',
path: '/upload'
});
upload.end(JSON.stringify(sample));
Node v0.8 roadmap
-----------------
- Move the remaining platform functions from src/platform-*.cc into libuv.
- Get rid of waf. Waf is an ugly build system. All platforms will build
using gyp. (Ben)
- Extensions. We need to define an easy and suggested way of building
extensions, which should be similar across all supported platforms. (Bert,
@nanha
nanha / nodebrew
Created April 1, 2012 09:30 — forked from hokaccha/nodebrew
node package manager
#!/usr/bin/env perl
# nodebrew
#
# Install:
#
# 1. このスクリプトをダウンロードして実行権限つけてパスが通ってるところにおく
# 2. 以下にパスを通す
# $HOME/.nodebrew/current/bin
#
# Install gcc44 package and update-alternatives (in chkconfig)
yum -y install gcc44 chkconfig
# Check if gcc is already a link
if [ ! -L /usr/bin/gcc ]; then mv /usr/bin/gcc /usr/bin/gcc41; fi
if [ ! -L /usr/bin/g++ ]; then mv /usr/bin/g++ /usr/bin/g++41; fi
# Install update-alteratives links for gcc41 and gcc44
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc41 60 --slave /usr/bin/g++ g++ /usr/bin/g++41
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc44 40 --slave /usr/bin/g++ g++ /usr/bin/g++44
# Select gcc44 to compile gecode-3.5.0 in chef::bootstrap_server
update-alternatives --config gcc
@nanha
nanha / min_max.js
Created March 23, 2012 05:51 — forked from trekdemo/min_max.js
Min/Max selection in javascript ( ruby style )
// Usage
// [1, 2, 3, 4].max() => 4
// [1, 2, 3, 4].min() => 1
//
// With blocks
// [1, 2, 3, 4].max( function(d){
// return d*-1;
// }); => -1
//
// [1, 2, 3, 4].min( function(d){
<!-- This is a Node+WebSocket powered demo to sync videos
across different browsers. This file is the client,
the other one is the Node server. Powered by Node and
http://github.com/miksago/node-websocket-server -->
<style>
.inactive { display: none; }
.active { display: block; }
</style>
<script>
@nanha
nanha / nativemodule.js
Created February 16, 2012 15:00
Node's NativeModule
var NativeModule;
/* Hack to get a reference to node's internal NativeModule */
(function(){
// intercept NativeModule.require's call to process.moduleLoadList.push
process.moduleLoadList.push = function(){
// `NativeModule.require('native_module')` returns NativeModule
NativeModule = arguments.callee.caller('native_module');
// delete the interceptor and forward normal functionality
@nanha
nanha / gist:1826420
Created February 14, 2012 12:14 — forked from kennethkalmer/gist:278814
node.js SMTP Server
/*
smtpd.js is SMTP server written for node.js
MIT License
*/
var tcp = require('tcp');
var sys = require('sys');
@nanha
nanha / http_mem_usage
Created February 9, 2012 05:08
memory comparison between http and https servers
LIVE: 0 TOTAL: 0 MEM: 11.492 Mb DIFF: 0.004 Mb
LIVE: 0 TOTAL: 0 MEM: 11.770 Mb DIFF: 0.277 Mb
LIVE: 0 TOTAL: 0 MEM: 10.523 Mb DIFF: -1.246 Mb
LIVE: 0 TOTAL: 0 MEM: 10.527 Mb DIFF: 0.004 Mb
LIVE: 0 TOTAL: 0 MEM: 10.488 Mb DIFF: -0.039 Mb
LIVE: 0 TOTAL: 0 MEM: 10.492 Mb DIFF: 0.004 Mb
LIVE: 0 TOTAL: 449 MEM: 13.281 Mb DIFF: 2.789 Mb
LIVE: 0 TOTAL: 947 MEM: 14.941 Mb DIFF: 1.660 Mb
LIVE: 0 TOTAL: 1441 MEM: 15.832 Mb DIFF: 0.891 Mb
LIVE: 1 TOTAL: 1958 MEM: 17.031 Mb DIFF: 1.199 Mb