Skip to content

Instantly share code, notes, and snippets.

View yorzi's full-sized avatar
🏠
Working from home

Andy Wang yorzi

🏠
Working from home
  • Xi'an, China
  • 14:56 (UTC +08:00)
View GitHub Profile
@yorzi
yorzi / tips.mysql.create_user
Created March 5, 2009 07:58
Create DB and regarding user
CREATE DATABASE testdb;
CREATE USER 'testuser'@localhost IDENTIFIED BY 's8723hk2';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@localhost;
exit
@yorzi
yorzi / rm .svn
Created March 16, 2009 09:26
delete all .svn file
find . -type d -name ".svn"|xargs rm -rf
@yorzi
yorzi / sample for password check.html
Created March 25, 2009 03:28
check passwor power
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网页密码强弱度检测</title>
</head>
<style type="text/css">
#pwdpower {
width:195px;
border:0px none;
@yorzi
yorzi / gist:769254
Created January 7, 2011 08:22 — forked from xdite/gist:758319
Ruby on Rails development Conventions

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
@yorzi
yorzi / deploy-rails3-app-to-subdirectory
Created January 20, 2011 09:02
deploy rails3 app to subdirectory and don't disturb local development url. Just make sure you are setting the config.ru in right way.
#config.fu
require ::File.expand_path('../config/environment', __FILE__)
if Rails.env.production?
map '/sub-folder-name' do
run YourApp::Application
end
else
run YouApp::Application
end
@yorzi
yorzi / ruby-1.9-tips.rb
Created February 13, 2011 05:32 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 Features and tips.
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@yorzi
yorzi / gist:836679
Created February 21, 2011 05:11 — forked from xdite/gist:835829
MacBook 装机配置Rails的步骤

MacBook 裝機步驟

警告: 請絕對不要跳著裝!

系統套件

  • Software Update
  • Install Xcode ( Mac OS X Install CD 那一塊的 >> 選擇安裝)
@yorzi
yorzi / write_deploy_log.rb
Created February 24, 2011 02:36 — forked from terrbear/write_deploy_log.rb
save the deploy log to server
alias :pputs :puts
def puts(str = "")
pputs(str)
$out << "#{str}"
end
STDOUT.instance_eval do
alias :pputs :puts
def puts(str = "")
pputs(str)
@yorzi
yorzi / branch-prompt.sh
Created March 17, 2011 13:33 — forked from thadd/branch-prompt.sh
Show your current git branch in a right-hand prompt in zsh
typeset -ga precmd_functions
precmd_functions+='update_git_branch_prompt'
update_git_branch_prompt() {
RPROMPT=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
}
@yorzi
yorzi / parent_layout_helper.rb
Created March 18, 2011 07:15
allow you nest you layout in rails application
#nested layout.
def parent_layout(layout)
@_content_for[:layout] = self.output_buffer
self.output_buffer = render(:file => "layouts/#{layout}")
end