Skip to content

Instantly share code, notes, and snippets.

View moehandi's full-sized avatar
:octocat:

M. Andi Saputra moehandi

:octocat:
  • Jakarta, Indonesia
View GitHub Profile
@moehandi
moehandi / negroni-gorilla.go
Created April 23, 2017 02:30 — forked from danesparza/negroni-gorilla.go
Negroni with Gorilla mux subrouter
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"log"
"net/http"
)
@moehandi
moehandi / main.go
Created April 23, 2017 02:13 — forked from Paulius-Maruska/main.go
Understanding http request routing with net/http and gorilla/mux.
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
func handler(name string)func (http.ResponseWriter, *http.Request) {
dummyHandler := func (w http.ResponseWriter, r *http.Request) {
@moehandi
moehandi / .Title
Created April 22, 2017 18:47 — forked from congjf/.Title
Using MongoDB in golang with mgo
Using MongoDB in golang with mgo
@moehandi
moehandi / golang-nuts.go
Created April 14, 2017 06:32 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@moehandi
moehandi / redirectExample.go
Created March 18, 2017 01:42 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
@moehandi
moehandi / tmux.md
Created February 24, 2017 07:36 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@moehandi
moehandi / golang-tls.md
Created December 13, 2016 02:40 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@moehandi
moehandi / client.go
Created December 13, 2016 02:39 — forked from spikebike/client.go
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@moehandi
moehandi / multiple_ssh_setting.md
Created December 2, 2016 16:20 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@moehandi
moehandi / include_list_viewpager.xml
Created July 21, 2016 06:43 — forked from iPaulPro/include_list_viewpager.xml
CollapsingToolbarLayout with TabLayout
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software