Skip to content

Instantly share code, notes, and snippets.

@sue445
sue445 / BaseTest.java
Last active December 11, 2015 18:29
ExternalResourceでテストコードのリファクタリングをしてみるサンプル
import org.junit.After;
import org.junit.Before;
public abstract class BaseTest {
@Before
public void setUp() throws Exception {
// setup
}
@Model(schemaVersion = 1)
public class SampleModel implements Serializable {
private String oldText;
@Attribute(lob = true)
private String newText;
public String getText(){
if(newText == null){
return oldText;
@sue445
sue445 / android_market_api_sample.rb
Created February 5, 2013 14:03
android_market_api のサンプル
require 'rubygems'
require 'android_market_api'
p "app detail"
p AndroidMarketApplication.new('jp.drecom.sg.nprwidget')
# Not Found
#p "get_overall_top_selling_free_app"
#p AndroidMarket.get_overall_top_selling_free_app(15)
@sue445
sue445 / array_instance_of.rb
Created February 19, 2013 02:40
[RSpec custom matcher] instance of array element are same class
# -*- coding: utf-8 -*-
require "rspec"
=begin
example)
[1, 2, 3].should array_instance_of Fixnum
=end
RSpec::Matchers.define :array_instance_of do |element_class|
match do |array|
@sue445
sue445 / string_matcher_spec.rb
Created March 8, 2013 08:28
string matcher using between be_include and include
# -*- coding: utf-8 -*-
require 'spec_helper'
describe String do
it "match with be_include" do
"cure peace".should be_include "azatoi"
=begin
error message
1) String match with be_include
@sue445
sue445 / plot-rspec-slowest-examples.rb
Last active December 14, 2015 19:58
extract rspec example seconds from rspec stdout
# extract example seconds from rspec profile log
#
# required:
# rspec >= 2.10.0
# Jenkins Plot Plugin
#
# usage:
# rspec --profile 5 > rspec-console.log # rspec >= 2.13.0
# rspec --profile > rspec-console.log # 2.10.0 <= rspec < 2.13.0
# ruby plot-rspec-slowest-examples.rb rspec-console.log > plot.csv
@sue445
sue445 / ja.bootstrap.yml
Last active December 15, 2015 12:39
bootstrap-railsでconfig/locales/ に置くlocaleファイル
# https://gist.github.com/sue445/5261654
ja:
helpers:
actions: "Actions"
links:
back: "戻る"
cancel: "キャンセル"
confirm: "本当にいいですか?"
destroy: "削除"
@sue445
sue445 / sample1_spec.log
Last active November 11, 2022 01:59
subject!とbeforeの順番が気になったので調べてみた
$ rspec --version
2.13.1
$ rspec -- sample1_spec.rb
before(:all)
subject!
let!
before(:each)
it
after(:each)
@sue445
sue445 / memcache.groovy
Created April 24, 2013 03:42
GAErminal上でmemcacheのhitRatioをお手軽計算
import org.slim3.memcache.Memcache
def stats = Memcache.statistics()
def totalCount = stats.getHitCount() + stats.getMissCount()
def hitRatio = stats.getHitCount() / totalCount
println hitRatio
@sue445
sue445 / gae_production.groovy
Created May 4, 2013 16:15
GAErminal上でappengineのproduction環境のAPIバージョンを取得してみた
import org.slim3.util.ServletContextLocator
def servletContext = ServletContextLocator.get()
def serverInfo = servletContext.serverInfo
println serverInfo // => Google App Engine/Google App Engine/1.8.0