Skip to content

Instantly share code, notes, and snippets.

@A
A / daemon.js
Created December 12, 2013 07:22
Daemonize and clusterize express.js app.
#!/usr/bin/env node
'use strict';
/**
* bin/node-simple-http-daemon
*/
// Everything above this line will be executed twice
require('daemon')();
var request = require('supertest');
var assert = require('assert');
// ...
var testUser = {
username: 'thisisatestuser',
email: '[email protected]',
password: 'test'
};
@A
A / middleware-basicAutn.js
Created December 22, 2013 14:46
middleware basicAuth
'use strict';
/**
* Module dependencies.
*/
var log = require('winston-wrapper')(module);
var config = require('nconf');
var express = require('express');
@A
A / npm.log
Created December 25, 2013 10:35
The initial build for the application failed: Shell command '/sbin/runuser -s /bin/sh 52bab4925004467099000001 -c "exec /usr/bin/runcon 'unconfined_u:system_r:openshift_t:s0:c4,c804' /bin/sh -c \"gear postreceive --init >> /tmp/initial-build.log 2>&1\""' returned an error. rc=255 .Last 10 kB of build output: Stopping NodeJS cartridge Repairing links for 1 deployments Building git ref 'master', commit bfb8307 Building NodeJS cartridge npm info it worked if it ends with ok npm info using [email protected] npm info using [email protected] npm info preinstall [email protected] npm info trying registry request attempt 1 at 05:34:37 npm http GET https://registry.npmjs.org/bootable npm info trying registry request attempt 1 at 05:34:38 npm http GET https://registry.npmjs.org/require-tree npm info trying registry request attempt 1 at 05:34:38 npm http GET https://registry.npmjs.org/stylus npm info trying registry request attempt 1 at 05:34:38 npm http GET https://registry.npmjs.org/connect-stylus npm info trying registry re
@A
A / cluster
Last active January 3, 2016 02:59
$ ab -n 1000 -c 100 -k -q http://0.0.0.0:8000/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 0.0.0.0 (be patient).....done
Server Software:
@A
A / async.js
Created January 20, 2014 11:44
// Synchronous
var a = function (x) {
while(new Date().getTime() < now + 1000) {
// do nothing
}
console.log(x)
};
a(1); // waits 1 sec and prints 1
a(2); // waits for finish `a(1)` then wait another 1 sec and prints 1
git submodule add git://github.com/chneukirchen/rack.git rack
# Initialized empty Git repository in /opt/subtest/rack/.git/
# remote: Counting objects: 3181, done.
#remote: Compressing objects: 100% (1534/1534), done.
# remote: Total 3181 (delta 1951), reused 2623 (delta 1603)
# Receiving objects: 100% (3181/3181), 675.42 KiB | 422 KiB/s, done.
# Resolving deltas: 100% (1951/1951), done.
$ git submodule init
# Submodule 'rack' (git://github.com/chneukirchen/rack.git) registered for path 'rack'
@A
A / dabblet.css
Created January 20, 2014 14:17
margins
/**
* margins
*/
body {
background: #aeb;
}
.first, .second {
width: 200px;
@A
A / dabblet.css
Created January 22, 2014 10:11
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.font {
width: 200px;
height: 100px;
font-size:20px;
}
@A
A / dabblet.css
Created January 22, 2014 12:32
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.a {
width: 600px;
height: 400px;
background: grey;
position: relative;
}