Skip to content

Instantly share code, notes, and snippets.

View astromahi's full-sized avatar

Mahendran Kathirvel astromahi

View GitHub Profile
@nf
nf / hello-node.js
Created July 6, 2012 21:14
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
@mreiferson
mreiferson / gist:4039222
Created November 8, 2012 14:48
Example NSQ reader in Go - simplified nsq_to_http
const (
ModeAll = iota
ModeRoundRobin
)
type Publisher interface {
Publish(string, []byte) error
}
type PublishHandler struct {
@andelf
andelf / sendMail.go
Last active September 20, 2023 15:13
golang send mail net/smtp SMTP
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"
@justinas
justinas / 1_singlehost.go
Last active November 29, 2023 11:41
Go middleware samples for my blog post. http://justinas.org/writing-http-middleware-in-go/
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
@leesmith
leesmith / simple-git-workflow.md
Last active December 30, 2023 23:37
Simple Git Workflow For Continuous Delivery

Simple Git Workflow For Continuous Delivery

Workflow guidelines:

  • master branch is always production-ready, deployable, 100% green test suite
  • New development is done on feature branches, with frequent rebasing onto master
  • Clean commit history by preferring to rebase instead of merge (git pull is configured to automatically rebase)

rebase workflow

Workflow

@mschoebel
mschoebel / main.go
Created March 6, 2014 20:02
Snippet: login/logout (Golang)
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
@chrisgillis
chrisgillis / ssl_smtp_example.go
Created April 16, 2014 14:48
Golang SSL SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 20, 2024 16:52
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@bryfry
bryfry / gzip.go
Last active August 28, 2023 09:23
Idiomatic golang net/http gzip transparent compression (works with Alice)
package main
import (
"compress/gzip"
"io"
"net/http"
"strings"
)
// Gzip Compression
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"