Skip to content

Instantly share code, notes, and snippets.

@ynwd
ynwd / Instal_and_configure_nginx.md
Created July 18, 2018 11:06 — forked from ipanardian/Instal_and_configure_nginx.md
Install and Configure Nginx on Mac

Install

$ brew install nginx

Setelah install jalankan nginx.
$ sudo nginx

Testing

Test apakah nginx sudah running, buka url http://localhost:8080.

Ganti default port

@ynwd
ynwd / docker_cmd.md
Last active June 12, 2019 04:37
Docker command line collection
Docker Basic Command Description
docker run hello-world Download the very small hello-world image and print a “Hello from Docker“ message
docker images Get List of Docker Images
docker search busybox Search the online Docker registry for a Image named busybox
docker run -t -i busybox Create an instance (container) of 'busybox' image interactively
docker run -t -i busybox:latest Create an instance with 'latest' tag value
docker run -t -i busybox:1.0 Create an instance with '1.0' tag value
docker ps --all List all containers
docker start ab0e37214358 Relaunch a Container
@ynwd
ynwd / mysql.md
Created January 18, 2019 03:51
Mysql
Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found
ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY 'root';
@ynwd
ynwd / error_handling.md
Created January 13, 2020 08:19
UnhandledPromiseRejectionWarning Error Handling

UnhandledPromiseRejectionWarning Error Handling

(node:15701) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Solution:

const checkFirstName = async (firstName) => {
@ynwd
ynwd / App.tsx
Created March 23, 2020 09:50
React useState & createContext
import React, { useState } from 'react'
const languages = { en: 'en', fr: 'fr' }
const initialTheme = { colour: 'blue', lang: languages.en }
const { Provider, Consumer } = React.createContext(initialTheme)
const App = (): JSX.Element => {
const [theme, setTheme] = useState(initialTheme)
const setLanguage = (lang: string): void => {
setTheme({ ...theme, lang: lang })
@ynwd
ynwd / fdb.ts
Created July 31, 2020 22:23
fdb
// ($lt, $lte, $gt, $gte, $in, $nin, $ne, $exists, $regex)
// $or, $and, $not, $where
function extractValue(object: any) {
const filterArray = [];
for (const key in object) {
filterArray.push(`${key};${object[key]}`);
}
const filterSort = filterArray.sort();
return filterSort.toString();
}
@ynwd
ynwd / jwt.ts
Last active August 22, 2020 07:26
Converting JWT callbacks to promises
import jwt from "jsonwebtoken";
export function tokenService() {
const SECRET = "secret";
return new Promise<string>((resolve, reject) => {
jwt.sign(
{ foo: "bar" },
SECRET,
(err: Error, token: string) => {
if (err) reject(err);
@ynwd
ynwd / docs-template.md
Last active December 20, 2023 09:54
Technical Documentation Template

Technical Documentation Template

First of all, you need to understand you are not writing documentation for you, nor for your current team. You are writing documentation for the future developers that were not there when you first wrote this code. Worst of it, they might think it is bad code for many reasons and won’t understand why you wrote this way.

Taken from: How to write good software technical documentation

Table of contents

@ynwd
ynwd / settuning.sh
Created October 2, 2020 22:14 — forked from mcollina/settuning.sh
m3medium config
#!/bin/bash
sysctl net.core.rmem_default=268435456
sysctl net.core.wmem_default=268435456
sysctl net.core.rmem_max=268435456
sysctl net.core.wmem_max=268435456
sysctl net.core.netdev_max_backlog=100000
sysctl "net.ipv4.tcp_rmem=4096 16384 134217728"
sysctl "net.ipv4.tcp_wmem=4096 16384 134217728"
sysctl "net.ipv4.tcp_mem=786432 1048576 268435456"