Skip to content

Instantly share code, notes, and snippets.

View ZhouMeichen's full-sized avatar

Michelle ZhouMeichen

View GitHub Profile

Deploy Rails Application (Nginx+Unicorn+MySQL) onto OpenShift

1) Create a DIY cartridge and add a MySQL cartridge

$ rhc app create -a [appname] -t diy-0.1
$ rhc cartridge add -a [appname] -c mysql-5.1

2) Download and install RVM for Openshift

Install and Run Tomcat & Apache Solr on OpenShift

1. Install Tomcat 7

1) Create a DIY cartridge

$ rhc app create -a [appname] -t diy-0.1

2) Download Tomcat

$ rhc app ssh [appname]

@ZhouMeichen
ZhouMeichen / dynamic.rb
Last active December 26, 2015 09:49
将字符型的类名及方法名动态转换成类和方法进行调用
# className & methodName are both String
# Object.send
def dynamic(className, methodName, *param)
k = Kernel.const_get(className).new()
k.send(methodName, *param) if k.respond_to? methodName
end
# Object.method
def dynamic(className, methodName, *param)
@ZhouMeichen
ZhouMeichen / my_map.rb
Last active December 26, 2015 12:29
用each实现map方法
# one dimensional array
# yield
class Array
def my_map
arr = []
each {|n,i| arr << yield(n)}
arr
end
end
@ZhouMeichen
ZhouMeichen / Singleton method and Instance method.md
Last active December 27, 2015 01:19
单例方法和实例方法(Singleton method and Instance method)

单例方法和实例方法(Singleton method and Instance method)

一、单例方法(Singleton method)

1、介绍

单例方法是某个具体实例对象的特有方法,只属于该实例对象。在Ruby中一切都是对象,所以类方法(Class method)也是一种特殊的单例方法,是某个具体类的特有方法。

2、实现

第一种:普通

@ZhouMeichen
ZhouMeichen / interfaceTest.rb
Last active May 10, 2019 05:26
Bank API Test (Communicate with IBM WebSphere MQ)
#encoding: utf-8
require 'open-uri'
require 'net/http'
require 'net/ssh'
require 'net/scp'
require 'nokogiri-pretty'
require 'rexml/document'
include REXML
@ZhouMeichen
ZhouMeichen / 开源自动化测试框架.md
Last active November 5, 2017 09:27
整理熟悉的测试框架(Selenium、Watir、Watir WebDriver)

开源自动化测试框架

自动化测试工具有很多,包括开源的和商业的,以下介绍目前比较流行的开源自动化测试工具。

1. Selenium

Selenium是一个用于Web应用程序自动化测试的开源测试框架。Selenium是个庞大的家族,包含Selenium IDE、Selenium Server、Selenium Core、Selenium WebDriver、Selenium RC(Remote Control)、Selenium Grid、Selenium on Rails等。

Selenium 1.0(RC)

简介

@ZhouMeichen
ZhouMeichen / generator.rb
Last active December 30, 2015 18:19
根据excel文件,生成若干数据(xml)
#encoding: utf-8
require 'spreadsheet'
require 'rexml/document'
include REXML
class Generator
attr_accessor :dataResult #array,获取每个xml所需数据
attr_accessor :resultPath #string,生成的xml存储路径
attr_accessor :excelPath #string,excel文件路径
attr_accessor :templatePath #string,xml模板文件路径
@ZhouMeichen
ZhouMeichen / README.txt
Created December 10, 2014 09:10
接口测试脚本(WebService+CSV in Windows)
1、安装Rubyinstaller for windows
前往“http://rubyinstaller.org/downloads/”网站下载RubyInstaller for Windows。一般,请下载1.9.3以上版本。按照提示安装即可,其中需要勾选“Add Ruby executables to your PATH”选项。
#####################################################################
2、安装gem
此工具所需gem包含:tiny_tds。可直接在命令行中联网安装,打开“cmd”,输入“gem install tiny_tds”。若联网安装失败,可使用已下载的“tiny_tds-0.6.2.gem”,在命令行中输入“gem install 路径/tiny_tds-0.6.2.gem”进行安装。
#####################################################################
3、根据具体测试环境修改conf文件夹中的config.yml
(1)method1:
connect_username:数据库登陆名
connect_password:数据库登陆密码
@ZhouMeichen
ZhouMeichen / JMeterJavaSampler.java
Created March 1, 2015 06:35
调用WebSphere MQ接口实现消息的读取,利用JMeter的Java请求进行性能测试
package test;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;