aboutsummaryrefslogtreecommitdiffstats
path: root/schmutz.go
diff options
context:
space:
mode:
authorgithubert <ikseno@googlemail.com>2013-12-13 21:13:04 +0100
committergithubert <ikseno@googlemail.com>2013-12-13 21:14:46 +0100
commit5e3c94483ed0897e017af591ba6117cab4952831 (patch)
tree9865ac3aeda0f9b1bda34d394b46d7ad62de9068 /schmutz.go
parentb6464465fda6ffeb40cb2aba013c069da7917b6b (diff)
Even initialer commit
Diffstat (limited to 'schmutz.go')
-rw-r--r--schmutz.go65
1 files changed, 65 insertions, 0 deletions
diff --git a/schmutz.go b/schmutz.go
new file mode 100644
index 0000000..c567ccb
--- /dev/null
+++ b/schmutz.go
@@ -0,0 +1,65 @@
+package main
+
+import (
+ "bufio"
+ "flag"
+ "io"
+ "math/rand"
+ "os"
+)
+
+func main() {
+ small := []rune{'\u0323', '\u0307', '\u0312'}
+ large := []rune{'\u0314', '\u031C', '\u0358', '\u0353', '\u0335'}
+ strikeOut := []rune{'\u0337', '\u0338', '\u0336', '\u0335',
+ '\u20d2', '\u20d3', '\u20e5', '\u20e6', '\u20eb'}
+
+ var useSmall = flag.Bool("feinstaub", false, "spray dust on your text")
+ var useLarge = flag.Bool("grobe-mettwurst", false, "a cookie got mangled in your typewriter")
+ var useStrikeout = flag.Bool("nein-nein-nein", false, "this is unacceptable")
+ var prob = flag.Float64("p", 0.1, "probability between 0.0 and 1.0")
+
+ flag.Parse()
+
+ runes := []rune{}
+
+ if *useSmall {
+ runes = append(runes, small...)
+ }
+
+ if *useLarge {
+ runes = append(runes, large...)
+ }
+
+ if *useStrikeout {
+ runes = append(runes, strikeOut...)
+ }
+
+ if len(runes) == 0 {
+ runes = append(runes, small...)
+ }
+
+ in := bufio.NewReader(os.Stdin)
+
+ for {
+ str, err := in.ReadString('\n')
+
+ if err != nil {
+ break
+ }
+
+ io.WriteString(os.Stdout, mangle(str, runes, *prob))
+ }
+}
+
+func mangle(text string, runes []rune, prob float64) (result string) {
+ for _, rune := range text {
+ result += string(rune)
+
+ if rand.Intn(100) <= int(100.0*prob) {
+ result += string(runes[rand.Intn(len(runes))])
+ }
+ }
+
+ return
+}