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
  • 07:12 (UTC +08:00)
View GitHub Profile
@yorzi
yorzi / paper_trail_history.rb
Last active August 29, 2015 14:04
paper_trail_history.rb
class PaperTrailHistory < PaperTrail::Version
def self.compose_query(params)
condition = ""
condition <<
(params[:type].present? ? "whodunnit NOT IN (?)" : "whodunnit IN (?)")
condition << " AND object_changes ILIKE '%#{params[:q]}%'" if params[:q].present?
@yorzi
yorzi / gist:da7600f1a045d5cf9425
Created July 6, 2015 10:02
bee-run-failed.sh
andy@Andys-Macbook-Pro~/workspace/go.projects/src/github.com/moscn/picoshop(users-and-orders):bee run
2015/07/06 17:50:11 [INFO] Uses 'picoshop' as 'appname'
2015/07/06 17:50:11 [INFO] Initializing watcher...
2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego)
2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/cache)
2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/cache/memcache)
2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/cache/redis)
2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/config)
2015/07/06 17:50:11 [TRAC] Dir
@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)