Skip to content

Instantly share code, notes, and snippets.

View loveky's full-sized avatar
🍺
cheers

loveky loveky

🍺
cheers
View GitHub Profile
@loveky
loveky / Sinatra中request.path_info和request.script_name的区别.md
Last active July 9, 2020 07:35
Sinatra中request.path_info和request.script_name的区别

最近在看Sinatra 1.3.5的源码。在Sinatra::Helpers模块中看到一个名为uri的方法,用来将一个相对路径转换为绝对路径。在该函数的代码中看到分别针对request.script_name和request.path_info进行了处理。但是并不清楚这两个参数的区别,于是做了一些reseach。

二者在RFC3875中有如下定义:

4.1.13. SCRIPT_NAME

The SCRIPT_NAME variable MUST be set to a URI path (not URL-encoded) which could identify the CGI script (rather than the script's output). The syntax is the same as for PATH_INFO (section 4.1.5) >

@loveky
loveky / Install Ruby mysql2 gem on Windows 7.md
Last active December 15, 2015 11:29
Install Ruby mysql2 gem on Windows 7
  1. Download and install Ruby from RubyInstaller
  2. Download Development Kit and follow the installation instructions
  3. Download Mysql Connector/C and extract it into a path without spaces. For example c:\mysql-connector
  4. Run gem install mysql2 -- --with-mysql-include=c:\mysql-connector\include --with-mysql-lib=c:\mysql-connector\lib to install the gem.
  5. Copy c:\mysql-connector\lib\libmysql.dll to your Ruby bin path.
@loveky
loveky / 常用Gem列表.md
Last active December 15, 2015 12:29
常用Gem列表
@loveky
loveky / setup.sh
Last active December 22, 2015 02:28
快速部署Rails部署环境 Nginx + PostgreSQL + Git + RVM + 1.9.3
deployer_username='deployer'
deploy_ssh_pubkey=''
db_name='bisaikong'
db_username='bisaikong'
db_password='bisaikong'
# 安装软件包
export DEBIAN_FRONTEND=noninteractive
apt-get -y update
apt-get -y install curl git-core python-software-properties
@loveky
loveky / gist:6418389
Created September 3, 2013 00:13
PostgreSQL常用命令
创建用户
CREATE USER name WITH PASSWORD pass;
创建数据库
CREATE DATABASE name OWNER username;
删除数据库
DROP DATABASE dbname;

查看当前系统中占用物理内存最多的进程

watch -n 10 "ps -eo pid,user,%cpu,%mem,rss,vsz,sz,comm,args | sort -k5 -n -r |head -15"

查看磁盘IO

iostat -d -x -h xvda 2
@loveky
loveky / gist:7426948
Created November 12, 2013 07:27
Apache disable cache on specific kind of resource
<FilesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</FilesMatch>
@loveky
loveky / git-rerere.md
Last active December 29, 2015 09:59
Reuse recorded resolution of conflicted merges 重用已记录的merge冲突解决方案

rerere 是啥的缩写?

rerere = reuse recorded resolution

rerere是干啥用的?

它会让Git记住你是如何解决某个文件的两个版本之间的conflict,这样在下次Git遇到同样的文件在相同的两个版本间发生冲突时,可以自动帮你使用相同的方法解决冲突。

如何启用rerere?

git config --global rerere.enabled true

或是

/**
* Version: 1.0 Alpha-1
* Build Date: 13-Nov-2007
* Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved.
* License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
* Website: http://www.datejs.com/ or http://www.coolite.com/datejs/
*/
Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",