Skip to content

Instantly share code, notes, and snippets.

View qichunren's full-sized avatar
🌈
Focusing contribute

Qichunren qichunren

🌈
Focusing contribute
View GitHub Profile
@qichunren
qichunren / 脚本验证.html
Created September 16, 2011 13:12 — forked from hare1987/脚本验证.html
脚本验证
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function checkregform(){
alert("验证开始了!");
if (document.yx.name.value==""){
alert("请填写宝宝的姓名!");
jruby 1.6.4或者ruby-1.9.2-p180
Rails 3.0.9
问题描述:
在rails初始化中声明HOST_NAME为一个String,然后在控制器中有这样的代码:
str = "## " + HOST_NAME + " ##"
启动程序的时候会出错(rails s):
然后我将上面的代码改一下子:
@qichunren
qichunren / nginx_config.text
Created August 30, 2011 06:23
nginx config
qichunren@qichunren-desktop:/opt/nginx-1.0.6$ ./configure --help
--help this message
--prefix=PATH set the installation prefix
--sbin-path=PATH set path to the nginx binary file
--conf-path=PATH set path to the nginx.conf file
--error-log-path=PATH set path to the error log
--pid-path=PATH set path to nginx.pid file
--lock-path=PATH set path to nginx.lock file
@qichunren
qichunren / ajax_history.js
Created July 20, 2011 02:33
mark url location history( ajax history)
// mark current location url
$("#nav_ticker").click(function(){
$("#nav ul li").removeClass("active");
$(this).addClass("active");
window.location.hash = "tickers/cp";
});
$("#nav_announce").click(function(){
$("#nav ul li").removeClass("active");
$(this).addClass("active");
@qichunren
qichunren / static_page_generator.rb
Created June 22, 2011 15:02
StaticPageGenerator
# encoding: utf-8
require File.expand_path("../../config/environment", __FILE__)
require File.expand_path("../../app/helpers/application_helper", __FILE__)
class StaticPageGenerator
attr_reader :source_dir, :output_dir
def initialize(output_dir=Rails.root.join("html"))
@source_dir = Rails.root.join("themes/default/views")
@output_dir = output_dir
@qichunren
qichunren / Readme.md
Created May 12, 2011 09:20
growlnotify
@qichunren
qichunren / auto_pull.sh
Created April 28, 2011 01:55
运用expect自动输入密码
qichunren@ubuntu:~/repos$ cat auto_pull.sh
#!/usr/bin/expect
set timeout 30
cd /home/qichunren/repos/web_backend
spawn git pull --rebase
expect "[email protected]'s password:"
send "secretpassword\r"
send "\r"
sleep 10
@qichunren
qichunren / Capybara_demo.rb
Created March 24, 2011 06:57
这个用来测试业务流程操作,以test_开头的public方法都会执行
# encoding: utf-8
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
# require 'capybara/rspec'
Capybara.run_server = false
Capybara.current_driver = :selenium
Capybara.app_host = 'http://cqrorx.com:3000'
Capybara.default_wait_time = 4
namespace :dev do
task :s do
sh "thin start -d -e production -p 5000"
end
task :stop do
sh "kill -9 `cat tmp/pids/thin.pid`"
end
@qichunren
qichunren / application_controller.rb
Created March 9, 2011 09:24
login from http basic authcation
class ApplicationController < ActionController::Base
USER_NAME, PASSWORD = "xx", "secret"
protect_from_forgery
before_filter :login_from_http_auth
protected
def login_from_http_auth
authenticate_or_request_with_http_basic do |user_name, password|
user_name == USER_NAME && password == PASSWORD