Skip to content

Instantly share code, notes, and snippets.

View bigwheel's full-sized avatar

k.bigwheel (kazufumi nishida) bigwheel

View GitHub Profile
@bigwheel
bigwheel / lunch.rb
Created August 2, 2012 03:46
ランダムに2チームへ分けるスクリプト 超人パワー編
#!/usr/bin/env ruby
srand(Time.local(2012, 8, 2).to_i)
class Member
attr_reader :name, :power
def initialize(name)
@name = name
@power = rand
end
@bigwheel
bigwheel / gist:3300587
Created August 9, 2012 03:13
ランダムに2チームへ分けるスクリプト ジャンケン編
#!/usr/bin/env ruby
class Member
attr_reader :name
def initialize(name)
@name = name
end
def win?(opponent)
result_table = { gu: { gu: :even, choki: :win, pa: :lose },
@bigwheel
bigwheel / gist:3366148
Created August 16, 2012 03:12
ランダムに2チームへ分けるスクリプト ジャンケン編 - モジュールに機能を分離
#!/usr/bin/env ruby
class Member
attr_reader :name
def initialize(name)
@name = name
end
end
class Symbol
@bigwheel
bigwheel / gist:3431969
Created August 23, 2012 03:39
ランダムに2チームへ分けるスクリプト ハイアンドロー編
#!/usr/bin/env ruby
class Member
attr_reader :name
def initialize(name)
@name = name
end
def win?(opponent)
raise 'should be overrided'
end
@bigwheel
bigwheel / gist:3650445
Created September 6, 2012 03:06
ランダムに2チームへ分けるスクリプト グッパでホイ編
#!/usr/bin/env ruby
class Member
attr_reader :name
def initialize(name)
@name = name
end
def hand
@bigwheel
bigwheel / gist:3909586
Created October 18, 2012 02:45
ランダムに2チームへ分けるスクリプト scala編
import scala.util.Random
object lunch_script {
def main(args: Array[String]) : Unit = {
val splitMember = shuffleAndSplit(args.toList, 20121018)
println(splitMember._1)
println(splitMember._2)
}
def shuffleAndSplit(member: List[String], date: Long) : (List[String], List[String]) = {
@bigwheel
bigwheel / main.rb
Last active December 16, 2015 12:18
Magic: the Gatheringカードメージギャラリーから@wikiフォーマットでドラフト点数表のテンプレートを作る
#!/bin/env ruby
# -*- coding: utf-8 -*-
require 'open-uri'
require 'nokogiri'
require 'pry'
doc = Nokogiri::HTML(open('http://www.wizards.com/magic/tcg/article.aspx?' +
'x=mtg/tcg/dragonsmaze/cig',
'Accept-Language' => 'ja,en-US;q=0.8,en;q=0.6'))
@bigwheel
bigwheel / print_casual_stacktrace.php
Last active December 22, 2015 10:29
phpで任意の箇所でスタックトレース表示するコード
foreach (debug_backtrace() as $func)
{
\Log::warning($func['file'] . ' - ' . $func['class'] . $func['type']
. $func['function'] . '(' . $func['args'] . ')[L' . $func['line'] . ']');
}
# play-jsonからhoconフォーマットへだいたい変換するスクリプト
# Seqだけはカッコが同一行へ存在しないと変換を失敗する
sed -i -e 's/Json.obj(/{/g' $1
sed -i -e 's/ -> /: /g' $1
sed -i -e 's/,$//g' $1
sed -i -e 's/Seq(\(.*\))/[\1]/g' $1
sed -i -e 's/L$//g' $1
sed -i -e 's/)/}/g' $1
sed -i -e 's/^\(\s*\)"\([^"]*\)"/\1\2/g' $1
@bigwheel
bigwheel / build.sbt
Created October 21, 2014 08:29
sbtでカスタムタスクを定義する方法
val scoobiRun = taskKey[Int]("A sample int task.")
scoobiRun := {
(compile in Compile).value
println(1)
1
}