ix-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/VERSION +1 -0
- data/bin/ix +14 -0
- data/bin/ix-acronym +21 -0
- data/bin/ix-add +8 -0
- data/bin/ix-append +8 -0
- data/bin/ix-arguments +12 -0
- data/bin/ix-array +17 -0
- data/bin/ix-ascii +3 -0
- data/bin/ix-avg +18 -0
- data/bin/ix-aws-pass +17 -0
- data/bin/ix-banner +2 -0
- data/bin/ix-base +24 -0
- data/bin/ix-base64-to-image +6 -0
- data/bin/ix-basename +8 -0
- data/bin/ix-bash-to-md +17 -0
- data/bin/ix-bcat +184 -0
- data/bin/ix-bellgrep +17 -0
- data/bin/ix-bench +9 -0
- data/bin/ix-binary-to-text +8 -0
- data/bin/ix-blackbox +45 -0
- data/bin/ix-blackbox-html-table +86 -0
- data/bin/ix-blamer +23 -0
- data/bin/ix-box +35 -0
- data/bin/ix-box2 +3 -0
- data/bin/ix-box3 +3 -0
- data/bin/ix-camel +17 -0
- data/bin/ix-cat +7 -0
- data/bin/ix-catafter +18 -0
- data/bin/ix-catan +6 -0
- data/bin/ix-chain +13 -0
- data/bin/ix-chars +4 -0
- data/bin/ix-checklist +23 -0
- data/bin/ix-child-math +10 -0
- data/bin/ix-chomp +6 -0
- data/bin/ix-chr +6 -0
- data/bin/ix-class +5 -0
- data/bin/ix-columns +41 -0
- data/bin/ix-combinations +11 -0
- data/bin/ix-command-class +21 -0
- data/bin/ix-commandify +22 -0
- data/bin/ix-commit +9 -0
- data/bin/ix-confirm +47 -0
- data/bin/ix-constants +9 -0
- data/bin/ix-cp +10 -0
- data/bin/ix-crack +163 -0
- data/bin/ix-crap +26 -0
- data/bin/ix-crazy-case +9 -0
- data/bin/ix-create-cluster-nodes +15 -0
- data/bin/ix-csv-to-json +16 -0
- data/bin/ix-day +12 -0
- data/bin/ix-debugging +33 -0
- data/bin/ix-decode-base64 +8 -0
- data/bin/ix-dequote +3 -0
- data/bin/ix-df +15 -0
- data/bin/ix-diagram +47 -0
- data/bin/ix-dirname +5 -0
- data/bin/ix-divide +8 -0
- data/bin/ix-done +11 -0
- data/bin/ix-dot-case +15 -0
- data/bin/ix-downcase +5 -0
- data/bin/ix-dto +39 -0
- data/bin/ix-each +7 -0
- data/bin/ix-edit +21 -0
- data/bin/ix-emails +10 -0
- data/bin/ix-escape +8 -0
- data/bin/ix-extensions +3 -0
- data/bin/ix-file-exists +11 -0
- data/bin/ix-filename +7 -0
- data/bin/ix-files +9 -0
- data/bin/ix-first +6 -0
- data/bin/ix-fish-diagram +47 -0
- data/bin/ix-flip-flop +20 -0
- data/bin/ix-flow +22 -0
- data/bin/ix-format-ruby-hash +61 -0
- data/bin/ix-gauge +86 -0
- data/bin/ix-get-colors +520 -0
- data/bin/ix-gift-exchange +52 -0
- data/bin/ix-glitter +29 -0
- data/bin/ix-grep-join +4 -0
- data/bin/ix-group +21 -0
- data/bin/ix-groups +15 -0
- data/bin/ix-gsub +5 -0
- data/bin/ix-gzip-dir +33 -0
- data/bin/ix-hash +10 -0
- data/bin/ix-hashtag +12 -0
- data/bin/ix-hex2rgb +5 -0
- data/bin/ix-histogram +80 -0
- data/bin/ix-hls +21 -0
- data/bin/ix-html +3 -0
- data/bin/ix-human-time +3 -0
- data/bin/ix-hyphen +9 -0
- data/bin/ix-hypothesis +546 -0
- data/bin/ix-ids +10 -0
- data/bin/ix-image-generate +3 -0
- data/bin/ix-image-to-base64 +9 -0
- data/bin/ix-increments +16 -0
- data/bin/ix-indent +42 -0
- data/bin/ix-indent-to-dot +36 -0
- data/bin/ix-int +5 -0
- data/bin/ix-interpolate +5 -0
- data/bin/ix-ips +4 -0
- data/bin/ix-jd +13 -0
- data/bin/ix-join +15 -0
- data/bin/ix-js-classic-functions +9 -0
- data/bin/ix-json-append +17 -0
- data/bin/ix-json-array-to-records +10 -0
- data/bin/ix-json-format +31 -0
- data/bin/ix-json-grep +16 -0
- data/bin/ix-json-interpolate +17 -0
- data/bin/ix-json-key +40 -0
- data/bin/ix-json-key-value +14 -0
- data/bin/ix-json-keys +12 -0
- data/bin/ix-json-merge +11 -0
- data/bin/ix-json-paths +61 -0
- data/bin/ix-json-paths-pretty +2 -0
- data/bin/ix-json-pp +11 -0
- data/bin/ix-json-query +14 -0
- data/bin/ix-json-records-to-array +13 -0
- data/bin/ix-json-remove-key +15 -0
- data/bin/ix-json-replace-values +35 -0
- data/bin/ix-json-template +267 -0
- data/bin/ix-json-to-csv +19 -0
- data/bin/ix-json-to-dot +5 -0
- data/bin/ix-json-to-html-table +84 -0
- data/bin/ix-json-to-ruby-hash +13 -0
- data/bin/ix-json-to-table +21 -0
- data/bin/ix-json-to-table-2 +22 -0
- data/bin/ix-json-to-xml +1 -0
- data/bin/ix-json-values +13 -0
- data/bin/ix-jsonpp +14 -0
- data/bin/ix-lake +6 -0
- data/bin/ix-lemmatize +17 -0
- data/bin/ix-length +6 -0
- data/bin/ix-linkify +35 -0
- data/bin/ix-linkify-html +70 -0
- data/bin/ix-links +3 -0
- data/bin/ix-llp +247 -0
- data/bin/ix-llp-indent +20 -0
- data/bin/ix-llp2 +224 -0
- data/bin/ix-log +44 -0
- data/bin/ix-make-readable +13 -0
- data/bin/ix-man +14 -0
- data/bin/ix-math +6 -0
- data/bin/ix-maze +3 -0
- data/bin/ix-md5 +7 -0
- data/bin/ix-md5s +3 -0
- data/bin/ix-military +39 -0
- data/bin/ix-morse-to-text +76 -0
- data/bin/ix-mr-robot +13 -0
- data/bin/ix-multiply +8 -0
- data/bin/ix-mv +10 -0
- data/bin/ix-ncsa-date-to-timestamp +27 -0
- data/bin/ix-nested-list +23 -0
- data/bin/ix-nnjj +16 -0
- data/bin/ix-noeol +6 -0
- data/bin/ix-noise +7 -0
- data/bin/ix-normalize +69 -0
- data/bin/ix-numbers +4 -0
- data/bin/ix-numerate +16 -0
- data/bin/ix-occurrence +8 -0
- data/bin/ix-open +9 -0
- data/bin/ix-parse +17 -0
- data/bin/ix-pass +17 -0
- data/bin/ix-path +8 -0
- data/bin/ix-path-stats +21 -0
- data/bin/ix-pbcopy +9 -0
- data/bin/ix-pdf +4 -0
- data/bin/ix-percentage +103 -0
- data/bin/ix-permutations +12 -0
- data/bin/ix-pick +4 -0
- data/bin/ix-planning-tickets +27 -0
- data/bin/ix-prefix +7 -0
- data/bin/ix-pretty +3 -0
- data/bin/ix-print-and-run +15 -0
- data/bin/ix-psd-to-json +16 -0
- data/bin/ix-quote +12 -0
- data/bin/ix-rainbow +21 -0
- data/bin/ix-ramp +15 -0
- data/bin/ix-random-hypothesis +10 -0
- data/bin/ix-range +9 -0
- data/bin/ix-remove-colors +519 -0
- data/bin/ix-remove-empty-lines +12 -0
- data/bin/ix-remove-leading-spaces +11 -0
- data/bin/ix-remove-trailing-spaces +11 -0
- data/bin/ix-replace +6 -0
- data/bin/ix-replay +34 -0
- data/bin/ix-retab +13 -0
- data/bin/ix-reverse +5 -0
- data/bin/ix-right +3 -0
- data/bin/ix-rm +8 -0
- data/bin/ix-rot13 +9 -0
- data/bin/ix-rot3 +9 -0
- data/bin/ix-rps +50 -0
- data/bin/ix-ruby-constructor-arguments +7 -0
- data/bin/ix-ruby-methods +40 -0
- data/bin/ix-ruby-options +189 -0
- data/bin/ix-ruby-procs +40 -0
- data/bin/ix-ruby-put-vars +11 -0
- data/bin/ix-ruby-setter-methods +47 -0
- data/bin/ix-ruby-to-json +9 -0
- data/bin/ix-ruler +13 -0
- data/bin/ix-run +105 -0
- data/bin/ix-saldo +25 -0
- data/bin/ix-sat +10 -0
- data/bin/ix-scan +13 -0
- data/bin/ix-scrum +13 -0
- data/bin/ix-scrum-summary +12 -0
- data/bin/ix-sentence +23 -0
- data/bin/ix-sentencify-comments +12 -0
- data/bin/ix-show-tabs +5 -0
- data/bin/ix-show-trailing-spaces +10 -0
- data/bin/ix-shuffle +11 -0
- data/bin/ix-signature +7 -0
- data/bin/ix-size +9 -0
- data/bin/ix-slider +201 -0
- data/bin/ix-snake +25 -0
- data/bin/ix-split +9 -0
- data/bin/ix-stack +42 -0
- data/bin/ix-stack-2 +31 -0
- data/bin/ix-stamp +5 -0
- data/bin/ix-stats +11 -0
- data/bin/ix-stream +15 -0
- data/bin/ix-string-similarity +152 -0
- data/bin/ix-string-similarity2 +35 -0
- data/bin/ix-strip +6 -0
- data/bin/ix-substract +5 -0
- data/bin/ix-success +2 -0
- data/bin/ix-suffix +7 -0
- data/bin/ix-sum +10 -0
- data/bin/ix-swap +3 -0
- data/bin/ix-symlink +13 -0
- data/bin/ix-tab +6 -0
- data/bin/ix-tabify +7 -0
- data/bin/ix-tac +11 -0
- data/bin/ix-task +20 -0
- data/bin/ix-technical +7 -0
- data/bin/ix-template +48 -0
- data/bin/ix-text-to-binary +7 -0
- data/bin/ix-text-to-dot +22 -0
- data/bin/ix-text-to-json +16 -0
- data/bin/ix-text-to-morse +72 -0
- data/bin/ix-tick +20 -0
- data/bin/ix-time +6 -0
- data/bin/ix-times +10 -0
- data/bin/ix-timestamp +79 -0
- data/bin/ix-timestamp-sort +16 -0
- data/bin/ix-timestamp2 +14 -0
- data/bin/ix-title +2 -0
- data/bin/ix-to-f +6 -0
- data/bin/ix-to-i +6 -0
- data/bin/ix-to-sym +6 -0
- data/bin/ix-to_i +6 -0
- data/bin/ix-todo +11 -0
- data/bin/ix-tokenize-for-template +25 -0
- data/bin/ix-transpose +48 -0
- data/bin/ix-tree +19 -0
- data/bin/ix-trim +5 -0
- data/bin/ix-truncate +22 -0
- data/bin/ix-ts +6 -0
- data/bin/ix-tsv-to-json +15 -0
- data/bin/ix-ucwords +11 -0
- data/bin/ix-unescape +8 -0
- data/bin/ix-unhtml +8 -0
- data/bin/ix-upcase +5 -0
- data/bin/ix-url-check +25 -0
- data/bin/ix-urls +46 -0
- data/bin/ix-vim +9 -0
- data/bin/ix-words +9 -0
- data/bin/ix-wrap +10 -0
- data/bin/ix-xy +81 -0
- data/bin/ix-zebra +122 -0
- metadata +597 -0
data/bin/ix-slider
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# TODO: decide if we should load current_value from flag or file override.
|
4
|
+
# TODO: allow user to type numbers to jump to a given part of the slider.
|
5
|
+
|
6
|
+
require 'io/console'
|
7
|
+
require 'timeout'
|
8
|
+
require 'isna'
|
9
|
+
require 'optparse'
|
10
|
+
|
11
|
+
$options = {}
|
12
|
+
|
13
|
+
# $options[:left_arrow] ||= "\e[D"
|
14
|
+
# $options[:right_arrow] ||= "\e[C"
|
15
|
+
$options[:left_arrow] ||= 'h'
|
16
|
+
$options[:right_arrow] ||= 'l'
|
17
|
+
$options[:up_arrow] ||= 'k'
|
18
|
+
$options[:down_arrow] ||= 'j'
|
19
|
+
$options[:bar_width] ||= 40
|
20
|
+
$options[:minimum_value] ||= 0
|
21
|
+
$options[:maximum_value] ||= 100
|
22
|
+
$options[:current_value] ||= 50
|
23
|
+
$options[:running] = true
|
24
|
+
|
25
|
+
OptionParser.new do |opts|
|
26
|
+
|
27
|
+
opts.banner = "Usage: #{File.basename($0)} [OPTIONS]"
|
28
|
+
|
29
|
+
opts.on('-r', '--right-arrow [KEY]', 'Keyboard key to use as a right arrow.') do |value|
|
30
|
+
$options[:right_arrow] = value
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on('-l', '--left-arrow [KEY]', 'Keyboard key to use as a left arrow.') do |value|
|
34
|
+
$options[:left_arrow] = value
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-u', '--up-arrow [KEY]', 'Keyboard key to use as an up arrow.') do |value|
|
38
|
+
$options[:up_arrow] = value
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on('-d', '--down-arrow [KEY]', 'Keyboard key to use as a down arrow.') do |value|
|
42
|
+
$options[:down_arrow] = value
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on('-b', '--bar-width [NUMBER]', 'Number of chars to use for bar the bar width.') do |value|
|
46
|
+
$options[:bar_width] = value.to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('-m', '--minimum-value [NUMBER]', 'Minimum value of slider.') do |value|
|
50
|
+
$options[:minimum_value] = value.to_i
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('-a', '--maximum-value [NUMBER]', 'Maximum value of slider.') do |value|
|
54
|
+
$options[:maximum_value] = value.to_i
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on('-c', '--current-value [NUMBER]', 'Current value of slider.') do |value|
|
58
|
+
$options[:current_value] = value.to_i
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on('-f', '--file [FILE]', 'The filename where the value of slider will be written to.') do |value|
|
62
|
+
$options[:file] = value
|
63
|
+
end
|
64
|
+
|
65
|
+
end.parse!
|
66
|
+
|
67
|
+
required_options = [
|
68
|
+
:left_arrow,
|
69
|
+
:right_arrow,
|
70
|
+
:up_arrow,
|
71
|
+
:down_arrow,
|
72
|
+
:bar_width,
|
73
|
+
:minimum_value,
|
74
|
+
:maximum_value,
|
75
|
+
:current_value,
|
76
|
+
:file
|
77
|
+
]
|
78
|
+
|
79
|
+
required_options.each do |option|
|
80
|
+
unless $options[option]
|
81
|
+
$stderr.puts "Can not run #{option.to_s} was not given."
|
82
|
+
exit 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def readkey
|
87
|
+
c = ''
|
88
|
+
result = ''
|
89
|
+
$stdin.raw do |stdin|
|
90
|
+
c = stdin.getc
|
91
|
+
result << c
|
92
|
+
if c == "\e"
|
93
|
+
begin
|
94
|
+
while (c = Timeout::timeout(0.0001) { stdin.getc })
|
95
|
+
result << c
|
96
|
+
end
|
97
|
+
rescue Timeout::Error
|
98
|
+
# no action required
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
result
|
103
|
+
end
|
104
|
+
|
105
|
+
def legend
|
106
|
+
labels = {
|
107
|
+
$options[:right_arrow] => 'right',
|
108
|
+
$options[:left_arrow] => 'left',
|
109
|
+
$options[:up_arrow] => 'finish',
|
110
|
+
$options[:down_arrow] => 'start',
|
111
|
+
'q' => 'quit'
|
112
|
+
}
|
113
|
+
parts = labels.keys.sort.map do |key|
|
114
|
+
"#{key.to_ansi.green.to_s} = #{labels[key]}"
|
115
|
+
end
|
116
|
+
parts * ', '
|
117
|
+
end
|
118
|
+
|
119
|
+
def print_slider(min, max, needle, open, close, spacer, marker)
|
120
|
+
print open
|
121
|
+
per_abstract_unit = (needle.to_f / max.to_f * $options[:bar_width])
|
122
|
+
print rainbow(marker, per_abstract_unit, $options[:bar_width])
|
123
|
+
print (spacer * ($options[:bar_width] - per_abstract_unit.to_i ))
|
124
|
+
print close
|
125
|
+
print " value: #{needle} "
|
126
|
+
end
|
127
|
+
|
128
|
+
def rainbow(marker, current, max)
|
129
|
+
result = (marker * current)
|
130
|
+
percent = (100 / $options[:bar_width].to_f * current)
|
131
|
+
case percent
|
132
|
+
when 0..25
|
133
|
+
return result
|
134
|
+
when 25..50
|
135
|
+
return result.to_ansi.green.to_s
|
136
|
+
when 50..75
|
137
|
+
return result.to_ansi.yellow.to_s
|
138
|
+
when 75..100
|
139
|
+
return result.to_ansi.red.to_s
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def update_file(file, value)
|
144
|
+
File.open(file, 'w+') do |file|
|
145
|
+
file.puts value
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
$stdout.sync = true
|
150
|
+
puts legend
|
151
|
+
|
152
|
+
if File.exists?($options[:file])
|
153
|
+
$options[:current_value] = File.read($options[:file]).to_i
|
154
|
+
end
|
155
|
+
|
156
|
+
Thread.new do
|
157
|
+
loop do
|
158
|
+
update_file($options[:file], $options[:current_value])
|
159
|
+
sleep 0.5
|
160
|
+
break unless $options[:running]
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
loop do
|
165
|
+
char = readkey
|
166
|
+
if char == 'q'
|
167
|
+
puts 'bye.'
|
168
|
+
$options[:running] = false
|
169
|
+
break
|
170
|
+
end
|
171
|
+
if char == $options[:right_arrow]
|
172
|
+
if ($options[:current_value] + 1) <= $options[:maximum_value]
|
173
|
+
$options[:current_value] += 1
|
174
|
+
end
|
175
|
+
end
|
176
|
+
if char == $options[:left_arrow]
|
177
|
+
if ($options[:current_value] - 1) >= $options[:minimum_value]
|
178
|
+
$options[:current_value] -= 1
|
179
|
+
end
|
180
|
+
end
|
181
|
+
if char == $options[:up_arrow]
|
182
|
+
$options[:current_value] = $options[:maximum_value]
|
183
|
+
end
|
184
|
+
if char == $options[:down_arrow]
|
185
|
+
$options[:current_value] = $options[:minimum_value]
|
186
|
+
end
|
187
|
+
|
188
|
+
print "\b" * 5000
|
189
|
+
|
190
|
+
print_slider(
|
191
|
+
$options[:minimum_value],
|
192
|
+
$options[:maximum_value],
|
193
|
+
$options[:current_value],
|
194
|
+
'[',
|
195
|
+
']',
|
196
|
+
' ',
|
197
|
+
'|'
|
198
|
+
)
|
199
|
+
|
200
|
+
end
|
201
|
+
|
data/bin/ix-snake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
WORDS_REGEX = /\w+/
|
4
|
+
UPPER_CASE_WORDS = /([A-Z])/
|
5
|
+
SPACE_PADDING = /^\s+/
|
6
|
+
STARTS_WITH_UPPERCASE = /\s*[A-Z]/
|
7
|
+
|
8
|
+
starts_with_uppercase = false
|
9
|
+
|
10
|
+
STDIN.each_line do |line|
|
11
|
+
line.chomp!
|
12
|
+
if line =~ STARTS_WITH_UPPERCASE
|
13
|
+
starts_with_uppercase = true
|
14
|
+
end
|
15
|
+
line.gsub!(UPPER_CASE_WORDS, ' \1')
|
16
|
+
padding = line.scan(SPACE_PADDING)[0].to_s
|
17
|
+
words = line.scan(WORDS_REGEX)
|
18
|
+
|
19
|
+
if starts_with_uppercase
|
20
|
+
padding = padding[1..(padding.size - 1)]
|
21
|
+
end
|
22
|
+
|
23
|
+
puts padding + words.map { |word| word.downcase } * '_'
|
24
|
+
end
|
25
|
+
|
data/bin/ix-split
ADDED
data/bin/ix-stack
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ARGV[0]
|
4
|
+
Dir.chdir ARGV[0]
|
5
|
+
end
|
6
|
+
|
7
|
+
STDIN.each do |line|
|
8
|
+
chunks = line.split(':')
|
9
|
+
file = chunks[0]
|
10
|
+
line_number = chunks[1].to_i
|
11
|
+
spacer = file.scan(/^\s*/)[0]
|
12
|
+
file.gsub!(/^\s+/, '')
|
13
|
+
unless File.exists? file
|
14
|
+
puts line
|
15
|
+
next
|
16
|
+
end
|
17
|
+
|
18
|
+
if File.directory? file
|
19
|
+
puts line
|
20
|
+
next
|
21
|
+
end
|
22
|
+
|
23
|
+
puts ''
|
24
|
+
puts line.chomp
|
25
|
+
puts "#{spacer}vim +#{line_number} #{file}"
|
26
|
+
data = File.read(file)
|
27
|
+
counter = 0
|
28
|
+
data.each_line do |line|
|
29
|
+
counter += 1
|
30
|
+
if counter > line_number -10
|
31
|
+
if counter < line_number +10
|
32
|
+
if counter == line_number
|
33
|
+
puts "#{spacer}[0;32;1m" + counter.to_s.rjust(8, ' ') + "| #{line.chomp}[0m"
|
34
|
+
else
|
35
|
+
puts spacer +counter.to_s.rjust(8, ' ') + "| #{line}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
data/bin/ix-stack-2
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'isna'
|
4
|
+
|
5
|
+
STDIN.each_line do |stack_line|
|
6
|
+
filepath, line = stack_line.split(':')
|
7
|
+
puts ''
|
8
|
+
puts '-' * 80
|
9
|
+
puts "file: #{filepath}"
|
10
|
+
puts "line: #{line}"
|
11
|
+
|
12
|
+
line = line.to_i
|
13
|
+
range_left = ((line - 5)..line).to_a
|
14
|
+
range_right = (line..(line + 5)).to_a
|
15
|
+
full_range = (range_left + range_right).sort
|
16
|
+
|
17
|
+
if File.exists?(filepath)
|
18
|
+
file_line = 0
|
19
|
+
File.read(filepath).each_line do |fline|
|
20
|
+
file_line += 1
|
21
|
+
if full_range.include?(file_line)
|
22
|
+
if line == file_line
|
23
|
+
r = "%10.f | %s" % [file_line, fline]
|
24
|
+
puts r.chomp.to_ansi.red.to_s
|
25
|
+
else
|
26
|
+
puts "%10.f | %s" % [file_line, fline]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/bin/ix-stamp
ADDED
data/bin/ix-stats
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
echo "sum\tcount\taverage\tmedian\tmin\tmax"
|
4
|
+
|
5
|
+
sort -n |
|
6
|
+
awk 'BEGIN{c=0;sum=0;}\
|
7
|
+
/^[^#]/{a[c++]=$1;sum+=$1;}\
|
8
|
+
END{ave=sum/c;\
|
9
|
+
if((c%2)==1){median=a[int(c/2)];}\
|
10
|
+
else{median=(a[c/2]+a[c/2-1])/2;}\
|
11
|
+
print sum,"\t",c,"\t",ave,"\t",median,"\t",a[0],"\t",a[c-1]}'
|
data/bin/ix-stream
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
configuration = OpenStruct.new
|
7
|
+
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
|
10
|
+
opts.banner = "Find similarity in a set of strings."
|
11
|
+
opts.separator ''
|
12
|
+
opts.separator "Usage: #{File.basename($0)} [OPTIONS]"
|
13
|
+
opts.separator ''
|
14
|
+
|
15
|
+
configuration.group = false
|
16
|
+
configuration.threshold = 50
|
17
|
+
configuration.summary = false
|
18
|
+
|
19
|
+
description = "Group input in batches and process each individually (faster)"
|
20
|
+
opts.on("-g", "--group", description) do |v|
|
21
|
+
configuration.group = v
|
22
|
+
end
|
23
|
+
|
24
|
+
description = "Limit the number of results by threshold, default is 50"
|
25
|
+
opts.on("-t", "--threshhold [NUMBER]", OptionParser::DecimalNumeric, description) do |v|
|
26
|
+
configuration.threshold = v
|
27
|
+
end
|
28
|
+
|
29
|
+
description = "Print a Summary of the groups found"
|
30
|
+
opts.on("-s", "--summary", description) do |v|
|
31
|
+
configuration.summary = v
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
opts.separator ''
|
36
|
+
|
37
|
+
end.parse!
|
38
|
+
|
39
|
+
# puts configuration.inspect
|
40
|
+
|
41
|
+
class Array
|
42
|
+
def product
|
43
|
+
inject do |cumulative, value|
|
44
|
+
cumulative += value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class String
|
50
|
+
def to_a
|
51
|
+
array = []
|
52
|
+
size.times do |n|
|
53
|
+
array << self[n]
|
54
|
+
end
|
55
|
+
array
|
56
|
+
end
|
57
|
+
|
58
|
+
def scores(other_string)
|
59
|
+
longest_string = nil
|
60
|
+
if other_string.size > self.size
|
61
|
+
longest_string = other_string
|
62
|
+
shortest_string = self
|
63
|
+
else
|
64
|
+
longest_string = self
|
65
|
+
shortest_string = other_string
|
66
|
+
end
|
67
|
+
scores = longest_string.to_a.map do |char|
|
68
|
+
0
|
69
|
+
end
|
70
|
+
shortest_string.size.times do |index|
|
71
|
+
if shortest_string[index] == longest_string[index]
|
72
|
+
scores[index] = 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
scores
|
76
|
+
end
|
77
|
+
|
78
|
+
def similarity(other_string)
|
79
|
+
scores(other_string).product * 100.0 / size
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class TargetString
|
84
|
+
attr_accessor :evaluated
|
85
|
+
attr_accessor :data
|
86
|
+
def to_s
|
87
|
+
data
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# client
|
92
|
+
|
93
|
+
strings = []
|
94
|
+
|
95
|
+
STDIN.each_line do |line|
|
96
|
+
next if line.chomp == ''
|
97
|
+
strings << line.chomp
|
98
|
+
end
|
99
|
+
|
100
|
+
strings.sort! do |n1, n2|
|
101
|
+
n1.size <=> n2.size
|
102
|
+
end
|
103
|
+
|
104
|
+
strings.reverse!
|
105
|
+
|
106
|
+
strings.map! do |string|
|
107
|
+
target_string = TargetString.new
|
108
|
+
target_string.evaluated = false
|
109
|
+
target_string.data = string
|
110
|
+
target_string
|
111
|
+
end
|
112
|
+
|
113
|
+
if configuration.group
|
114
|
+
groups = strings.group_by do |string|
|
115
|
+
string.data.size
|
116
|
+
end
|
117
|
+
else
|
118
|
+
groups = { 0 => strings }
|
119
|
+
end
|
120
|
+
|
121
|
+
counter = 0
|
122
|
+
groups.each do |key, group|
|
123
|
+
group.each do |string_1|
|
124
|
+
counter = 0
|
125
|
+
unless string_1.evaluated
|
126
|
+
if configuration.summary
|
127
|
+
summary_string = string_1.to_s
|
128
|
+
else
|
129
|
+
puts "****>>" + string_1.to_s
|
130
|
+
end
|
131
|
+
end
|
132
|
+
string_1.evaluated = true
|
133
|
+
group.each do |string_2|
|
134
|
+
next if string_2.evaluated
|
135
|
+
similarity = string_1.to_s.similarity(string_2.to_s)
|
136
|
+
scores = string_1.to_s.scores(string_2.to_s).inspect
|
137
|
+
template = "%5.f %s"
|
138
|
+
bindings = [similarity, string_2, scores]
|
139
|
+
if similarity >= configuration.threshold
|
140
|
+
string_2.evaluated = true
|
141
|
+
counter += 1
|
142
|
+
unless configuration.summary
|
143
|
+
puts template % bindings
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
if counter > 0
|
148
|
+
puts "#{counter} #{summary_string}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# http://stackoverflow.com/questions/9822078/ruby-compare-two-strings-similarity-percentage
|
4
|
+
|
5
|
+
def string_difference_percent(a, b)
|
6
|
+
longer = [a.size, b.size].max
|
7
|
+
same = a.each_char.zip(b.each_char).select { |a,b| a == b }.size
|
8
|
+
(longer - same) / a.size.to_f
|
9
|
+
end
|
10
|
+
|
11
|
+
lines = []
|
12
|
+
|
13
|
+
STDIN.each_line do |line|
|
14
|
+
lines.push(line.chomp)
|
15
|
+
end
|
16
|
+
|
17
|
+
scores = {}
|
18
|
+
|
19
|
+
target_line = lines.shift
|
20
|
+
|
21
|
+
puts "00 - Comparing: #{target_line}"
|
22
|
+
|
23
|
+
lines.each do |line|
|
24
|
+
score = string_difference_percent(target_line, line)
|
25
|
+
scores[score] ||= []
|
26
|
+
scores[score].push(line)
|
27
|
+
end
|
28
|
+
|
29
|
+
scores.keys.sort.reverse.each do |score|
|
30
|
+
puts ''
|
31
|
+
scores[score].each do |line|
|
32
|
+
puts "\t#{score} #{line}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/bin/ix-strip
ADDED
data/bin/ix-substract
ADDED
data/bin/ix-success
ADDED
data/bin/ix-suffix
ADDED
data/bin/ix-sum
ADDED
data/bin/ix-swap
ADDED
data/bin/ix-symlink
ADDED
data/bin/ix-tab
ADDED
data/bin/ix-tabify
ADDED
data/bin/ix-tac
ADDED
data/bin/ix-task
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
OK_REGEX = /\s*OK - .*/
|
4
|
+
NG_REGEX = /\s*-- - .*/
|
5
|
+
LEADING_SPACE = /(^\s*)([^\s].*$)/
|
6
|
+
|
7
|
+
STDIN.each_line do |line|
|
8
|
+
line.chomp!
|
9
|
+
if line =~ OK_REGEX
|
10
|
+
line.gsub!('OK - ', '-- - ')
|
11
|
+
puts line
|
12
|
+
next
|
13
|
+
end
|
14
|
+
if line =~ NG_REGEX
|
15
|
+
line.gsub!('-- - ', 'OK - ')
|
16
|
+
puts line
|
17
|
+
next
|
18
|
+
end
|
19
|
+
puts line.gsub(LEADING_SPACE, '\1-- - \2')
|
20
|
+
end
|
data/bin/ix-technical
ADDED
data/bin/ix-template
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
INTERPOLATOR_TOKEN = /%\d+s/
|
6
|
+
|
7
|
+
# puts interpolate(['world', 'other world'], 'hello %1s')
|
8
|
+
def interpolate(values, template)
|
9
|
+
copy = "#{template}"
|
10
|
+
copy.scan(INTERPOLATOR_TOKEN).each do |interpolator|
|
11
|
+
needle = interpolator.scan(/\d+/).first.to_i
|
12
|
+
value = (values[needle - 1] || 'n/a')
|
13
|
+
copy.gsub!(interpolator, value)
|
14
|
+
end
|
15
|
+
copy
|
16
|
+
end
|
17
|
+
|
18
|
+
if ARGV[0]
|
19
|
+
template = "#{ARGV[0]}"
|
20
|
+
if File.exists?(template)
|
21
|
+
template = File.read(template)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
STDIN.each_line do |line|
|
26
|
+
|
27
|
+
if line =~ /\t/
|
28
|
+
values = line.chomp.split(/\t/)
|
29
|
+
else
|
30
|
+
values = line.chomp.split(/\s+/)
|
31
|
+
end
|
32
|
+
|
33
|
+
unless ARGV[1]
|
34
|
+
STDOUT.puts interpolate(values, template)
|
35
|
+
next
|
36
|
+
end
|
37
|
+
|
38
|
+
fname = interpolate(values, ARGV[1])
|
39
|
+
dir = File.dirname(fname)
|
40
|
+
unless File.directory?(dir)
|
41
|
+
# puts "creating #{dir}"
|
42
|
+
FileUtils.mkdir_p(dir)
|
43
|
+
end
|
44
|
+
File.open(fname, 'w+') do |file|
|
45
|
+
file.puts interpolate(values, template)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|