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 / 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 / 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 / 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
jruby 1.6.4或者ruby-1.9.2-p180
Rails 3.0.9
问题描述:
在rails初始化中声明HOST_NAME为一个String,然后在控制器中有这样的代码:
str = "## " + HOST_NAME + " ##"
启动程序的时候会出错(rails s):
然后我将上面的代码改一下子:
@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("请填写宝宝的姓名!");
@qichunren
qichunren / nginx.sh
Created September 20, 2011 07:49
file name: /etc/init.d/nginx use service nginx [start|stop|restart]
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@qichunren
qichunren / etc_init.d_tomcat
Created September 26, 2011 03:04
tomcat daemon script
#!/bin/sh
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the tomcat web server
# Description: starts tomcat using start-stop-daemon
@qichunren
qichunren / tmp.txt
Created October 25, 2011 04:08
temp text
*** 车厢1 ***
2011-10-25 12:07:32
温度000: 0c
温度001: 0c
湿度000: 0%RH
湿度001: 0%RH
@qichunren
qichunren / client.rb
Created November 18, 2011 02:29
ruby udp
require 'socket'
socket = UDPSocket.new
socket.send("I am ok.", 0, 'localhost', 1234)
text, sender = socket.recvfrom(16)
socket.close
@qichunren
qichunren / database_backup.sh
Created November 28, 2011 10:10
backup mysql data
#!/bin/bash
if [ ! -d /root/backup/sql ]; then
mkdir -p /root/backup/sql
fi
cd /root/backup/sql
database_yml=/www/ntdeck_secart/WEB-INF/config/database.yml
date_str=`date +%Y_%m_%d_%H_%M`
db_username=`grep user $database_yml | awk '{print $2}' | sed -n 3p`