Skip to content

Instantly share code, notes, and snippets.

View lanrion's full-sized avatar
🎯
Focusing

lanrion lanrion

🎯
Focusing
  • guǎng zhōu
View GitHub Profile
@lanrion
lanrion / gist:f0933d113f3f7d4854d5
Last active August 29, 2015 14:04
配置默认不安装 ri与rdoc文件 disable-install-ruby-ri-rdoc

bundle 在安装gem时,在默认的情况下,是会下载安装gem附带的ri与rdoc,gem安装的越多,那么rdoc就会占用了我们大量的硬盘空间;配置如下:

vim ~/.gemrc
# 添加如下即可
gem: --no-ri --no-rdoc

赞!

@lanrion
lanrion / mysqldump-export-or-import-db
Last active August 29, 2015 14:03
mysqldump 导出导入数据库
导出:
mysqldump -uroot db_name > tmp/db_name
导入:
进入mysql数据库控制台,
如mysql -u root -p
mysql>use 数据库;
然后使用source命令,后面参数为脚本文件(如这里用到的.sql)
mysql>source SQL的文件目录;
@lanrion
lanrion / gist:a611e5b41f8e7b83c24d
Created June 25, 2014 06:48
generating ssh keys
@lanrion
lanrion / gist:3bbee094fd586b64d31e
Created June 24, 2014 08:42
显示进程名,对应的端口号
netstat -nltp
@lanrion
lanrion / gist:c09683589bd87b056fab
Last active August 29, 2015 14:02
nokogiri mac installing Guide

貌似最新版本的依赖安包包,还是挺多的。

http://nokogiri.org/tutorials/installing_nokogiri.html

If this is a concern for you and you want to use the system library instead, abort this installation process and reinstall nokogiri as follows:

gem install nokogiri -- --use-system-libraries
@lanrion
lanrion / gist:6fd390d6e1d216eef2c3
Created June 22, 2014 05:11
bin/rails:6: warning: already initialized constant APP_PATH
lanrion dummy (master) $ 4rs 
bin/rails:6: warning: already initialized constant APP_PATH
/Users/lanrion/Projects/mygems/retrench/test/dummy/bin/rails:6: warning: previous definition of APP_PATH was here
Error: Command '-p' not recognized
Usage: rails COMMAND [ARGS]

The most common rails commands are:
 generate    Generate new code (short-cut alias: "g")
 console     Start the Rails console (short-cut alias: "c")
https://github.com/harrisj/qrencoder
依赖包
for ubuntu
sudo apt-get install qrencode libqrencode-dev
gem install qrencoder
for mac
brew install qrencode
gem install qrencoder -- -- with-qrencoder-include=/usr/local/Cellar/qrencode/3.4.3_1/include --with-qrencoder-lib=/usr/local/Cellar/qrencode/3.4.3_1/lib
@lanrion
lanrion / gist:a525373b5e040c9a3f86
Created June 10, 2014 06:08
导出id,name json格式

有一个简单的需求:

数据库有一个表User(id, name),需要导出:

 {
   id1 => name1,
   id2 => name2
 }
http://git-scm.com/book/en/Git-Basics-Tagging
git tag -a v1.5 -m 'my version 1.5'
git push origin v1.5
@lanrion
lanrion / gist:26f38989fe842c560755
Last active August 29, 2015 14:01
sed 替换指定目录文件下的文件内容

I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site

find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;