Skip to content

Instantly share code, notes, and snippets.

View tpai's full-sized avatar
🌴
On vacation in Spain

Tony Pai tpai

🌴
On vacation in Spain
View GitHub Profile
@tpai
tpai / addArecord.sh
Last active December 10, 2018 05:08
AWS cheatsheet
HOST_ZONE_ID=
ACTION=
DNS_NAME=
# Add A record for s3 website hosting using custom domain
# Ref: http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html
aws route53 change-resource-record-sets --hosted-zone-id $HOST_ZONE_ID --change-batch "{
\"Changes\": [{
\"Action\": \"$ACTION\",
\"ResourceRecordSet\": {
@tpai
tpai / multi-trackers.md
Created August 22, 2017 08:29
Trackers related

Working with multiple trackers

GA

ga('create', 'UA-XXXXX-Y', 'auto');
ga('create', 'UA-XXXXX-Z', 'auto', 'clientTracker');
@tpai
tpai / _jwt.md
Last active November 13, 2017 04:18
Where to store JWT token, Cookies or HTML5 WebStorage?

Where to store JWT token, cookies or HTML5 WebStorage?

Before reading this article I have no idea about JWT authetication and think there's no difference bewteen them, after that I was wrong, really needs to pay more attention on security issue.

Cookies

  • HttpOnly flag: make sure cookies not be manipulated by javascript (immune to XSS)
  • Secure flag: guarantee the cookies is only sent over HTTPS
  • Prevent CSRF: check Referer and Origin from API
@tpai
tpai / live_stream.md
Created July 13, 2017 10:53
live stream related collection

音視頻技術參考

https://github.com/gwuhaolin/blog/issues/5
https://read01.com/zD2OdO.html
https://github.com/ossrs/srs
https://imququ.com/post/html5-live-player-1.html
http://blog.ucloud.cn/?p=694
@tpai
tpai / jsbin.gabugay.js
Last active July 11, 2017 04:13
URL String Replacement// source http://jsbin.com/gabugay
'use strict';
function resize(str, size) {
if (typeof size === 'undefined') return str;
return str.replace(/(https?):\/\/picture-original.cdn.com\/([^.]*).(jpe?g|png|gif)/ig, function (match, protocol, key, ext) {
return protocol + '://picture-thumb.cdn.com/' + key + '-' + size + '.' + ext;
});
}
console.assert(resize('https://picture-original.cdn.com/page-localhost-2017710.jpg', 300) === 'https://picture-thumb.cdn.com/page-localhost-2017710-300.jpg', { msg: 'test1 failed' });
@tpai
tpai / predicting_test.md
Last active July 20, 2017 06:33
模擬試題

模擬試題

重點:針對履歷客製化試題、函式庫工具原理解析。

前端函式庫

React.js

原理

@tpai
tpai / index.html
Created May 10, 2017 13:44
Center middle image and maintain aspect ratio // source http://jsbin.com/yefeju
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Center middle image and maintain aspect ratio</title>
<style id="jsbin-css">
html, body {
height: 100%;
}
@tpai
tpai / httpie.md
Last active May 26, 2017 09:26
HTTP

HTTPie

Usage

http [options] [method] [url] [bodies] [headers]

Options

@tpai
tpai / auto-scaling.md
Last active February 24, 2021 14:38
cheatsheet for aws ecs

Auto Scaling Launch Config

  • Amazon ECS Optimized AMI: ami-b4ae1dd7
  • Instance Type: t2.small

Config Details

  • Name: [CONFIG_NAME]
  • IAM role: fever_ecs
  • User data: As text
@tpai
tpai / gcommit.md
Last active August 16, 2017 02:33
Commit changes with conventions

Required Modules

package.json

{
  "devDependencies": {
    "commitizen": "^2.8.6",
    "cz-conventional-changelog": "^1.2.0",
 "ghooks": "^1.3.2",