Skip to content

Instantly share code, notes, and snippets.

@ynwd
ynwd / reflection.go
Created November 30, 2020 05:31 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@ynwd
ynwd / clear_cache.md
Last active November 6, 2024 00:24
postgres uuid extension in docker-compose

Clear Cache

docker-compose rm -fv db
@ynwd
ynwd / golang_vscode_unit_test.md
Last active December 23, 2020 10:18
golang unit test with vscode
  1. create salam.go
  2. create main.go
  3. open salam.go on vs-code
  4. put your pointer to CreateSalam method.
  5. righ-click, select 'Generate Tests for Function'. this will create a new file salam_test.go
  6. run go test ./...
@ynwd
ynwd / agile.md
Last active February 15, 2021 04:19
Scrum: Simplified

Scrum: Simplified

Catatan ini merupakan refleksi dari pengalaman setelah merasakan implementasi scrum di beberapa tempat. Juga rangkuman-rangkuman setelah membaca-baca dokumentasi resmi dan mengikuti beberapa kursus scrum di Linked Learning.

Misalnya, klien Anda ingin membuat aplikasi e-commerce. Anda kemudian membuat semua proposal dan dokumentasinya secara detail setelah melakukan analisa yang lama dan mendalam. Klien pun kemudian setuju. Tim development lalu memulai pengerjaan.

Tapi ternyata, di tengah pengerjaan, ada kebutuhan bisnis sangat mendesak, yang memaksa klien Anda untuk mengubah sebagian atau seluruh alur bisnis.

Jika menggunakan manajemen tradisional, maka seluruh perencanaan dan penulisan dokumentasi harus dilakukan ulang hingga selesai agar pengerjaan bisa dilakukan. Tentu saja hal ini akan membutuhkan waktu sebagaimana proses sebelumnya.

@ynwd
ynwd / react_test.md
Created November 7, 2021 07:28
React testing using @testing-library/react and msw

This is a modification of the App.tsx and App.test.tsx CRAs.

It uses useEffect to get the text from the API.

App.tsx

import React, { useEffect, useState } from 'react';
import logo from './logo.svg';
import './App.css';
@ynwd
ynwd / logo.svg
Last active December 12, 2021 22:09
logo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ynwd
ynwd / main.go
Created December 21, 2021 23:31
mongodb
package main
import (
"context"
"encoding/json"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
@ynwd
ynwd / App.js
Created January 21, 2022 09:32
useReducer simple example
import React, { useReducer } from 'react'
function countReducer(state, count) {
console.log("count=", count)
console.log("state=", state)
return count
}
function App() {
@ynwd
ynwd / App.js
Created January 21, 2022 10:03
react createContext simple example
import React, { useContext, useReducer, createContext } from 'react'
function Counter() {
const { count, setCount } = useContext(CountContext)
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
@ynwd
ynwd / App.js
Created January 22, 2022 01:47
react useEffect & useContext example
import React, { useContext, useReducer, createContext, useEffect } from 'react'
function Counter() {
const { count, setCount } = useContext(CountContext)
useEffect(() => {
document.title = `You clicked ${count} times`
}, [count])
return (