Skip to content

Instantly share code, notes, and snippets.

View trylovetom's full-sized avatar
♥️
Falling in Love with JavaScript~

CHANG, TZU-YEN trylovetom

♥️
Falling in Love with JavaScript~
View GitHub Profile
@trylovetom
trylovetom / machine.js
Last active September 10, 2019 11:09
Generated by XState Viz: https://xstate.js.org/viz
const PassengerMachine = Machine({
id: '叫車服務(乘客端)',
initial: '地圖畫面',
states: {
'地圖畫面': {
on: {
'確認上下車地點': '訂單資訊畫面(金額、付款方式、特殊需求)'
}
},
'訂單資訊畫面(金額、付款方式、特殊需求)': {
@trylovetom
trylovetom / machine.js
Last active September 5, 2019 10:11
Generated by XState Viz: https://xstate.js.org/viz
const DriverMachine = Machine({
id: '叫車服務(司機端)',
initial: '登入頁面',
states: {
'登入頁面': {
on: {
'登入流程': '準備上線頁面'
}
},
'準備上線頁面': {
@trylovetom
trylovetom / parseHTMLTableToJSON.js
Last active November 26, 2023 05:17
Parse HTML Table To JSON With Cheerio.
const text = `<table cellspacing=1 bordercolordark=#666666 cellpadding=0 width=100% align=center bgcolor=#D9D9D9 bordercolorlight=#ffffff border=0><tr class='chinese blue_t2'><td height=20>球队</td><td>球员</td><td>位置</td><td>原因</td><td>日期</td><td>备注</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>波特兰拓荒者</td><td> 纽基</td><td>中锋</td><td>脚部</td><td>2019/03/26</td><td>赛季报销</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>波特兰拓荒者</td><td> 麦高林</td><td>后卫</td><td>膝部</td><td>2019/03/17</td><td>预计缺阵</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> 赞达拿赫捷臣</td><td>前锋</td><td>膝部</td><td>2019/01/26</td><td>赛季报销</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> 奥图波达</td><td>前锋</td><td>肩部</td><td>2019/03/26</td><td>预计缺阵</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> 云度卡达</td><td>中锋</td><td>拇指</td><td>2019/01/16</td><td>预计缺阵</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> D.华伦天尼</td><td>前锋</td><td>足踝</td><td>2018/10/19</td><td
@trylovetom
trylovetom / Schedule.js
Last active January 19, 2019 04:12
The Job Schedule Base On setInterval.
import {
job as homeJob,
time as homeTime,
enable as homeEnable,
runFirstTime as homeRunFirstTime
} from './home'
/**
* 建立 Schedule
* @version 1.1.0
{
"message": "Access to Identity \'...\' is forbidden.',
"code:: "NotAuthorizedException",
'...': '...',
}
const AWS = require('aws-sdk')
AWS.config.region = 'us-east-1'
// Functions
const getCredentials = IdentityId => {
const cognito = new AWS.CognitoIdentity({ apiVersion: '2014-06-30' })
const params = {
IdentityId
}
@trylovetom
trylovetom / CognitoAuthLoginLambda.js
Created March 6, 2018 04:58
CognitoAuthLoginLambda
console.log('Loading Function')
// Dependencies
const AWS = require('aws-sdk')
// Functions
const getToken = userId => {
const cognito = new AWS.CognitoIdentity({ apiVersion: '2014-06-30' })
const params = {
IdentityPoolId: '...',
@trylovetom
trylovetom / better-nodejs-require-paths.md
Created August 8, 2017 09:20 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@trylovetom
trylovetom / main.swift
Created June 3, 2017 04:21
sync url session data task
//
// main.swift
// test
//
// Created by 張子晏 on 2017/6/3.
// Copyright © 2017年 張子晏. All rights reserved.
//
import Foundation
@trylovetom
trylovetom / for Birkhoff Lee
Created July 29, 2016 18:12
for Birkhoff Lee
//
// ViewController.swift
// test
//
// Created by 張子晏 on 2016/7/30.
// Copyright © 2016年 張子晏. All rights reserved.
//
import UIKit
import SwiftHTTP