Skip to content

Instantly share code, notes, and snippets.

View bagus2x's full-sized avatar
🎯
Focusing

tubagus saifulloh bagus2x

🎯
Focusing
View GitHub Profile
$ sudo snap install --classic heroku
$ git init
$ git add . && git commit -m "...
$ touch Procfile
========================
web: bin/contoh
========================
$ go build -o bin/contoh
$ heroku create contoh
$ git push heroku master:master
@bagus2x
bagus2x / .bashrc
Last active October 16, 2020 01:56
golang env .bashrc
# config yg lain
export GOPATH=/home/bagus2x/Documents/workspace/go
export GOBIN=/home/bagus2x/Documents/workspace/go/bin
export PATH=$PATH:$GOBIN
export PATH="$PATH:$(yarn global bin)"
alias n=nvim
alias repo="cd ~/Documents/workspace/go/src/github.com/bagus2x"
@bagus2x
bagus2x / c.psm1
Created September 17, 2020 16:42
golang cross compile di windows
$env:GOOS = "linux"
go build -o bin/server server.go
@bagus2x
bagus2x / ps1.sh
Last active October 29, 2020 06:06
bash shell ps1 example | user[branch]β–Ίβ–Ί
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
@bagus2x
bagus2x / ps1.sh
Created October 29, 2020 06:06
simple ps1
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
fi
class Main {
public static void main(String[] args) {
int nilai[][] = {
{15, 10, 7, 12, 25},
{37, 22, 30, 17, 11},
{8, 37, 4, 18, 32}
};
int max = nilai[0][0];
for(int i = 0; i < nilai[0].length; i++) { // kolom
@bagus2x
bagus2x / goroutineerror.go
Last active December 3, 2020 22:18
belajar handle error di goroutine dengan channel
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
type result struct {
data string
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=[pass]' -p 1433:1433 -d mcr.microsoft.com/mssql/server
docker exec -it [cont_name/id] bash
# Inside container
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P [pass]
[{"codes":"1F600","char":"πŸ˜€","name":"grinning face","category":"Smileys & Emotion (face-smiling)","group":"Smileys & Emotion","subgroup":"face-smiling"},{"codes":"1F603","char":"πŸ˜ƒ","name":"grinning face with big eyes","category":"Smileys & Emotion (face-smiling)","group":"Smileys & Emotion","subgroup":"face-smiling"},{"codes":"1F604","char":"πŸ˜„","name":"grinning face with smiling eyes","category":"Smileys & Emotion (face-smiling)","group":"Smileys & Emotion","subgroup":"face-smiling"},{"codes":"1F601","char":"😁","name":"beaming face with smiling eyes","category":"Smileys & Emotion (face-smiling)","group":"Smileys & Emotion","subgroup":"face-smiling"},{"codes":"1F606","char":"πŸ˜†","name":"grinning squinting face","category":"Smileys & Emotion (face-smiling)","group":"Smileys & Emotion","subgroup":"face-smiling"},{"codes":"1F605","char":"πŸ˜…","name":"grinning face with sweat","category":"Smileys & Emotion (face-smiling)","group":"Smileys & Emotion","subgroup":"face-smiling"},{"codes":"1F923","char":"🀣","name":"rolli
When designing schemas in Mongo DB, expecially the first times, a quick useful checklist to choose whether or not to use embedded documents in one-to-many relation.
So here is the checklist:
Type of query: ask yourself what could be the best model representation for the most frequent queries you'll need to do. Everytime I'll get the parent document I'll always (or really often) need all the child documents. Answer: Nested.
Data model lifecycle: think about the life cycle of the container document and its content: make sense that child documents will still have to exist when the parent document is deleted? If the answer is "no" nested is the way.
Snapshots: another reason that should affect your choice is the data you're representing and if the nested item is a snapshot of something happened at a given time. Suppose you're working with a "Receipt" object that contains a list of buyed products these will be copied as a nested documents in the receipt. You're storing an information related to a s