Skip to content

Instantly share code, notes, and snippets.

🌵

Qian Chen elgs

🌵
Block or report user

Report or block elgs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@elgs
elgs / gist:c7fe4c3c83d8c3048f5e
Created Aug 25, 2014
reverse string in Golang
View gist:c7fe4c3c83d8c3048f5e
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 Aug 29, 2015
Nodejs cluster
View Nodejs_Cluster.md
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();
You can’t perform that action at this time.