Skip to content

Instantly share code, notes, and snippets.

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
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;
}
}
@kurorido
kurorido / capistrano-laravel-deploy.rb
Created October 5, 2015 07:43 — forked from arhea/capistrano-laravel-deploy.rb
Capistrano 3 deploy script for Laravel 4.
# 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
@kurorido
kurorido / gist:52e3e0cd95aaeb2a52d9
Created August 18, 2015 15:08
Sublime shortcuts cheat sheet
# 跳到特定的檔案
Ctrl + P
可輸入 <檔案名稱>:<行號> 來快速跳躍
# 跳到特定行
Ctrl + G
# 轉換 Emmet
Ctrl + E
@kurorido
kurorido / gist:5846b20920625916cc95
Created August 17, 2015 13:45
Regular Expression Cheat Sheet
# [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!@#$")(*&!+_-]
# 匯入
mysql -u <user> -p <password> <database> < <sql_filename>
# 匯出
mysqldump -u <user> -p <password> <database> > <sql_filename>
# 新增使用者
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
# 加上權限
@kurorido
kurorido / FPM
Created July 23, 2015 16:37
FPM Trobuleshot
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
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.
@kurorido
kurorido / docker_cheat_sheet
Last active October 3, 2015 11:22
docker cheat sheet
# 停止所有 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
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: {