This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ubuntu下Git服务器安装与配置 | |
1. 安装 | |
1.1 安装Git-Core: | |
sudo apt-get install git-core | |
1.2 安装 Gitosis | |
sudo apt-get install python-setuptools | |
mkdir ~/src | |
cd ~/src | |
git clone git://eagain.net/gitosis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scripting | |
一、In drivers which support it, you can easily execute JavaScript: | |
page.execute_script("$('body').empty()") | |
For simple expressions, you can return the result of the script. Note that this may break with more complicated expressions: | |
result = page.evaluate_script('4 + 4'); | |
二、 page.execute_script("$('div:eq(0)').length") | |
page.execute_script("document.getElementById('wrapper')") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
模拟浏览器,人工测试 | |
1. 文本框: | |
直接填充 : fill_in("#{@user.id}_name",:with=>"jdo") | |
通过节点赋值 : find(:xpath,"//html/body/div[2]/div[2]/div/div/div[3]").set("123456") | |
获取文本框值: find(:xpath,"//html/body/div[2]/div[2]/div/div/div[3]").value.should=="expect value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
一 、Apache with passenger deploying rails project | |
1. 安装好 ror 环境 | |
bundle exec rake RAILS_ENV=production db:create | |
bundle exec rake RAILS_ENV=production db:migrate | |
2. 安装apache | |
sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev | |
3.安装 passenger | |
sudo gem install passenger | |
sudo passenger-install-apache2-module | |
4. 按照提示 编辑 httpd.conf ,并添加如下配置 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 在本地服务器建立 rubygems.org 的镜像缓存,以提高 gem 的安装速度 | |
# 此配置设置缓存过期为1天,也就是说,新上的 gem 无法马上安装 | |
# 做这个起什么作用? | |
# rubygems 的很多资源文件是存放到 Amazon S3 上面的,由于 GFW 对某些 S3 服务器又连接重置或丢包,导致 gem 安装异常缓慢或有时候根本无法连接安装。 | |
# 而通过这种跳板的方式可以很好的解决这个问题,当然前提是 Nginx反向代理 服务器需要在国外 | |
proxy_cache_path /var/cache/rubygems levels=1:2 keys_zone=RUBYGEMS:10m | |
inactive=24h max_size=1g; | |
server { | |
listen 80; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nletter = "...whatever..." | |
Newsletter.all.each do |user| | |
Mailer.deliver_letter(nletter, user) | |
end | |
# And your mailer function would look like: | |
def letter(nletter, user) | |
@nletter = nletter | |
mail(:to => user.email, :subject => @nletter.subject) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#(1) 把timestamp和token联合; | |
# (2) 使用HMAC算法得到加密字符串(将appkey作为参数并使用SHA256 哈希方法); | |
# (3) 比较signature和得到的加密字符串。 | |
timestamp = "1398236282767" | |
token = "THd78OwTxVGjTgCYSOxr4vkCPj3oIUg1TpZgkYpjerT2zNWdPQ" | |
signature = "df5fc888e86c8032f0c6b56e91ab91ebdfdae297e7a1dd4983e2e091042c151e" | |
data = timestamp + token | |
appkey = 'bl92t6tw-55zn-h14y-uzpd-y52k7jqe5s' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "bundler/setup" | |
require "stringex" | |
## -- Rsync Deploy config -- ## | |
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file | |
ssh_user = "[email protected]" | |
ssh_port = "22" | |
document_root = "~/website.com/" | |
rsync_delete = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pony' | |
mails = {:to=>"[email protected]", | |
:subject=>"问答箱子找回密码", | |
:from=>"[email protected]", | |
:html_body=>"html body", | |
:via=>"smtp", | |
:via_options=>{ | |
:address => 'smtp.exmail.qq.com', | |
:port => '25', | |
:user_name => '[email protected]', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list | |
get '/' do | |
list = Dir.glob("./files/*.*").map{|f| f.split('/').last} | |
# render list here | |
end | |
# upload | |
post '/' do | |
tempfile = params['file'][:tempfile] | |
filename = params['file'][:filename] |
OlderNewer