Skip to content

Instantly share code, notes, and snippets.

View nomkhonwaan's full-sized avatar
💭
while(me.awake()) { me.code(); }

Natcha Luangaroonchai nomkhonwaan

💭
while(me.awake()) { me.code(); }
View GitHub Profile
@nomkhonwaan
nomkhonwaan / config.json
Last active December 18, 2019 05:44
เว็บบล็อกเวอร์ชัน-2-1-ทำ-automated-deployment-กับ-docker-swarm-5df86c3ddc6cd8e69b1c8115
{
"production": {
"nginx:1.17-alpine": {
"service": "<stack_name>_nginx"
}
}
}
@nomkhonwaan
nomkhonwaan / wait-all-workers-with-waitgroup.go
Last active December 12, 2019 14:19
การทำ-worker-pool-ใน-go-5df184b36f448bf43c7edbfb
package main
import (
"fmt"
"sync"
"time"
)
func worker(id int, jobs <-chan int, results chan<- int, wg *sync.WaitGroup) {
for j := range jobs {
@nomkhonwaan
nomkhonwaan / app.component.ts
Last active November 27, 2019 14:40
เว็บบล็อกเวอร์ชัน 2.1 - วิธีแสดงผล Gist ใน Angular เทมเพลต
import { DOCUMENT } from '@angular/common';
import {
AfterViewInit,
Component,
ElementRef,
OnInit,
Renderer2,
ViewChild,
Inject,
} from '@angular/core';
@nomkhonwaan
nomkhonwaan / bufferred-channel-which-uses-only-3-slots.go
Last active November 24, 2019 22:39
Channel กับการสื่อสารระหว่าง Goroutines ใน Go
package main
import (
"fmt"
)
func main() {
intChan := make(chan int, 10)
intChan <- 1
@nomkhonwaan
nomkhonwaan / serve.go
Created October 27, 2019 14:00
A simple alternative Node.js serve command
package main
import (
"fmt"
"io"
"log"
"net"
"net/http"
"net/http/httptest"
"os"
@nomkhonwaan
nomkhonwaan / base64.go
Created May 23, 2019 06:03
A base64 decoding and encoding written in Go programming language
package main
import (
"bufio"
"encoding/base64"
"flag"
"io"
"log"
"os"
"strings"
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;

+----------+ +----------+ +----------+ +----------+ | HAProxy0 | | HAProxy1 | | HAProxy2 | ... | HAProxyN | +----------+ +----------+ +----------+ +----------+ | | | | | -----------+-------------+----------------+ v +---------------+ | Swarm Manager | +---------------+ |

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import { AppContainer } from 'react-hot-loader';
if (module.hot) {
module.hot.accept('./App', () => {
render(require('./App').default);
const assets = {
scripts: [
{
src: `${paths.publicUrl}static/js/bundle.js`
}
],
styles: []
};
if (process.env.NODE_ENV === 'production') {