This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- [実行方法] | |
-- sqlplus scott/tiger@localhost:1521/sid @create_ddl.sql | |
-- [出力結果] | |
-- create_table.sql | |
-- [参考] | |
-- http://oracle.se-free.com/ddl/A1_get_ddl.html | |
set long 2000 | |
set heading off | |
set line 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cf. http://www.ne.jp/asahi/hishidama/home/tech/java/swing/DropTarget.html | |
import groovy.swing.SwingBuilder | |
import javax.swing.JFrame | |
import java.awt.dnd.DropTarget | |
import java.awt.dnd.DnDConstants | |
import java.awt.datatransfer.DataFlavor | |
import java.awt.datatransfer.Transferable | |
def swing = new SwingBuilder() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// こちらは以前試していた失敗作 | |
class DoWhile { | |
def proc | |
def _do(Closure proc) { | |
this.proc = proc | |
return this | |
} | |
def _while(Closure cond) { | |
10.times { | |
println cond() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'UTF-8'.with { enc -> | |
URLDecoder.decode(new URL('http://h.hatena.ne.jp/').getText(enc), enc) | |
}.findAll(~/["']\/keyword\/(.+?)["']/) { match, _1 -> | |
_1 | |
}.sort().unique().each { | |
println it | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.swing.SwingBuilder | |
import javax.swing.JFrame | |
import java.awt.GridLayout | |
def printlnswing(message) { | |
new SwingBuilder().edt { | |
frame(title: 'Message', pack: true, visible: true, | |
layout: new GridLayout(0, 1), | |
defaultCloseOperation: JFrame.EXIT_ON_CLOSE) { | |
message.eachLine() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.util.UUID.randomUUID().toString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def beforeN(int n) { | |
new Date() - n | |
} | |
// 例: 100日前 | |
println beforeN(100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import javax.xml.parsers.*; | |
import javax.xml.transform.*; | |
import javax.xml.transform.dom.*; | |
import javax.xml.transform.stream.*; | |
import org.w3c.dom.*; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Markdown { | |
/** 見出し:Atx形式 */ | |
String headerAtx(String md) { | |
def sharpSize = md.find(/^#+/).size() | |
if (sharpSize in 1..6) { | |
def tags = [ "<h${sharpSize}>", | |
"</h${sharpSize}>" ] | |
//def contents = md.replaceAll(/^#+\s*|\s*#+$/, '').trim() | |
def contents = md.replaceAll(/(?x) # enable whitespace and comments | |
^\#+ # 先頭からはじまるシャープ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String[] deal(int numPlayers, String deck) { | |
deck.toList().collate(numPlayers, false) | |
.transpose()*.join() ?: [''] * numPlayers | |
} | |
assert deal(3, '123123123') == ['111', '222', '333'] as String[] | |
assert deal(4, '123123123') == ['12', '23', '31', '12'] as String[] | |
assert deal(6, '012345012345012345') == ['000', '111', '222', '333', '444', '555'] as String[] | |
assert deal(4, '111122223333') == ['123', '123', '123', '123'] as String[] | |
assert deal(1, '012345012345012345') == ['012345012345012345'] as String[] | |
assert deal(6, '01234') == ['', '', '', '', '', ''] as String[] |
NewerOlder