typrtail 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +15 -0
- data/bin/typrtail +6 -1
- data/typrtail-0.0.2.gem +0 -0
- data/typrtail.gemspec +1 -1
- metadata +5 -11
- data/pkg/typrtail-0.0.1.gem +0 -0
- data/pkg/typrtail-0.0.1.tgz +0 -0
- data/pkg/typrtail-0.0.1/README.textile +0 -39
- data/pkg/typrtail-0.0.1/Rakefile +0 -10
- data/pkg/typrtail-0.0.1/bin/typrtail +0 -220
- data/pkg/typrtail-0.0.1/typrtail.gemspec +0 -25
- data/typrtail-0.0.1.gem +0 -0
data/README.textile
CHANGED
@@ -18,6 +18,21 @@ h1. Installation
|
|
18
18
|
user@host ~$ gem install typrtail
|
19
19
|
</pre>
|
20
20
|
|
21
|
+
h1. Configuration
|
22
|
+
|
23
|
+
@typrtail@ looks for @$HOME/.typrtailrc@ and if it exists, loads it. This file
|
24
|
+
is plain ruby, you can override any of the parameters any way you like...have
|
25
|
+
it your way.
|
26
|
+
|
27
|
+
<pre>
|
28
|
+
# override some defaults, be faster with more errors!
|
29
|
+
$speed_adjust = 0.35 # was 1.0
|
30
|
+
$typo_prob = 35
|
31
|
+
$min_typo_prob = 15
|
32
|
+
|
33
|
+
# stop more abruptly when we hit a typo
|
34
|
+
$time_to_recognize_typo = 0.4 # was 0.3
|
35
|
+
</pre>
|
21
36
|
|
22
37
|
h1. FAQ
|
23
38
|
|
data/bin/typrtail
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
RC_FILE = "#{ENV['HOME']}/.typrtailrc"
|
4
|
+
|
5
|
+
# to make everything faster, make this <1.0, slower >1.0 HTH
|
4
6
|
$speed_adjust = 1.0
|
5
7
|
|
6
8
|
$rand_base = 10
|
@@ -171,6 +173,9 @@ def erase_typo
|
|
171
173
|
sleep slp
|
172
174
|
end
|
173
175
|
|
176
|
+
|
177
|
+
load RC_FILE if File.exist? RC_FILE
|
178
|
+
|
174
179
|
lastch = ' '
|
175
180
|
chars_since_typeo = 0
|
176
181
|
total_chars = 0
|
data/typrtail-0.0.2.gem
ADDED
Binary file
|
data/typrtail.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typrtail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kyle Burton
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-08-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -29,15 +29,9 @@ extra_rdoc_files: []
|
|
29
29
|
|
30
30
|
files:
|
31
31
|
- bin/typrtail
|
32
|
-
- pkg/typrtail-0.0.1/bin/typrtail
|
33
|
-
- pkg/typrtail-0.0.1/Rakefile
|
34
|
-
- pkg/typrtail-0.0.1/README.textile
|
35
|
-
- pkg/typrtail-0.0.1/typrtail.gemspec
|
36
|
-
- pkg/typrtail-0.0.1.gem
|
37
|
-
- pkg/typrtail-0.0.1.tgz
|
38
32
|
- Rakefile
|
39
33
|
- README.textile
|
40
|
-
- typrtail-0.0.
|
34
|
+
- typrtail-0.0.2.gem
|
41
35
|
- typrtail.gemspec
|
42
36
|
has_rdoc: true
|
43
37
|
homepage: http://github.com/kyleburton/typrtail
|
data/pkg/typrtail-0.0.1.gem
DELETED
Binary file
|
data/pkg/typrtail-0.0.1.tgz
DELETED
Binary file
|
@@ -1,39 +0,0 @@
|
|
1
|
-
h1. typrtail
|
2
|
-
|
3
|
-
Tail or cat a file: make it look like someone is typing them.
|
4
|
-
|
5
|
-
For some processes I was monitoring, this was far more entertaining than just watching a @tail -f@.
|
6
|
-
|
7
|
-
<pre>
|
8
|
-
user@host ~$ tail -f /var/log/messages | typrtail
|
9
|
-
</pre>
|
10
|
-
|
11
|
-
<pre>
|
12
|
-
user@host ~$ wget -q -O - http://www.gutenberg.org/files/730/730.txt | head -n 20 | typrtail
|
13
|
-
</pre>
|
14
|
-
|
15
|
-
h1. Installation
|
16
|
-
|
17
|
-
<pre>
|
18
|
-
user@host ~$ gem install typrtail
|
19
|
-
</pre>
|
20
|
-
|
21
|
-
|
22
|
-
h1. FAQ
|
23
|
-
|
24
|
-
h2. What good is this?
|
25
|
-
|
26
|
-
Come on, it's just for fun.
|
27
|
-
|
28
|
-
h2. Why'd you do this?
|
29
|
-
|
30
|
-
I was overworked and needed an escape.
|
31
|
-
|
32
|
-
h2. Doesn't this already exist?
|
33
|
-
|
34
|
-
Yeah, I'm sure it does, they're probably better too, I needed a break.
|
35
|
-
|
36
|
-
h2. It's too slow, can you make it faster?
|
37
|
-
|
38
|
-
Yes, you can. It's a plain Ruby program, open it up and take a look at the top, there are a lot of constants (yes, globals - *gasp* globals! I know, how awful!) that control things like the typing speed. Have at 'em!
|
39
|
-
|
data/pkg/typrtail-0.0.1/Rakefile
DELETED
@@ -1,220 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# to make everything faster, make this <1.0, sower >1.0 HTH
|
4
|
-
$speed_adjust = 1.0
|
5
|
-
|
6
|
-
$rand_base = 10
|
7
|
-
$rand_range = 100.0
|
8
|
-
|
9
|
-
# 1 in X chance of a typo :D
|
10
|
-
$typo_prob = 50
|
11
|
-
$min_typo_prob = 10
|
12
|
-
$min_slp = 0.02
|
13
|
-
|
14
|
-
# repeated chars are fast
|
15
|
-
$repeat_time = 0.05
|
16
|
-
# typing the same char 2x is fast
|
17
|
-
$same_type_time = 0.075
|
18
|
-
# oops, how fast do you recover from seeing you made one or more typos?
|
19
|
-
$time_to_recognize_typo = 0.3
|
20
|
-
$sleep_after_space = 0.2
|
21
|
-
|
22
|
-
|
23
|
-
# spacebar is wicked quick to hit, so is enter -- unshifted characters are
|
24
|
-
# easier than those that require a shift key...
|
25
|
-
$typing_rates = {
|
26
|
-
" " => 2.0,
|
27
|
-
"\n" => 1.5,
|
28
|
-
"abcdefghijklmnopqrstuvwxyz" => 0.9,
|
29
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" => 0.50,
|
30
|
-
"`1234567890-=[]\\;',./" => 0.60,
|
31
|
-
"~!@#\$%^&*()_+{{}|:\"<>?" => 0.2,
|
32
|
-
}
|
33
|
-
|
34
|
-
# typos are near the character typed :)
|
35
|
-
$typo_table = {
|
36
|
-
"a" => "qwsz",
|
37
|
-
"b" => "ghvn ",
|
38
|
-
"c" => "dfxv ",
|
39
|
-
"d" => "ersfxc",
|
40
|
-
"e" => "34wrsd",
|
41
|
-
"f" => "rtdgcv",
|
42
|
-
"g" => "tyfhvb",
|
43
|
-
"h" => "yugjbn",
|
44
|
-
"i" => "89uojk",
|
45
|
-
"j" => "uihknm,",
|
46
|
-
"k" => "iojlm,",
|
47
|
-
"l" => "opk;,.",
|
48
|
-
"m" => " n,jk",
|
49
|
-
"n" => " bmhj ",
|
50
|
-
"o" => "90ipkl",
|
51
|
-
"p" => "0-o[l;",
|
52
|
-
"q" => "12wsa ",
|
53
|
-
"r" => "45etdf",
|
54
|
-
"s" => "weadzx",
|
55
|
-
"t" => "56ryfg",
|
56
|
-
"u" => "78yihj",
|
57
|
-
"v" => "fgcb ",
|
58
|
-
"w" => "23qeas",
|
59
|
-
"x" => "sdzc ",
|
60
|
-
"y" => "67tugh",
|
61
|
-
"z" => "asx",
|
62
|
-
|
63
|
-
"A" => "aaQWSZ",
|
64
|
-
"B" => "bbGHVN ",
|
65
|
-
"C" => "ccDFXV ",
|
66
|
-
"D" => "ddERSFXC",
|
67
|
-
"E" => "ee\#$WRSD",
|
68
|
-
"F" => "ffRTDGCV",
|
69
|
-
"G" => "ggTYFHVB",
|
70
|
-
"H" => "hhYUGJBN",
|
71
|
-
"I" => "ii*(UOJK",
|
72
|
-
"J" => "jjUIHKNM,",
|
73
|
-
"K" => "kkIOJLM,",
|
74
|
-
"L" => "llOPK:<>",
|
75
|
-
"M" => "mm N<JK",
|
76
|
-
"N" => "nn BMHJ ",
|
77
|
-
"O" => "oo()IPKL",
|
78
|
-
"P" => "pp)_O{L:",
|
79
|
-
"Q" => "qq!@WSA ",
|
80
|
-
"R" => "rr$%ETDF",
|
81
|
-
"S" => "ssWEADZX",
|
82
|
-
"T" => "tt%^RYFG",
|
83
|
-
"U" => "uu&*YIHJ",
|
84
|
-
"V" => "vvFGCB ",
|
85
|
-
"W" => "ww@#QEAS",
|
86
|
-
"X" => "xxSDZC ",
|
87
|
-
"Y" => "yy^&TUGH",
|
88
|
-
"Z" => "zzASX",
|
89
|
-
|
90
|
-
|
91
|
-
"`" => "1",
|
92
|
-
"1" => "`22q",
|
93
|
-
"2" => "1133qw",
|
94
|
-
"3" => "2244we",
|
95
|
-
"4" => "3355er",
|
96
|
-
"5" => "4466rt",
|
97
|
-
"6" => "5577ty",
|
98
|
-
"7" => "6688yu",
|
99
|
-
"8" => "7799ui",
|
100
|
-
"9" => "8800io",
|
101
|
-
"0" => "99-op",
|
102
|
-
"-" => "00=p[",
|
103
|
-
"=" => "-[]",
|
104
|
-
"[" => "-=p];'",
|
105
|
-
"]" => "=[\\'",
|
106
|
-
"\\" => "]",
|
107
|
-
";" => "p[l'./",
|
108
|
-
"'" => "[];/",
|
109
|
-
"," => " m.kl",
|
110
|
-
"." => ",/l;",
|
111
|
-
"/" => ".;'",
|
112
|
-
"~" => "`!",
|
113
|
-
"!" => "11~@Q",
|
114
|
-
"@" => "22!#QW",
|
115
|
-
"\#" => "33@$WE",
|
116
|
-
"$" => "44#%ER",
|
117
|
-
"%" => "55$^RT",
|
118
|
-
"^" => "66%&TY",
|
119
|
-
"&" => "77^*YU",
|
120
|
-
"*" => "88&(UI",
|
121
|
-
"(" => "99*)IO",
|
122
|
-
")" => "00(_OP",
|
123
|
-
"_" => "--)+P{",
|
124
|
-
"+" => "==_{}",
|
125
|
-
"{" => "[[_+P}:\"",
|
126
|
-
"}" => "]]+{|\"",
|
127
|
-
"|" => "\\\}",
|
128
|
-
":" => ";;P{L\">?",
|
129
|
-
"\"" => "''{}:?",
|
130
|
-
"<" => ",,KLM> ",
|
131
|
-
">" => "..<?L:",
|
132
|
-
"?" => "//>:\"",
|
133
|
-
|
134
|
-
" " => " "
|
135
|
-
}
|
136
|
-
|
137
|
-
# keep it real ;)
|
138
|
-
def plausible_typo ch
|
139
|
-
chars = $typo_table[ch.chr]
|
140
|
-
return nil unless chars
|
141
|
-
chars[rand(chars.size)]
|
142
|
-
end
|
143
|
-
|
144
|
-
# Ruby msut have these, just don't know what they are
|
145
|
-
def is_alpha? ch
|
146
|
-
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".include? ch
|
147
|
-
end
|
148
|
-
|
149
|
-
def is_num? ch
|
150
|
-
"0123456789".include? ch
|
151
|
-
end
|
152
|
-
|
153
|
-
# Hammer^H^H^H^H^H^Hpause time
|
154
|
-
def pause_time ch
|
155
|
-
slp = 0.05 + (rand($rand_base) / $rand_range)
|
156
|
-
modifier = $typing_rates.keys.detect do |chars|
|
157
|
-
chars.include? ch
|
158
|
-
end
|
159
|
-
modifier = $typing_rates[modifier] || 0.5
|
160
|
-
slp / modifier
|
161
|
-
end
|
162
|
-
|
163
|
-
# backup, erase, backup (for next char)
|
164
|
-
# NB: should peek, and not do this if next char is a newline b/c this will add
|
165
|
-
# a space before the end of the line...
|
166
|
-
def erase_typo
|
167
|
-
$stderr.putc("\b"[0])
|
168
|
-
$stderr.putc(" "[0])
|
169
|
-
$stderr.putc("\b"[0])
|
170
|
-
slp = pause_time("a"[0]) / 2.0
|
171
|
-
sleep slp
|
172
|
-
end
|
173
|
-
|
174
|
-
lastch = ' '
|
175
|
-
chars_since_typeo = 0
|
176
|
-
total_chars = 0
|
177
|
-
while ch = $stdin.getc
|
178
|
-
total_chars += 1
|
179
|
-
slp = pause_time(ch)
|
180
|
-
# repeated characters are quick
|
181
|
-
if ch == lastch
|
182
|
-
slp = $repeat_time
|
183
|
-
# sequences of the same 'type' are quick
|
184
|
-
elsif is_alpha?(ch) && is_alpha?(lastch)
|
185
|
-
slp = $same_type_time
|
186
|
-
elsif is_num?(ch) && is_num?(lastch)
|
187
|
-
slp = $same_type_time
|
188
|
-
end
|
189
|
-
|
190
|
-
# awww, it gets harder to keep going w/o making a mistake :-)
|
191
|
-
typo_prob = $typo_prob - (chars_since_typeo/2)
|
192
|
-
typo_prob = typo_prob < $min_typo_prob ? $min_typo_prob : typo_prob
|
193
|
-
num_typos = 0
|
194
|
-
while rand(typo_prob) <= 1.0
|
195
|
-
chars_since_typeo = 0
|
196
|
-
typo_prob = $typo_prob
|
197
|
-
typo = plausible_typo ch
|
198
|
-
if typo
|
199
|
-
$stderr.putc typo
|
200
|
-
$stderr.flush
|
201
|
-
num_typos += 1
|
202
|
-
sleep($speed_adjust * $time_to_recognize_typo)
|
203
|
-
end
|
204
|
-
# making a typo makes another one more likely :P
|
205
|
-
typo_prob /= 2.0
|
206
|
-
end
|
207
|
-
num_typos.times { erase_typo }
|
208
|
-
|
209
|
-
# so you made it thorugh the gauntlet? emith the char...
|
210
|
-
lastch = ch
|
211
|
-
slp += Math.sin(total_chars) / 4.0
|
212
|
-
slp = slp < $min_slp ? $min_slp : slp
|
213
|
-
|
214
|
-
sleep($speed_adjust * slp)
|
215
|
-
|
216
|
-
$stdout.putc ch
|
217
|
-
$stdout.flush
|
218
|
-
sleep($speed_adjust * $sleep_after_space) if ' ' == ch.chr
|
219
|
-
chars_since_typeo += 1
|
220
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
|
4
|
-
SPEC = Gem::Specification.new do |s|
|
5
|
-
s.name = "typrtail"
|
6
|
-
s.version = "0.0.2"
|
7
|
-
s.author = "Kyle Burton"
|
8
|
-
s.email = "kyle.burton@gmail.com"
|
9
|
-
s.platform = Gem::Platform::RUBY
|
10
|
-
s.description = <<DESC
|
11
|
-
typrtail is a toy program.
|
12
|
-
|
13
|
-
It simulates a person typing a file, it is suitable to be used in a pipeline.
|
14
|
-
|
15
|
-
user@host ~$ tail -f /var/log/messages | typrtail
|
16
|
-
|
17
|
-
DESC
|
18
|
-
s.summary = "Hey! It looks like you're typing but your fingers aren't moving!"
|
19
|
-
# s.rubyforge_project = "typrtail"
|
20
|
-
s.homepage = "http://github.com/kyleburton/typrtail"
|
21
|
-
s.files = Dir.glob("**/*")
|
22
|
-
s.executables << "typrtail"
|
23
|
-
s.require_path = "bin"
|
24
|
-
s.has_rdoc = false
|
25
|
-
end
|
data/typrtail-0.0.1.gem
DELETED
Binary file
|