Skip to content

Instantly share code, notes, and snippets.

@wkubota
wkubota / detect_suspicious_data_provider.rb
Created April 13, 2018 08:47
PhpUnitのdataProvider向けメソッド名に``test``プリフィックスをつけてしまっているものを見つけ出すスクリプト
#!/usr/bin/ruby
require 'pp'
testDir = "./tests/"
tests = Hash.new
Dir.glob(testDir + '**/*.php') do |filename|
File.open(filename) do |file|
targets = []
file.each_line do |line|
/(.*)(@dataProvider )(test.*)/ =~ line
@wkubota
wkubota / detect_php_testless_class.rb
Last active May 1, 2017 07:44
php の テストケースが無いクラスを見つけるrubyスクリプト
#!/usr/bin/ruby
sourceDir = "./app/"
testDir = "./tests/"
tests = Hash.new
Dir.glob(testDir + '**/*.php') do |filename|
sourcePath = filename.gsub(testDir, sourceDir)
sourceFile = sourcePath.gsub('Test.php', '.php')
tests[sourceFile] = filename
end
@wkubota
wkubota / succ_num.js
Last active March 1, 2016 10:23
連続ニョロ問題
var input_array = [1,2,3,5,6,7,9,11,12,13,14,16,18,19,23,24,25,26];
var result = "";
var arrIndexElements = function (element, index, array) {
//console.log("a[" + index + "] = " + element + " " + array + " " + this);
console.log("a[" + index + "] = " + element + ":" + result);
if (index === 0) {
result = result + element;
} else {
var prev = array[index - 1];
@wkubota
wkubota / list_all_jobs.groovy
Created December 17, 2015 02:34
JenkinsのScript Consoleから実行すると全てのJobの名称を出力欄に列挙してくれるコードスニペット
import hudson.model.*
displayChildren(Hudson.instance.items)
def displayChildren(items) {
for (item in items) {
if (item.class.canonicalName != 'com.cloudbees.hudson.plugins.folder.Folder') {
println(item.name)
}
#!/bin/bash
result="job.rslt"
rm $result
for var in 0 0 0
do
# ./child.sh $var&
ruby child.rb $var&
mypid=$!
echo $mypid
#!/bin/bash
ARG1=$1
echo $ARG1
sleep 30s
exit $ARG1
@wkubota
wkubota / sendmail.rb
Created February 27, 2015 03:53
カレントディレクトリ配下の(複数の)emlファイルを元にメールを送出するスクリプト
require 'net/smtp'
Dir.glob("./**/*.eml") { |filename|
open(filename) do |f|
Net::SMTP.start('mail.example.com') {|smtp|
smtp.send_message(f,'from@example.com','to@example.com')
}
end
}
alert("A");
@wkubota
wkubota / evil_if_sentence.cs
Last active August 29, 2015 14:10
良くないところのいっぱいあるif文の例
///// intValueはこの元のメソッドの引数でint型
int fuga = 0;
// 90<XXX率
if (intValue >= 90)
{
// 値を設定
fuga = 1;
}
// 80<XXX率≦90
if (80 < intValue && intValue <= 90)
@wkubota
wkubota / fizzbuzz.cpp
Last active August 29, 2015 14:09
C++のテンプレートメタプログラミングでFIZZBUZZを書いてみた。
#include <iostream>
#include <string>
#define FIZZ "Fizz"
#define BUZZ "Buzz"
#define CRLF "\r\n";
template<int N>
struct num {
static std::string value() {