aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md33
-rw-r--r--schmutz.go65
2 files changed, 97 insertions, 1 deletions
diff --git a/README.md b/README.md
index dea35e5..64645ee 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,35 @@
schmutz
=======
-You̇r screen is quiṭe dirty, please cleȧn it.
+Thoughts o̒f dirt sp̒ill over to̒ your unicode enabled ̇tex̒t.̣
+
+Usage:
+
+ --feinstaub
+ spray dust on your text
+
+ --grobe-mettwurst
+ a cookie got mangled in your typewriter
+
+ --nein-nein-nein
+ this is unacceptable
+
+ -p 0.1
+ probability between 0.0 and 1.0
+
+Everything is optional, all options can be combined. If nothing
+is defined, the program defaults to the runes for --feinstaub.
+
+The random number generator is not seeded.
+
+samples
+-------
+
+--nein-nein-nein -p 1.0
+ L⃥o̶r⃥e⃫m⃥ ⃦i̶p⃫s̶u⃓m̷ ̸d⃦o̸l̵o⃥r⃓ ⃫s⃦i̷t⃒ ̷a̷m̸e̵t⃦,⃥ ⃦c̵o⃓n⃥s̵e⃫c⃫t̶e̷t⃓u̷r⃒ ⃫a̷d̸i⃦p⃓i̸s⃒c̸i⃒n̷g̶ ⃒e⃫l̶i⃒t̸.̸ ⃫D⃒o⃒n̷e̸c̵ ⃥a⃒ ̷d⃥i⃫a⃦m̶ ⃥l⃫e⃦c⃓t̶u̶s⃦.̸ ⃒S̵e̶d̷ ⃥s̷i⃥t⃦ ̷a̵m⃒e̷t⃓ ̷i̵p̷s̵u⃦m⃫ ⃥m̸a⃥u̶r̵i̸s̶.̷ ⃥M⃥a̵e̵c̶e̵n̸a⃦s⃥ ⃦c̶o⃓n⃥g⃒u̶e⃥ ⃥l⃓i⃫g̸u⃥l⃒a̸ ̶a⃫c̵ ⃒q⃥u̵a⃒m⃒ ̸v⃥i̵v̵e⃓r⃦r̸a̸ ⃒n̶e̵c⃥ ⃒c̵o̶n̵s̶e⃒c⃓t⃒e̷t̵u̵r⃥ ⃒a̷n⃓t̸e⃦ ⃥h⃒e⃒n⃦d⃥r̵e⃥r⃫i̶t⃓.̵
+
+--grobe-mettwurst -p 0.5
+ Lor̵em̔ ̜i̵p͘su̵m̔ ̜dol͓o͘r si̜t͘ ̵am̜et͓, co͘ns̵ect̵et̔ur͓ ad̔ipi̜s͓c͓in͓g̵ eli͓t.͓ ̵D͓on͓e̜c̔ ͘a̔ d̜i͘am̔ le͓ctus. S̜ed͘ sit am̜et i͘p͓s̵u̵m͘ ̜m̔auri̜s̵.͓ ̔M͓ae͓ce͓n͓a͓s ̔c̵ong̜u̔e̔ l͓igu̔la ̔a̜c q̜u͘a͘m ̵vi͘ve͓rr̜a͘ nec co͓nsec̔te̵tur̵ ante h̔e͘n̜d̔r̔e̵r͘i̔t.
+
+--feinstaub
+ Lorem ipsu̒m dolor s̒it amet, co̒nsectetur adipiscing ėlit̒. ̣Donec̒ a d̒iam lectus. Sed ̒siṭ ̣am̒et ipṡum mauris. Maec̣enas conguẹ ligụla ac quam viv̇ẹr̒ra nec c̣ons̒eċtetur ạnte he̒ndrerit.̒
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
+}