8/05/2012
Setup L2TP/IPsec VPN server on Ubuntu
4/09/2012
Setup text mate environment with ruby on rails
set the following in order to get most of your textmate bundle work:
PATH -> paths with your git & mysql & ruby
DYLD_LIBRARY_PATH -> path of your mysql lib
ARCHFLAGS -> -arch x86_64
RUBYOPT -> rubygems
3/20/2012
set timezone on Ubuntu
you if you wanna change the default timezone
first select your timezone interactively by using 'tzselect', you may
need 'sudo'
after that, we wanna make the change permanently
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
finally we change 'UTC=yes' into 'UTC=no' in the file located at
'/etc/default/rcS'
now you have it done! do a 'date' for sure
3/02/2012
Rails 3 issue: 'Content-Length' field not exist in HTTP head when using 'send_data' method
class AnyController < ApplicationController def any_action send_data [SOME-BINARY-DATA] end end
when browser make any request to this controller, Rails 3 app will
REMOVE your 'Content-Length' field of the HTTP response header, even
you add content-length in the logic code explicitly
To fix this, we could add a Rack middleware and plug it in to the app,
in your #{Rails.root}/config/application.rb file, find code like below:
module XX class Application < Rails::Application config.middleware.use "HttpHeaderFix" # add this line
then create a file named 'http_header_fix.rb' at #{Rails.root}/middleware
class HttpHeaderFix def initialize(app) @app = app end def call(env) status, headers, response = @app.call(env) if headers["Content-Type"] == "application/octet-stream" if headers["Content-Length"].blank? if response.respond_to? :length length = response.length elsif response.respond_to? :count length = response.count elsif response.respond_to? :size length = response.size elsif response.respond_to? :body length = response.body.length else raise "unknown response: #{response.class}" end headers["Content-Length"] = length.to_s end end [status, headers, response] end endOK, there you go!!
3/01/2012
Setup ssh proxy under linux
check your /etc/shells file if it contains a line '/sbin/nologin'
Then you want just add your SSH account like this:
useradd -M -s /sbin/nologin -n usernamesome version of Linux may like this:
useradd -s /sbin/nologin usernameand even the 'nologin' shell is located at '/usr/sbin/nologin' in some
Linux version
Now, you have a SSH server & account setup
Recommended web browser plugins for SSH proxy:
Firefox users checkout autoproxy:
https://addons.mozilla.org/en-US/firefox/addon/autoproxy/
Chrome users checkout Switchy!:
https://chrome.google.com/webstore/detail/caehdcpeofiiigpdhbabniblemipncjj
2/12/2012
Setup RVM on Mac OS X
Installing rvm itself is pretty easy. The rvm homepage gives a quick
install command:
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)and then add this to your shell profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" CC=/usr/bin/gcc-4.2For ruby 1.9.3, we need libksba installed, using Homebrew, just run
'brew install libksba'installing Homebrew is quite easy too:
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"now try install ruby 1.9.3:
rvm install 1.9.3 --reconfigure --debug -C --enable-pthread --with-gcc=clangNOTE: in case of any compilation issues
* downgrade to Xcode 4.1
* or install osx-gcc-installer
and reinstall your rubies.
Setup Git on Mac OS X
- Check this out http://code.google.com/p/git-osx-installer/ *Don't worry if it's a Snow Leopard version, it works on Lion!
- Double click to mount it.
- Run the git-1.x.x.x-x.pkg (A basic installer. Note: You'll need administrative privileges.)
- Complete the Installation
- Open up a terminal
- Change directories to the mounted image
bash$ cd /Volumes/Git\ 1.x.x.x\ xx/ - Run the shell script (bash$ ./setup\ git\ PATH\ for\ non-terminal\ programs.sh)
- Change directories to the mounted image
Re-open your terminal (reset your session) and you'll be good to go. Up and running with Git in no time!
2/04/2012
[转] 最大化Dropbox的免费空间
1. 使用别人的邀请链接注册,这样就是2.25G,否则只有2G。我的Referer链接: http://db.tt/MQB4KVy
2. 安装Dropbox客户端,然后完成Get Started教程里的五六步,获得256M免费空间 https://www.dropbox.com/gs
3. 获得额外的5×128M免费空间 https://www.dropbox.com/free
(1) 绑定Twitter帐户 - 128MB
(2) 绑定Facebook帐户 - 128MB
(3) 在twitter上Follow @Dropbox - 128MB
(4) 写出一句话说明为什么你喜欢Dropbox - 128MB
(5) 把那句话Tweet出去(就是发到twitter上) - 128MB
4. 邀请其他人,每个人可以给你增加256MB空间。
5. 如果你有.edu、.edu.cn等邮箱(学生或者老师,比如武大的@mail.whu.edu.cn就行),访问https://www.dropbox.com/edu 绑定edu邮箱,就可以将每次邀请的量增加,由256增加到512,邀请能获得的最大空间也会翻倍到16G。步骤1的256也会变成512。