Skip to content

Instantly share code, notes, and snippets.

View ruyaoyao's full-sized avatar
❣️

Shiny ruyaoyao

❣️
View GitHub Profile
@ruyaoyao
ruyaoyao / queue.js
Last active August 17, 2016 04:09 — forked from s25g5d4/queue.js
/*
Auther: s25g5d4 @ https://github.com/s25g5d4
Usage:
用法很簡單,只要 var q = new Queue(limit, timeout, delay)
第一個參數是這個 queue 最大同時併發量
第二個參數是任務執行的 timeout
當某個任務執行超過 timeout 時間後會自動被 reject
第三個參數是任務完成後強制延後下一個任務執行的時間
@ruyaoyao
ruyaoyao / gist:b9904e9bf5689b43b56a1d1ed05032b6
Created August 16, 2016 03:07 — forked from TimPerry/gist:522234ee4de8534496ff
loopback webpack react native
var LoopbackBootPlugin = require('loopback-webpack-plugin');
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var config = {
debug: true,
devtool: 'source-map',
@ruyaoyao
ruyaoyao / openshift-node-force-domain.js
Created July 22, 2016 08:53 — forked from rahuljiresal/openshift-node-force-domain.js
This is a middleware for Connect and Express that redirects any requests to a default domain. Based on https://github.com/goloroden/node-force-domain, modified to work on Openshift platform.
/*
Openshift uses haproxy (haproxy.org) as a front proxy to route request to instances of the app.
This proxy does the job of unwrapping https and sets the 'x-forwarded-proto' header.
Because of this, the Node.JS app never sees the actual protocol of the request, unless it checks the presence of this header.
I modified the code written by goloroden (https://github.com/goloroden/node-force-domain) to check this header instead of ports.
This gist does exactly what his code does, except checks for actual protocol instead of relying on the port for the protocol.
*/
var rewrite = function (route, options) {
options = _.defaults({
# Assuming that you have followed all the instructions from https://github.com/rumblelabs/asset_sync
# Put this in your deployment script
# Choose any environment here the important part is that your environment is using the same bucket for all environments
# than you only need to precompile assets once
RAILS_ENV=staging bundle exec rake assets:precompile
# You need to set git credentials otherwise it won't be able to commit
git config --global user.email "[email protected]"
git config --global user.name "Codeship Server"
# Add your manifest file so that rails can find digested version of files
@ruyaoyao
ruyaoyao / xss_notes.md
Created July 14, 2016 15:27 — forked from jaceju/xss_notes.md
XSS 上課筆記

XSS 上課筆記

OWASP

  1. Injection
  2. Broken Authentication and Session Management
  3. XSS

Devcore

@ruyaoyao
ruyaoyao / Front-end-Developer-Interview-Questions-TC.md
Created July 14, 2016 15:26 — forked from jaceju/Front-end-Developer-Interview-Questions-TC.md
Front-end-Developer-Interview-Questions - 前端工程師面試問題集(繁體中文版)

前端工程師面試問題集

@版本 2.0.0

譯注:此翻譯版,主要給不能流利的讀英文的人看,相關專有名詞還是保留原文。翻譯不好地方請協助pull request.

此repository包含了一些前端開發的面試問題,來審查一個有潛力的面試者。這並不是建議你對同一個面試者問上所有的問 (那會花費好幾小時)。從列表中挑幾個題目,應該就夠幫助你審查面試者是否擁有你需要的技能。

Rebecca MurpheyBaseline For Front-End Developers 也是一篇很棒且值得讀的文章在你開始面試之前。

@ruyaoyao
ruyaoyao / dep.js
Created July 14, 2016 15:25 — forked from jaceju/dep.js
[Node.js] 如何用 mockery.js + sinon.js 來驗證
'use strict';
class DepClass {
constructor (arg) {
console.log(arg);
}
say (word) {
console.log(word);
}
@ruyaoyao
ruyaoyao / why-curry-helps.md
Last active May 18, 2016 09:19 — forked from jcouyang/why-curry-helps.md
为什么要柯里化(why-curry-helps)slide http://git.io/why-curry-helps 📈

还记得 Haskell Curry吗,

多巧啊, 人家姓 Curry 名 Haskell, 难怪 Haskell 语言会自动柯里化, 呵呵. 但是不奇怪吗, 为什么要柯里化呢. 为什么如此重要导致 Haskell 会默认自动柯里化所有函数, 不就是返回一个部分配置好的函数吗.

我们来看一个 Haskell 的代码.

max 3 4
(max 3) 4
@ruyaoyao
ruyaoyao / js-get-fn-name.js
Created April 3, 2016 05:13 — forked from dfkaye/js-get-fn-name.js
get a javascript function name
function getFnName(fn) {
var f = typeof fn == 'function';
var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
return (!f && 'not a function') || (s && s[1] || 'anonymous');
}
console.log(getFnName(String)); // 'String'
console.log(getFnName(function test(){})); // 'test'
console.log(getFnName(function (){})); // 'anonymous'
@ruyaoyao
ruyaoyao / for-loops.js
Created April 1, 2016 07:39 — forked from juliocesar/for-loops.js
ES6 - for loops
// ES6 for loops
// =============
// Things in ES6 can be "iterable". Arrays are iterable by default.
var fruits = ['Apple', 'Banana', 'Grape'];
for (var fruit of fruits)
console.log('Fruit: ' + fruit);