Last active
January 5, 2018 18:55
-
-
Save dave-burke/8e1179e33537b79e100f905c07cf9d67 to your computer and use it in GitHub Desktop.
Generate technobabble (and optionally use them as demo git commit messages)
This file contains hidden or 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
#!/usr/bin/env groovy | |
void usage(){ | |
println """ | |
usage: ${this.class.name}.groovy [-p, -g] [n] | |
Generates technobabble. | |
-p Print n paragraphs instead of n phrases. An optional third | |
argument may be used to specify the number of sentences per | |
paragraph. | |
-g If the -g flag is present, then phrases are used to generate | |
empty commits in the git repository of the current | |
directory. | |
n The number of phrases to generate. Default 1. | |
""" | |
} | |
verbs = [ | |
"Add", | |
"Adjust", | |
"Align", | |
"Calibrate", | |
"Change", | |
"Construct", | |
"Convert", | |
"Correct", | |
"Create", | |
"Deconstruct", | |
"Downgrade", | |
"Encapsulate", | |
"Run a level 1 diagnostic on", | |
"Run a level 2 diagnostic on", | |
"Run a level 3 diagnostic on", | |
"Fix", | |
"Implement", | |
"Investigate", | |
"Optimize", | |
"Patch", | |
"Readjust", | |
"Realign", | |
"Reconstruct", | |
"Refactor", | |
"Reformulate", | |
"Remove", | |
"Scan", | |
"Update", | |
"Upgrade", | |
"Use", | |
] | |
adjectives = [ | |
"ambient", | |
"anomalous", | |
"asymetrical", | |
"astrophysical", | |
"atmospheric", | |
"auxiliary", | |
"electromagnetic", | |
"giga-watt", | |
"inverted", | |
"ionic", | |
"linear", | |
"magnatomic", | |
"magnetic", | |
"microscopic", | |
"modulated", | |
"nucleonic", | |
"optical", | |
"oscillating", | |
"phased", | |
"photonic", | |
"quantum", | |
"rapid", | |
"reciprocating", | |
"scalar", | |
"sonic", | |
"temporal", | |
"thermal", | |
"trans-warp", | |
"unknown", | |
"verteron", | |
] | |
modifiers = [ | |
"alternating ", | |
"anti-matter ", | |
"artificial ", | |
"audio ", | |
"baryon ", | |
"dampening ", | |
"data ", | |
"databanks ", | |
"dithering ", | |
"difussion ", | |
"e-m ", | |
"energy ", | |
"flux ", | |
"frequency ", | |
"fusion ", | |
"gravimetric ", | |
"infusion ", | |
"interface ", | |
"molecular ", | |
"nadion ", | |
"nano-", | |
"neutrino ", | |
"particle ", | |
"phase ", | |
"plasma ", | |
"pulse ", | |
"quantum ", | |
"space-time ", | |
"spatial ", | |
"subspace ", | |
"superficial ", | |
"system ", | |
"tetryon ", | |
"warp ", | |
"wavefront ", | |
] | |
nouns = [ | |
"actuator", | |
"array", | |
"buffer", | |
"capacitor", | |
"conduit", | |
"configuration", | |
"continuum", | |
"controller", | |
"coupling", | |
"discriminator", | |
"distortion", | |
"disturbance", | |
"domain", | |
"effect", | |
"emitter", | |
"emission", | |
"field", | |
"harmonic", | |
"interference", | |
"initiator", | |
"inversion", | |
"matrix", | |
"network", | |
"pathways", | |
"pattern", | |
"phenomenon", | |
"relay", | |
"signal", | |
"singularity", | |
"stream", | |
"variance", | |
] | |
String pick(words){ | |
return words[new Random().nextInt(words.size())] | |
} | |
String babble(){ | |
return "${pick(verbs)} the ${pick(adjectives)} ${pick(modifiers)}${pick(nouns)}" | |
} | |
String paragraph(n = 5){ | |
return (1..n).collect { babble() }.join(". ") + "." | |
} | |
void commit(String message){ | |
StringBuilder out = new StringBuilder() | |
def proc = "git commit --allow-empty -m \"${message}\"".execute() | |
proc.consumeProcessOutput(out, out) | |
proc.waitFor() | |
println out | |
} | |
if(args.length > 0){ | |
if(args[0].isInteger()){ | |
Integer n = args[0] as Integer | |
(1..n).each { print "${babble()}. " } | |
println "" | |
} else if(args.length > 1 && args[1].isInteger()) { | |
Integer n = args[1] as Integer | |
if(args[0] == "-g"){ | |
(1..n).each { commit(babble()) } | |
} else if(args[0] == "-p"){ | |
if(args.length > 2 && args[2].isInteger()){ | |
nSentences = args[2] as Integer | |
} else { | |
nSentences = 5 | |
} | |
(1..n).each { | |
println paragraph(nSentences) | |
println "" | |
} | |
} | |
} else { | |
usage(); | |
} | |
} else { | |
println babble() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output: