Skip to content

Instantly share code, notes, and snippets.

View liwh's full-sized avatar
🎯
Focusing

robie lee liwh

🎯
Focusing
View GitHub Profile
#测试数据库连接状态:
My_Model.connection.current_database
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
@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
@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:704775
Created November 18, 2010 08:29
设置模块常量
module A
A.const_set("NUM",2)
end
A::NUM
@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:706196
Created November 19, 2010 06:40
关闭memcache缓存,并重启
sudo kill -9 `ps -A|grep memca|awk '{print $1}'` && memcached -m 20 -d

由于,觉得用textmate还是不大习惯,所以,还是决定把macvim安装上,首先,在安装之前,我们现查看一下vim包的variants。


ApplematoMacBook-Pro:~ Apple$ port variants vim
vim has the variants:
athena: Build GUI version using Athena widgets

  • conflicts with gtk1 gtk2 motif
  • requires x11
    big: Build big feature set
  • conflicts with small tiny
    cscope: Enable source code browsing with cscope
@liwh
liwh / gist:711422
Created November 23, 2010 07:48
定义抽象类,实现代码重构
# app/models/abstract_server.rb
class AbstractServer < ActiveRecord::Base
self.abstract_class = true
validates_presence_of :name, :address, :username, :password, :encoding
validates_length_of :name, :maximum => 20, :allow_blank => true
validates_length_of :address, :maximum => 20, :allow_blank => true
validates_length_of :username, :password, :maximum => 20, :allow_blank => true
validates_length_of :encoding, :maximum => 10, :allow_blank => true
@liwh
liwh / gist:721701
Created November 30, 2010 13:49
intall the shopqi project on mac os x
  • 首先安装rvm,这个和在linux上安装是一致的,安装完成之后,将 if [[ -s /Users/Apple/.rvm/scripts/rvm ]] ; then source /Users/Apple/.rvm/scripts/rvm ; fi 放在~/.bash_profile中。
  • rvm 1.9.2 —default
  • 参见前面安装rails 3
  • bundle install (在项目目录下执行,注意将Gemfile文件里的rb-inotify这个gem注释调,因为它还不支持os x平台)
  • 安装homebrew,具体步骤见:安装homebrew ,homebrew安装东西比macport要快很多。
  • sudo brew install ImageMagick
  • sudo brew install mongodb (具体步骤见:安装mongodb )