Skip to content

Instantly share code, notes, and snippets.

View elgs's full-sized avatar
🌵

Qian Chen elgs

🌵
View GitHub Profile
@elgs
elgs / gist:c7fe4c3c83d8c3048f5e
Created August 25, 2014 07:21
reverse string in Golang
func reverse(input string) string {
n := 0
rune := make([]rune, len(input))
for _, r := range input {
rune[n] = r
n++
}
rune = rune[0:n]
// Reverse
for i := 0; i < n/2; i++ {
@elgs
elgs / Nodejs_Cluster.md
Last active August 29, 2015 13:56
Nodejs cluster
var cluster = require('cluster');
var http = require('http');
var numWorkers = 2;

if (cluster.isMaster) {
    // Fork worker.
    for (var i = 0; i < numWorkers; ++i) {
        console.log('master: about to fork a worker');
        cluster.fork();