Skip to content

Instantly share code, notes, and snippets.

View liwh's full-sized avatar
🎯
Focusing

robie lee liwh

🎯
Focusing
View GitHub Profile
@liwh
liwh / gist:706196
Created November 19, 2010 06:40
关闭memcache缓存,并重启
sudo kill -9 `ps -A|grep memca|awk '{print $1}'` && memcached -m 20 -d
@liwh
liwh / gist:706044
Created November 19, 2010 02:20
输入历史使用最多的10条命令
history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn | head
liweihui@desktop:~$ history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn | head
85 cd
77 git
74 vim
68 ls
22 rm
20 mv
14 ruby
@liwh
liwh / gist:704775
Created November 18, 2010 08:29
设置模块常量
module A
A.const_set("NUM",2)
end
A::NUM
@liwh
liwh / gist:703047
Created November 17, 2010 06:02
ruby写文件
#1
file= File.new('filename','w')
file.puts 'aa'
file.close
#2
File.open('filename','w') do |file|
file.puts 'aa'
end
@liwh
liwh / gist:701422
Created November 16, 2010 04:32
textmate快捷键
自动补全 : esc
查找项目文件:command+t
查找文件内符号:shift+command+t
跳到某行:command+l
选择:shift+方向键
向后缩进:option+tab
向前缩进:shift+option+tab
reformat 所选:option+command+[
大写所选:control+u
小写所选:control+shift+u
sudo port install mongodb
Password:
---> Computing dependencies for mongodb
---> Dependencies to be installed: boost boost-jam libpcap pcre scons spidermonkey nspr
---> Fetching boost-jam
---> Attempting to fetch boost-jam-3.1.18.tgz from http://cdnetworks-kr-2.dl.sourceforge.net/boost
---> Verifying checksum(s) for boost-jam
---> Extracting boost-jam
---> Applying patches to boost-jam
---> Configuring boost-jam
#测试数据库连接状态:
My_Model.connection.current_database
后台启动mongodb: ./mongod --fork --logpath /var/log/mongodb.log --logappend
关闭mongodb: $ ./mongo
> db.shutdownServer()
今天,准备执行rake db:seed时,发现出现:no such file to load --openssl,
在安装了sudo apt-get install openssl libopenssl-ruby1.9 都没有效果后,此时,从http://openssl.org/ 上下载OpenSSL 0.9.8o 的tar包,自己进行编译安装。步骤如下。
1. tar -xvf openssl*
2. cd openssl*
3. sudo make && sudo make install
4.进入ruby源文件目录,找到/ext/openssl 的目录,进入此目录
@liwh
liwh / gist:652752
Created October 29, 2010 02:10
快速添加到每一个文件的方法
find app -iname '*.rb' | xargs sed -i '1 i\# encoding: utf-8'
@liwh
liwh / gist:633930
Created October 19, 2010 09:43
factory_girl error
Factory.define :valid_thing, :class => Thing do |t|
  t.name 'Some valid thing'
  t.user { Factory(:valid_user) }
end
Wrapping the call in {} causes Factory Girl to not evaluate the code inside of the 
braces until the :valid_thing factory is created. This will force it to wait until the