- 博客(200)
- 资源 (1)
- 收藏
- 关注
原创 ruby静态方法hook
静态方法和实例方法的实现方式不一样,代码如下: class M class << self def save(tt,a) #puts "save #{tt} #{t3}" puts "save #{tt} #{a}" end # def reload(flag) # puts "reloaded"...
2012-06-26 14:07:41
392
原创 selenium webdriver杂记
1 简述通过研究selenium-webdriver的源码,笔者发现其实webdriver的实现原理并不高深莫测无法揣度。在这里以webdriver ruby binding的firefox-webdriver实现为例,简单介绍一下webdriver的工作原理。当测试脚本启动firefox的时候,selenium-webdriver 会首先在新线程中启动firefox浏览器。如果...
2012-06-26 14:03:21
116
原创 C#类似yaml的配置文件
1 在项目的目录下创建一个XML文件,命名为App.config: <?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="sky" value="lby"/> &am
2012-06-25 16:17:40
488
原创 Ruby的优雅(C#版)
相比于C#,ruby显得灰常的优雅。 设计上的:1 不需要引用必须依赖的包C#的using System,在ruby的世界里是不存在的,没有必要反复强调这些规则。 2 非核心依赖包不需要重复引用如果有2个类A和B,都依赖于C,C#必须在A和B中都声明引用C。若是ruby,只需要在A或者B中声明一次即可,当然也可以在类似main的入口声明,这样的话A和B都不用声明了。...
2012-06-25 15:31:20
235
原创 visual studio2010常用快捷键(用时切记要淡定)
不太明白visual studio的设计者是怎么想的,为何非要把所有功能都定义成有快捷键。按2次确实可以满足需求了,但很多常用功能都得按2次了~~ 和eclipse对比来看,visual studio的快捷键就是一个S+B。 1 格式化代码Ctrl+E,再按Ctrl+D 格式化全部代码Ctrl+E,再按Ctrl+F 格式化选中的代码 2 运行调试F5调试C...
2012-06-25 14:40:27
104
原创 设置DIV并排显示
需要注意的是,所有子元素都需要设置CSS,容器可以不设置:.news { background-color: gray; border: solid 1px black; }.news img { float: left; }.news p { float: right; }<div class="news">...
2012-06-21 14:35:34
130
原创 js 取数组最大值、最小值
var arr=new Array(1,2,3,5,7); 利用apply来继承math方法function arrMath(arr){ return Math.max.apply(Math,array);} function arrMin(arr){ return Math.min.apply(Math.array);}利用apply...
2012-06-21 13:20:10
99
原创 C#给线程传递参数
需要注意的是怎样给线程传递参数。using System;using System.Collections.Generic;using System.Data.OleDb;using System.Diagnostics;using System.IO;using System.Text;using System.Threading;names...
2012-06-19 14:43:43
95
原创 ruby最简单的方式对数组求和
通过循环来求和代码看上去不太优雅,不符合ruby的特性。推荐另外一种方法:eval [1,2,3,4].join('+')
2012-06-18 17:21:02
990
原创 ruby按精度保留小数
有一个round函数,用起来非常方便:>> 2.3465.round=> 2>> 2.3465.round(2)=> 2.35>> 2.3465.round(3)=> 2.347
2012-06-18 17:17:32
1364
原创 C#发送http请求
using System;using System.IO;using System.Net;using System.Text;namespace Examples.System.Net{ public class WebRequestPostExample { public static void Main () ...
2012-06-18 10:26:29
194
原创 解决改hosts对chrome无效的问题
1. 手动清空chrome://net-internals/#dns 2. 设置禁用Chrome – > 扳手 – > 选项 – > 高级选项 – > 去勾 “用预提取 DNS 提高网页载入速度” ...
2012-05-29 12:02:15
3241
原创 最全http服务器状态码集合
1xx(临时响应)表示临时响应并需要请求者继续执行操作的状态代码。代码 说明100 (继续) 请求者应当继续提出请求。 服务器返回此代码表示已收到请求的第一部分,正在等待其余部分。101 (切换协议) 请求者已要求服务器切换协议,服务器已确认并准备切换。2xx (成功)表示成功处理了请求的状态代码。代码 说明200 (成功) 服务器已成功处理了...
2012-04-23 13:36:09
95
原创 GIT常用命令集合(持续更新)
1 check一个资源到本地git clone URL FOLDER 2 locate到另外一个URLgit remote set-url origin NEW_URL 3 添加另外一个remote URLgit remote add REMOTE_NAME URL 4 删除一个remotegit remote rm REMOTE_NAME 5 解决...
2012-04-19 18:30:00
112
原创 Ruby更改gem source
很多时候,在安装gem的过程中会出现找不到资源的error,我们需要从另外一个gem服务器下载安装。通过gem sources命令配置源,或通过修改Gemfile中的source语句可以实现。常用的源http://rubygems.org/http://gems.github.comhttp://gems.rubyforge.orghttp://ruby.taoba...
2012-04-17 16:56:51
228
原创 Linux下安装Ruby
首先来看官方推荐的方法:sudo apt-get install ruby1.9.1文档上面也说了, 这个安装的是1.9.2, 不是1.9.1。 可是, 很快你会发现一个SB的问题:在命令行里面运行ruby, 只能通过ruby191。。。 而不是ruby。 坑爹吧~~~! 最好的方法: 先安装RVM,再安装指定的ruby版本。rvm in...
2012-04-17 16:36:11
185
原创 Linux下安装RVM
1. 在命令行里面执行bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) 2. 刷新rvm命令souce ~/.rvm/scripts/rvm
2012-04-17 16:32:28
269
原创 一个好用的Linux命令行工具-yakuake
yakuake是一个linux命令行工具, 类似macos下的iTerm。 安装方法很简单:apt-get install yakuake 常用快捷键:SHIT+ LEFT / RIGHT 切换tabF12 可以显示或隐藏整个窗体...
2012-04-17 16:10:41
433
原创 Ruby通过win32ole调用操作系统接口
1 Word require 'win32ole'word = WIN32OLE.new('Word.Application') word.visible=true #?????? word.Documents.Add() for i in(0..100) word.Selection.Font.Size=12 ...
2012-04-16 13:23:02
147
原创 windows下subversion的global-ignores配置
配置global-gnores有两种方法: 修改注册表和更改配置文件。 最简单的方式:1 找到C:\Documents and Settings\lee\Application Data\Subversion\config文件 2 大致第76行: global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.p...
2012-04-13 17:03:52
307
原创 vbscript自定义import函数
vbscript本身不提供impot功能,需要自定义Sub Import(strFile)Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")Dim objFs : Set objFs = CreateObject("Scripting.FileSystemObject")strFile = W...
2012-04-11 11:57:23
359
原创 Mac Web开发环境设置不完全指南 - Shell
原文来自: http://tyraeltong.com/blog/2012/01/24/setup-web-development-environment-on-mac-3/
2012-04-09 14:11:37
163
原创 配置GIT需要忽略的文件
原文来自: http://blog.csdn.net/richardysteven/article/details/6069418 具体使用请看 man gitignore 一般某个项目dev过程中都会产生一些中间文件,这些文件是我们不想要追踪的。git中可以使用.gitignore文件来忽略这些文件。 在需要的目录下面 添加 .gitignore文件文件中每...
2012-03-22 15:25:08
116
原创 解决cygwin的文件路径冲突
删除环境变量(PATH, CYGWIN)环境变量PATH里的c:\cygwin\bin; 还有名叫CYGWIN的变量
2012-03-22 11:11:04
422
原创 Watir get started
Getting StartedLoad the Watir libraryrequire 'watir'Open a browser (default: Internet Explorer)browser = Watir::Browser.newOpen Browser at the specified URL...
2012-03-16 11:31:31
89
原创 Watir文档大全
1 watir-webdriver class APIhttp://rubydoc.info/gems/watir-webdriver/0.5.3/frames2 waitr.com 简易入门http://watir.com/examples/3 waitr-webdriver最全的文档http://wiki.openqa.org/dashboard.action 整个...
2012-03-16 11:31:00
148
原创 Ruby修改yaml文件
需要注意save之后调用close方法, 否则可能只有第一次会成功FILE_PATH = "test.yml"file_to_save = File.open(FILE_PATH,"w")YAML::dump(updatedYaml,file_to_save)file_to_save.close ...
2012-03-09 14:16:04
450
原创 Ruby命令运行rspec程序
任何ruby gem的命令都可以写成ruby的运行方式, rpsec也提供了这样的写法:require 'rspec/autorun'describe 1 do it "is < 2" do 1.should be < 2 endend 运行方式:ruby test.rb -fd ...
2012-02-13 16:13:52
460
怎样在Eclipse里面调试ruby子进程?
有两个ruby文件main.rb和sub.rb。 main.rb的内容:puts 'begin debug...'system 'ruby sub.rb'puts 'end debug...'sub.rb的内容:puts 'begin debug sub...'s = 123puts sputs 'end debug sub...' 现...
2012-02-09 17:57:40
107
Ruby怎样自定义命令
1 首先在ruby根路径下面的bin目录建立2个文件: yanzilee9292和yanzilee9292.bat。 yanzilee9292.bat文件: @ECHO OFFIF NOT "%~f0" == "~f0" GOTO :WinNTGOTO :EOF:WinNT@"ruby.exe" "%~dpn0" %* yanzilee9292文件: ...
2012-02-08 14:39:33
161
原创 解决eclispe中ruby-debug-ide19找不到路径
找到ruby-debug-ide文件,更改 bt = debug_load(Debugger::PROG_SCRIPT, options.stop, options.load_mode) #no need to modify this file. #C:\Ruby192\lib\ruby\gems\1.9.1\gems\ruby-debug-ide19-0.4...
2012-02-02 16:10:47
127
原创 怎样调试纯Ruby程序
有两个版本, 命令行的和IDE支持的 安装方法: 1. 命令行版gem install ruby-debug19 2. IDE版本gem install ruby-debug-ide19 怎样使用:http://bashdb.sourceforge.net/ruby-debug.html...
2012-02-02 14:26:55
124
原创 测试用例review
原文来自: http://hi.baidu.com/%C9%C1%D2%AB%B5%C4%CB%AE%BD%A7/blog/item/50de20378df198200a55a910.html 1. 是否涵盖了需求文档上的每个功能点 2. 是否涵盖了需求文档上的每条业务规则说明 3. 是否覆盖了输入条件的各种有意义组合 4. 是否覆盖了业务操作的基本路径和异常路径 5. 是...
2012-01-29 14:56:06
736
原创 六种用ruby调用执行shell命令的方法
原文来自: http://blackanger.blog.51cto.com/140924/43730碰到需要调用操作系统shell命令的时候,Ruby为我们提供了六种完成任务的方法1.Exec方法 Kernel#exec方法通过调用指定的命令取代当前进程:>>exec 'echo "hello $HOSTNAME"'hello nate.lo...
2012-01-20 13:05:02
298
原创 Ruby读写文件
1. 读取File.open("C:\\test\\dir1\\filename", "r") do |file| file.each_line do |line| puts line endend 2. 创建并保存file=File.new('D:\\test\\ruby.txt','w')file.puts "first...
2012-01-16 10:53:40
215
原创 Ruby中的%表示法(百分号表示法)
转自: http://hi.baidu.com/hbxiao135/blog/item/4b28bf166985f15df3de32db.html 在Ruby语言中到处充斥着语法糖衣,有很多的惯用表示法,对于初学者来说,往往被这些技巧 搞得晕头转向。 这两天看Rails源码中的Rakefile时,遇到一句代码:%x( mysqladmin --user=#{MYSQL_DB_USER} c...
2012-01-16 10:47:54
211
原创 Windows下利用GitBash生成public ssh key
1. cd到~目录, 然后运行ssh-keygen -t rsa2. 运行完成后, 会在/c/Documents and Settings/username/.ssh目录下生成2个文件:id_rsaid_rsa.pub 3. 然后把id_rsa.pub文件传给服务器, 就可以使用GIT了...
2012-01-11 14:47:46
364
原创 Defining “method_called”.. How do I make a hook method which gets called every t
原文来自: http://stackoverflow.com/questions/3236194/defining-method-called-how-do-i-make-a-hook-method-which-gets-called-every-t I want to make a hook method which gets called everytime any function ...
2012-01-10 16:17:27
119
原创 Watir建立对象库的一种方法-application和object映射
1. 对象库定义def login_link $ie.link(:text, 'Log in')enddef username_field $ie.text_field(:name, 'userid')end 2. 调用方式login_link.clickusername_field.set(username) ...
2012-01-09 16:07:23
85
原创 Watir关闭所有IE窗口的3种方法
1. 循环def close_all_windows loop do begin Watir::IE.attach(:title, //).close rescue Watir::Exception::NoMatchingWindowFoundException break rescue retry ...
2012-01-09 16:04:19
160
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅