This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.digitalocean.com/community/questions/how-to-change-swap-size-on-ubuntu-14-04 | |
Just follow these steps: | |
Make all swap off | |
sudo swapoff -a | |
Resize the swapfile | |
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getClosestValues = function(a, x) { | |
var lo = -1, hi = a.length; | |
while (hi - lo > 1) { | |
var mid = Math.round((lo + hi)/2); | |
if (a[mid] <= x) { | |
lo = mid; | |
} else { | |
hi = mid; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config valid only for Capistrano 3.1 | |
lock '3.1.0' | |
set :application, "" # EDIT your app name | |
set :scm, :git | |
set :repo_url, "" # EDIT your git repository | |
set :keep_releases, 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 跳到特定的檔案 | |
Ctrl + P | |
可輸入 <檔案名稱>:<行號> 來快速跳躍 | |
# 跳到特定行 | |
Ctrl + G | |
# 轉換 Emmet | |
Ctrl + E |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [0-9].json | |
\d+[.][j][s][o][n] | |
# the end of every line. | |
(?>\x0D\x0A?|[\x0A-\x0C\x85\x{2028}\x{2029}]) | |
# begin of lines. | |
^[a-zA-z0-9!@#$")(*&!+_-] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 匯入 | |
mysql -u <user> -p <password> <database> < <sql_filename> | |
# 匯出 | |
mysqldump -u <user> -p <password> <database> > <sql_filename> | |
# 新增使用者 | |
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; | |
# 加上權限 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/23464157/cant-start-or-stop-php-fpm-on-ubuntu | |
/usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ctrl+Alt+V (Refactor | Extract Variable) | |
Ctrl+D in the editor duplicates the selected block or the current line when no block is selected. | |
If the cursor is between the parentheses of a method call, pressing Ctrl+P brings up a list of valid parameters. | |
Ctrl+Shift+Backspace (Navigate | Last Edit Location) | |
Use Ctrl+Shift+F7 (Edit | Find | Highlight Usages in File) to quickly highlight usages of some variable in the current file. | |
Use F3 and Shift+F3 keys to navigate through highlighted usages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 停止所有 container 並且 remove | |
docker stop $(docker ps -a -q) | |
docker rm $(docker ps -a -q) | |
# 用 image 執行 container | |
sudo docker run -idt <image> | |
-d flag which tells Docker to run the container in the background. | |
# 執行 container 並且印出 env | |
docker run --rm --name <name> <image> env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.Zhengzhou.aggregate([ | |
{ $match: { ModifiedTime: { $gt: ISODate("2015-07-01T00:00:00.000Z"), $lt: ISODate("2015-07-02T00:00:00.000Z")}, DeviceResponseTime: { $ne : 0 } } }, | |
{ | |
$project: { | |
date : { $dateToString : { format: "%Y-%m-%d", date: "$ModifiedTime" }}, | |
DeviceResponseTime: 1 | |
} | |
}, | |
{ | |
$group: { |