Skip to content

Instantly share code, notes, and snippets.

defines = [
['"(.*)"/"(.*)"でログインする',"open,/login/show,\ntype,u,%s\ntype,p,%s\nclickAndWait,login2,"],
["「確認画面へ」", "//img[@alt='確認画面へ']"], [".*に遷移する", "ClickAndWait,%s,"],
]
actions = ['"id"/"password"でログインする','「確認画面へ」に遷移する']
testblock = actions.map do |action|
testcases = defines.find_all{|d| action =~ Regexp.new('^' + d[0] + '$')}[0][1]
target = action.scan(/「.*」/).map{|x| defines.find_all{|d| x == d[0]}[0] }.map{|x| x[1]} + action.scan(/"(.*?)"/).flatten
@koduki
koduki / packagejar.rb
Created March 26, 2011 19:07
Rakefile: packaging ruby files in jar.
# package dfines
APP_NAME = "myapp"
TARGET = "hello.rb"
FILES = [
"hello.rb",
"testcase.xls",
"lib/*"
]
# work directories
@koduki
koduki / okm.rb
Created April 16, 2011 17:01
Object Mapper for kvs
module PConfig
def self.setup params
@store = params[:store]
end
def self.store
@store
end
end
class Index
load './kvs.rb'
require 'roma-client'
PConfig.setup :store => Roma::Client::RomaClient.new (["localhost:11212"])
data.each{ |xs|
p xs
index = xs[1] + xs[0]
order = Order.new "koduki" + index
order.isbn = xs[0]
order.user_id = 'koduki'
@koduki
koduki / JPAExample.java
Created May 22, 2011 09:38
JPA 2.0(JavaEE 6 by GlassFish 3.1) Example with CriteriaQuery.
import java.util.List;
import javax.ejb.embeddable.EJBContainer;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="CustomerDBPU" transaction-type="JTA">
<jta-data-source>jdbc/sample</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.logging.timestamp" value="true" />
<property name="eclipselink.logging.session" value="true" />
<property name="eclipselink.logging.thread" value="true" />
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="CustomerDBPU" transaction-type="JTA">
<jta-data-source>jdbc/sample</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.logging.timestamp" value="true" />
<property name="eclipselink.logging.session" value="true" />
<property name="eclipselink.logging.thread" value="true" />
@koduki
koduki / install.sh
Created June 11, 2011 01:01
titanium build and install command.
#!/bin/zsh
MOBILE_SDK=${HOME}/Library/Application\ Support/Titanium/mobilesdk/osx/1.7.0.RC1
ANDROID_SDK=/opt/android-sdk-mac_x86
guid=`xpath tiapp.xml "//guid/text()"` 2> /dev/null
name=`xpath tiapp.xml "//name/text()"` 2> /dev/null
id=`xpath tiapp.xml "//id/text()"` 2> /dev/null
$MOBILE_SDK/android/builder.py install $name $ANDROID_SDK ./ $id $guid
# -*- encoding: UTF-8 -*-
require 'time'
require 'twitter'
require 'roma/client'
timeline = Twitter.user_timeline('ntt_rate1').map{|s| [s.id, s.text, Time.parse(s.created_at)]}
rates = timeline.map do |r|
[
@koduki
koduki / realtime_fx_rate.rb
Created June 21, 2011 14:27
save ntt_rate1 post to MongoDB.
# -*- encoding: UTF-8 -*-
require 'mongo_mapper'
class Rate
include MongoMapper::Document
key :twitter_id, String
key :date, Date
key :USD, Float
key :EUR, Float