Skip to content

Instantly share code, notes, and snippets.

View tonkla's full-sized avatar
🏠
Working from home

Surakarn Samkaew tonkla

🏠
Working from home
View GitHub Profile
@tonkla
tonkla / tfma.mq5
Created September 7, 2023 08:53
A Moving Average (MA) -based Expert Advisors (EA) for MetaTrader 5
#property copyright "Stradeji"
#property link "https://www.stradeji.com"
#property version "1.0"
#property strict
#include <Trade\Trade.mqh>
CTrade ctrade;
ulong ACCOUNT_ID = 0;
@tonkla
tonkla / deno-outdated.ts
Created October 19, 2022 10:09
deno outdated : find outdated packages (inspired by yarn/pnpm oudated)
const deps = await Deno.readTextFile('./src/deps.ts')
const regexPkg = /(https:\/\/.+)@([^\/]+)/
let isFinding = true
Deno.stdout.write(new TextEncoder().encode('.'))
const id = setInterval(() => {
if (isFinding) Deno.stdout.write(new TextEncoder().encode('.'))
}, 250)
@tonkla
tonkla / settings.json
Created May 4, 2021 11:55
VSCode Settings
{
"editor.fontFamily": "'JetBrains Mono', 'IBM Plex Mono', Menlo, Monaco, 'Courier New', monospace",
"editor.fontSize": 15,
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.minimap.enabled": false,
"explorer.confirmDelete": false,
"explorer.compactFolders": false,
"extensions.ignoreRecommendations": true,
"files.trimTrailingWhitespace": true,
@tonkla
tonkla / gha-workflow.yml
Last active May 4, 2021 11:57
GitHub Actions Workflow + Google Cloud Platform
name: web-develop
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- "web/**/*"
env:
@tonkla
tonkla / prettier
Created July 28, 2020 12:12
Prettier CLI
prettier --print-width 100 --single-quote --no-semi --trailing-comma es5 --tab-width 2 --use-tabs false --write "**/*.{js,ts}"
@tonkla
tonkla / 1-fake-async.js
Last active February 2, 2020 06:28
How Asynchronous JavaScript Works?
function print(func, wait) {
console.log(`${func}: ${wait}`)
setTimeout(() => { console.log(`${func}: ${wait}, waited`) }, wait)
}
async function func1() {
await print(1, 1000)
await print(1, 1500)
await print(1, 2000)
}
@tonkla
tonkla / Dockerfile
Last active July 10, 2020 06:45
Node.js + MongoDB + Docker
FROM node:12-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . ./
RUN npm run build
@tonkla
tonkla / store.js
Last active July 20, 2019 05:53
React app's global state management with the Context API and Hooks
import { createContext, useContext, useCallback, useState } from 'react'
const AppContext = createContext({})
const useAppContext = () => {
return useContext(AppContext)
}
const useAppState = () => {
const initialState = { count: 0 }
@tonkla
tonkla / upload.js
Last active August 28, 2023 12:35
Parsing 'multipart/form-data' Excel (.xlsx) with Busboy on AWS Lambda (Node.js)
'use strict'
const Busboy = require('busboy')
const XLSX = require('xlsx')
function parseMultipartFormData(input, contentType) {
return new Promise((resolve, reject) => {
const buffers = []
const busboy = new Busboy({
headers: { 'content-type': contentType },
@tonkla
tonkla / convertObjectKeysCase.js
Last active March 5, 2018 08:56
ES6 module to recursively convert between `snake_case` and `camelCase` keys in an object using `lodash`.
// Credit: https://gist.github.com/felixjung/a00879103892af44524f
// Credit: https://gist.github.com/emcmanus/eb735299788c820b4eb85c38f02598e4
import {
camelCase,
cloneDeep,
isArray,
isPlainObject,
map,
mapKeys,