Skip to content

Instantly share code, notes, and snippets.

View roylee0704's full-sized avatar
🧘‍♂️

roylee0704

🧘‍♂️
  • Bangkok, Thailand
View GitHub Profile
@roylee0704
roylee0704 / dockergrep.sh
Created December 9, 2016 08:24
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
@roylee0704
roylee0704 / 📊 Weekly development breakdown
Last active April 13, 2024 00:13
📊 Weekly development breakdown
TypeScript 7 hrs 7 mins ███████████████░░░░░░ 71.6%
SQL 1 hr 8 mins ██▍░░░░░░░░░░░░░░░░░░ 11.4%
Other 30 mins █░░░░░░░░░░░░░░░░░░░░ 5.1%
JSON 28 mins ▉░░░░░░░░░░░░░░░░░░░░ 4.8%
Python 26 mins ▉░░░░░░░░░░░░░░░░░░░░ 4.5%
@roylee0704
roylee0704 / Dockerrun.aws.json
Created September 2, 2016 11:37
Dockerrun.aws.json Syntax
{
"containerDefinitions": [
{
"command": [ "string" ],
"cpu": number,
"disableNetworking": boolean,
"dnsSearchDomains": [ "string" ],
"dnsServers": [ "string" ],
"dockerLabels": {
"string" : "string"
@roylee0704
roylee0704 / html2pdf.js
Created July 5, 2020 14:31 — forked from antfu/html2pdf.js
HTML to PDF
import puppeteer from 'puppeteer'
import fs from 'fs'
async function buildPDF(htmlString) {
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage();
await page.setContent(htmlString, { waitUntil: 'networkidle0' })
const pdf = await page.pdf({
format: 'A4',
displayHeaderFooter: false,
@roylee0704
roylee0704 / prehash_tuple.py
Created May 15, 2016 11:21
python prehash implementation of tuple type. (simplified version)
def hash(tuple):
mult = 1000003
x = 0x345678
for index, item in enumerate(tuple):
x = ((x ^ hash(item)) * mult) & (1<<32)
mult += (82520 + (len(tuple)-index)*2)
return x + 97531
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@roylee0704
roylee0704 / docker-compose.yml
Last active September 23, 2020 04:56
1. Setup Terraform Backends
version: "3.8"
services:
# service name to run in docker-compose command
terraform:
image: hashicorp/terraform:0.13.3
# map all files under host dir './aws' to container dir '/infra'
volumes:
- ./aws:/infra
@roylee0704
roylee0704 / machine.js
Last active July 30, 2020 10:48
Generated by XState Viz: https://xstate.js.org/viz
const daikinMachine = Machine({
id: 'daikin',
initial: 'AwaitingPayment',
context: {
retries: 0
},
states: {
AwaitingPayment: {
on : {
RECEIVE_PAYMENT: 'Open'
error 7/22/20, 05:04 - [IPay88Api] {
"exchangeId": "cc002e71-8501-468b-8992-90f772dd975b",
"root": {
"Envelope": {
"Body": {
"Fault": {
"faultcode": "a:DeserializationFailed",
"faultstring": {
"attributes": {
"xml:lang": "en-US"
@roylee0704
roylee0704 / shipping-rate.dto.ts
Created March 29, 2020 05:09
shipping rate result
import { Field, ObjectType } from 'type-graphql';
@ObjectType('ShippingRate', {
description:
'A shipping rate to be applied to an order.',
})
export class ShippingRateDto {
@Field({
description: 'The name of the carrier, which customers see at checkout',