Skip to content

Instantly share code, notes, and snippets.

View bxcodec's full-sized avatar
:octocat:
Learning and Making

Iman Tumorang bxcodec

:octocat:
Learning and Making
View GitHub Profile
@bxcodec
bxcodec / 1_intro.md
Last active May 18, 2023 15:30
[Bahasa Indoneisa] Golang Tutorial for Beginner: Create a simple REST API

Introduction

Pada tutorial ini, akan ada beberapa steps yang akan kita lakukan. Semua steps akan dijelaskan dibawah berikut.

Adapun stepsnya adalah sebagai berikut

  • Inisialisasi project
  • Membuat models
  • Membuat HTTP Handler
  • Menyambungkan aplikasi ke Database
@bxcodec
bxcodec / docker-rm-images.md
Created December 24, 2018 12:48 — forked from alferov/docker-rm-images.md
Remove all (untagged) images and containers from Docker
# Delete all containers
docker rm $(docker ps -aq)
# Delete all images
docker rmi $(docker images -q)
# Delete all untagged images
docker rmi $(docker images -q --filter "dangling=true")

References:

@bxcodec
bxcodec / gist:92201e2035a1d580b251fcafad1721bf
Created December 21, 2018 14:22 — forked from jaredhirsch/gist:4963424
ETags & If-None-Match headers: a dialogue

ETags & If-None-Match headers: a dialogue

1st request.

browser: can haz foo?

GET /foo HTTP/1.1

1st response.

@bxcodec
bxcodec / pr.md
Created November 22, 2018 04:31 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@bxcodec
bxcodec / simple_shell.go
Last active August 7, 2020 16:32
Simple Shell With Custom
package main
import (
"bufio"
"errors"
"fmt"
"os"
"os/exec"
"strconv"
"strings"
@bxcodec
bxcodec / simple_shell.go
Created November 7, 2018 08:25
Simple Shell Application in Go
package main
import (
"bufio"
"fmt"
"os"
"os/exec"
"strings"
)
// original from: http://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
// original gist: https://gist.github.com/willpatera/ee41ae374d3c9839c2d6
function doGet(e){
return handleResponse(e);
}
// Enter sheet name where data is to be written below
var SHEET_NAME = "writer";
@bxcodec
bxcodec / gist:7790c6017e16595ea59e821c2bfe4545
Created September 27, 2018 10:02 — forked from justincase/gist:5492212
Enable mgo debug log
mgo.SetDebug(true)
var aLogger *log.Logger
aLogger = log.New(os.Stderr, "", log.LstdFlags)
mgo.SetLogger(aLogger)
@bxcodec
bxcodec / _struct_to_map.go
Last active April 22, 2024 15:21
Golang Struct To Map Example By JSON tag
/*
This function will help you to convert your object from struct to map[string]interface{} based on your JSON tag in your structs.
Example how to use posted in sample_test.go file.
*/
func structToMap(item interface{}) map[string]interface{} {
res := map[string]interface{}{}
if item == nil {
return res
}
@bxcodec
bxcodec / main.go
Last active April 19, 2018 04:48
profiling_api
package main
import (
"fmt"
"log"
"net/http"
"net/http/pprof"
)
func Sample(w http.ResponseWriter, r *http.Request) {