This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<.*?(>)|<\/[\w]+> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createContext, Dispatch, useContext, useMemo } from 'react'; | |
interface ActionsT { | |
INCREMENT: string; | |
DECREMENT: string; | |
} | |
export const Actions: ActionsT = { | |
INCREMENT: 'INCREMENT', | |
DECREMENT: 'DECREMENT' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gosqlnull | |
import ( | |
"database/sql" | |
"encoding/json" | |
"testing" | |
"github.com/stretchr/testify/assert" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse, CancelToken } from 'axios'; | |
import { history } from '../App'; | |
const BASE_URL = 'http://localhost:8080'; | |
export const publicClient = axios.create({ | |
baseURL: BASE_URL | |
}); | |
export const privateClient = axios.create({ | |
baseURL: BASE_URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MutableRefObject, useEffect, useRef } from 'react'; | |
interface Options<Target> { | |
root?: MutableRefObject<any>; | |
enabled?: boolean; | |
rootMargin?: string; | |
threshold: number; | |
onIntersect: (entry?: IntersectionObserverEntry, target?: Target) => void; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Keunggulannya bisa untuk nonunique column timestamp | |
CREATE TABLE cek ( | |
id SERIAL PRIMARY KEY, | |
name VARCHAR(50) NOT NULL, | |
created_at INT NOT NULL | |
); | |
INSERT INTO cek VALUES (DEFAULT, 'satu', 1); | |
INSERT INTO cek VALUES (DEFAULT, 'dua', 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ~/.go | |
echo "GOPATH=$HOME/.go" >> ~/.bashrc | |
echo "export GOPATH" >> ~/.bashrc | |
echo "PATH=\$PATH:\$GOPATH/bin # Add GOPATH/bin to PATH for scripting" >> ~/.bashrc | |
source ~/.bashrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"syscall" | |
"unsafe" | |
) | |
func main() { | |
str := []byte("Hello World") | |
syscall.Syscall(syscall.SYS_WRITE, uintptr(syscall.Stdout), uintptr(unsafe.Pointer(&str[0])), uintptr(len(str))) |