Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:
defp deps do
[
{:cowboy, "~> 1.0.0"},
{:plug, "~> 0.8.1"}
]
end| #!/bin/sh | |
| STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$") | |
| if [[ "$STAGED_FILES" = "" ]]; then | |
| exit 0 | |
| fi | |
| PASS=true |
| CODENAMES = { | |
| "\u0000": "NULL", | |
| "\u0001": "START OF HEADING", | |
| "\u0002": "TEXT, START OF", | |
| "\u0003": "TEXT, END OF", | |
| "\u0004": "TRANSMISSION, END OF", | |
| "\u0005": "ENQUIRY", | |
| "\u0006": "ACKNOWLEDGE", | |
| "\u0007": "BELL", | |
| "\u0008": "BACKSPACE", |
| // 检测浏览器的 User Agent 应该是非常简单的事情 | |
| // 微信在 Android 下的 User Agent | |
| mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352 | |
| // 微信在 iPhone 下的 User Agent | |
| mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0 | |
| // 通过javascript判断 | |
| // 很容易看出来,微信的 User Agent 都有‘micromessenger’字符串标示,我们判断是否含有这些字符串就OK了 | |
| function isWeixinBrowser(){ |
Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:
defp deps do
[
{:cowboy, "~> 1.0.0"},
{:plug, "~> 0.8.1"}
]
endMagic words:
psql -U postgresSome interesting flags (to see all, use -h or --help depending on your psql version):
-E: will describe the underlaying queries of the \ commands (cool for learning!)-l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)| #!/bin/bash | |
| target_branch="production" | |
| working_tree="PATH_TO_DEPLOY" | |
| while read oldrev newrev refname | |
| do | |
| branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
| if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then | |
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "[email protected]"
| // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
| // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
| // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
| // MIT license | |
| (function() { | |
| var lastTime = 0; | |
| var vendors = ['ms', 'moz', 'webkit', 'o']; |