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 / gog.coffee
Last active September 11, 2015 18:33
hubot script
module.exports = (robot) ->
robot.hear /gog [help|?]/i, (result) ->
result.send "gog [rank|new|bestselling_per_week],[number]"
robot.hear /gog (.*),(.*)/i, (result) ->
sort = result.match[1].trim()
num = result.match[2]
url = "http://www.gog.com/games/ajax/filtered?sort="+sort+"&limit=" + num
@tpai
tpai / fb.js
Last active April 27, 2016 05:47
SDK
var myId, myName
window.fbAsyncInit = function() {
FB.init({
appId: [YOUR_APP_ID],
channelUrl: "//" + window.location.hostname + "/channel.html",
xfbml: true
})
FB.getLoginStatus(function(response) {
@tpai
tpai / angular.markdown
Last active May 17, 2017 04:14
Learning memo

AngularJS

Directives

  • ng-app="[MODULE_NAME]" // init angular
  • ng-controller="[CONTROLLER_NAME] as [ALIAS]" // init controller
  • ng-show="[CONDITION]" // show expression if true
  • ng-hide="[CONDITION]" // hide expression if true
  • ng-repeat="[ALIAS] in [CONTROLLER_NAME].[PROPERTY_NAME]" // for element in elements
  • ng-src="{{[CONTROLLER_NAME].[ARRAY][0]}}" // when load image in array

IE8 Terminator

Hasta la vista, baby.

NPM Modules

{
  "dependencies": {
    "babel-core": "5.8.34",

Scrum

Scrum 敏捷開發學習心得

要點

  • 重視個人與互動
  • 產出可用的軟體
  • 與客戶合作非敵
  • 持續地回應變化
@tpai
tpai / moment.js
Last active May 16, 2016 08:56
JS 相關筆記
/* Range of date display by moment. */
// yesterday
startDate.add(-1, "days")
endDate.add(-1, "days")
// today
moment()
moment()

layout: true class: center, middle, inverse

Redux Unit Test

.footnote[tonypai present]

What should I do?

layout: false class: inverse

Preparation

@tpai
tpai / param.js
Last active January 7, 2016 02:09
$.param() => _.param()
var _ = require("lodash");
var param = function( a ) {
var s = [], add = function( key, value ) {
s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
};
for ( var prefix in a ) {
buildParams( prefix, a[prefix], add );
}
return s.join("&").replace(/%20/g, "+");
@tpai
tpai / articles.md
Last active September 6, 2017 07:27
nginx related note

前端優化

  • Server 設置:啟用 gzip 壓縮、靜態內容設置 max-age/expires 或使用 CDN、動態內容設置 cache control。(樣板參考)
  • 減少 HTTP Requests:善用 CSS Sprite 解決大量載入圖片的問題,盡量以水平排列圖片,相較於垂直排列圖片大小較小。
  • favicon.ico:存在且小於 1KB 加上較長的 expires。
  • 預載:頁面加載完成後隨即加載用於其他頁面的資源。

CORS

@tpai
tpai / build-docker-env.md
Last active April 28, 2017 08:34
My docker note for building private game server