Skip to content

Instantly share code, notes, and snippets.

## 掛載 rewrite module
sudo a2enmod rewrite
sudo service apache2 restart
修改 /etc/apache2/sites-available/default
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride FileInfo
Order allow,deny
mongo 進入 Command Line
use <dbname> 使用特定db
show collections 顯示所有collections
db.<collection>.find() 顯示 collections 下所有的 document
db.<collection>.drop() 刪除 collections
@kurorido
kurorido / .htaccess
Created April 28, 2015 13:48
htaccess cache
# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
# Expires Headers - 2678400s = 31 days
<ifmodule mod_expires.c>
@kurorido
kurorido / gist:b8a4f827d52c6b47c890
Last active August 29, 2015 14:22
一些網頁基礎使用
if( /Android|webOS|iPhone|iPod|iPad|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
window.location.href = "to mobile site url";
}
var basketModule = (function() {
var basket = [];
return {
addItem: function(values) {
basket.push(values);
},
getItemCount: function() {
return basket.length;
},
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: {
@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
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 / 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
# 匯入
mysql -u <user> -p <password> <database> < <sql_filename>
# 匯出
mysqldump -u <user> -p <password> <database> > <sql_filename>
# 新增使用者
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
# 加上權限