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.awt.* | |
import javax.swing.* | |
if (args.length < 1) { | |
println "Usage: Breathe minutes" | |
System.exit(0) | |
} | |
minutes = args[0] as int | |
dim = Toolkit.getDefaultToolkit().getScreenSize(); |
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
if (args.length < 1) { | |
println("Usage: groovy FibTune.groovy words") | |
return | |
} | |
fibMap = [ | |
'I':'1', 'J':'1', 'U':'1', 'V':'1', 'Y':'1', | |
'H':'3', 'L':'3', 'N':'3', 'R':'3', 'X':'3', | |
'A':'4', 'E':'4', 'O':'4', 'Q':'4', | |
'B':'5', 'C':'5', 'F':'5', 'G':'5', 'S':'5', 'Z':'5', |
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
<html> | |
<head> | |
<title>FibTune</title> | |
</head> | |
<body> | |
<h1>FibTune</h1> | |
<p>This program creates a tune using the | |
<a href="http://www.flutetree.com/playing/fibonacci.html" target="_blank">Fibonacci Technique</a> | |
and renders it in NAFTracks Six Hole Font (if installed), in Flutetree.com Songbook |
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 findPairs1(nums, limit) { | |
print "$nums, $limit => " | |
def pairs = [] | |
nums.eachWithIndex { n1, i1 -> | |
nums.eachWithIndex { n2, i2 -> | |
if (i1 != i2 && (n1 + n2) == limit) { | |
pairs << [ n1, n2 ].sort() | |
} | |
} |
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
// See: https://en.wikipedia.org/wiki/Happy_number | |
(1 .. 100).each { n -> | |
println "$n:" | |
def sums = [] | |
while (true) { | |
def squares = (n as String).collect { (it as int) ** 2 } | |
n = squares.sum() | |
println " $squares => $n" + (n == 1 ? " (happy)" : "") |
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 java.net.*; | |
import java.util.*; | |
/** | |
* MailPing is used to test communication with a mail server. | |
* | |
* @author Thornton Rose | |
* @version 1.1 | |
*/ |
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 java.net.*; | |
import java.util.*; | |
import java.text.*; | |
/** | |
* SmtpMailer is used to send mail using SMTP. | |
* | |
* @author Thornton Rose | |
* @version 1.0 |
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 CsvDoc { | |
def doc = [] | |
def setHeader(titles) { | |
doc = [ toCsv(titles) ] + doc | |
} | |
def addRow(values) { | |
doc << toCsv(values) | |
} |
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.text.* | |
class Dates { | |
static final DATE_TIME = "yyyy-MM-dd HH:mm:ss" | |
static final EUROPEAN = "dd/MM/yyyy" | |
static final HSQLDB = "yyyy-MM-dd HH:mm:ss.SSS" | |
static final ISO = "yyyy-MM-dd'T'HH:mm:ss.SSS" | |
static final YEAR_MONTH_DAY = "yyyy-MM-dd" | |
static final YEAR_MONTH_DAY_HOUR_MINUTE = "yyyy-MM-dd (HH:mm)" | |
static final MONTH_DAY_YEAR = "MM/dd/yyyy" |
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 RestClient { | |
def proxy = Proxy.NO_PROXY | |
def basicAuth | |
// ???: Bake this into request()? | |
static def encodePath(path) { | |
path.replaceAll(" ", "%20") | |
} | |
def getContent(String url) { |
OlderNewer