brutalitops 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +19 -0
- data/README +2 -0
- data/bin/brutalitops +87 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3fb7ccf41927b8945bc986b4113072a833500e26ef2e6f4198b777e968ac31d4
|
4
|
+
data.tar.gz: e098e2de80e874745888eefddd0b326284b15fc64afebdb17454baadf712b66d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 31eedc9cfd8f1062ead44a57cf7e627a4fc074e6b4c0c120791fc8f8cd5e183ecaab0a9b1ec1cfdf6e01548b5ec93ac86505b44421f8e5771c4bce0a5645c397
|
7
|
+
data.tar.gz: e021209db9b87e5cb35909cff3442e66b273d778b01adbb101c740c086f725c8435dafdd297531819bc0439a67d78eefb465fe4a6599ed3e29514c7c74bf26d6
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2020 Kevin Tanyag
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README
ADDED
data/bin/brutalitops
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
class Brutalitops
|
4
|
+
|
5
|
+
def initialize(min, max, options=[])
|
6
|
+
alphabet_lowercase = ('a'..'z').to_a
|
7
|
+
alphabet_uppercase = ('A'..'Z').to_a
|
8
|
+
nums = (0..9).to_a
|
9
|
+
specials = [' ', '!', '@', '#', '$', '%','^', '&', '*', '(', ')', '-', '_', '+', '=', '[', ']', '{', '}', '|', '\\', '?', "/", '<', '>', '.', ',', '~', '`']
|
10
|
+
|
11
|
+
@min = min
|
12
|
+
@max = max
|
13
|
+
@selection = []
|
14
|
+
|
15
|
+
if !options.empty?
|
16
|
+
options.each do |option|
|
17
|
+
case option
|
18
|
+
when :alpha_lowercase
|
19
|
+
@selection += alphabet_lowercase
|
20
|
+
when :alpha_uppercase
|
21
|
+
@selection += alphabet_uppercase
|
22
|
+
when :nums
|
23
|
+
@selection += nums
|
24
|
+
when :special_chars
|
25
|
+
@selection += specials
|
26
|
+
else
|
27
|
+
#handle custom array passed in
|
28
|
+
@selection += option
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def print_permutations_to_console(verbose=true)
|
35
|
+
generate_permutations(verbose).each do |permutation|
|
36
|
+
puts permutation
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def print_permutations_to_csv(verbose=true)
|
41
|
+
puts "Generating csv..." if verbose
|
42
|
+
File.open("brutalitops_#{Time.now.strftime("%Y_%m_%d_%H%M%S").to_s}.csv", "w") do |file|
|
43
|
+
generate_permutations(verbose).each do |permutation|
|
44
|
+
file.puts permutation
|
45
|
+
end
|
46
|
+
end
|
47
|
+
puts "Finished generating csv." if verbose
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_array
|
51
|
+
generate_permutations
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def generate_permutations(verbose=false)
|
57
|
+
permutations = []
|
58
|
+
puts "Generating permutations..." if verbose
|
59
|
+
|
60
|
+
@min.upto(@max) do |i|
|
61
|
+
puts "Building permutation with #{i} choices. This might take some time." if verbose
|
62
|
+
temp_arr = @selection.repeated_permutation(i).to_a
|
63
|
+
temp_arr.each {|t| permutations << t.join.to_s}
|
64
|
+
puts "Finished building permutation with #{i} choices." if verbose
|
65
|
+
end
|
66
|
+
|
67
|
+
puts "Finished permutations." if verbose
|
68
|
+
puts "Number of permutations generated: #{permutations.size}" if verbose
|
69
|
+
|
70
|
+
permutations
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
#test things out
|
76
|
+
# def time_it(label)
|
77
|
+
# start_time = Time.now
|
78
|
+
# yield
|
79
|
+
# elapsed_time = Time.now - start_time
|
80
|
+
# puts "#{label} took #{elapsed_time} seconds"
|
81
|
+
# end
|
82
|
+
|
83
|
+
# b = Brutalitops.new(2, 3, [:alpha_lowercase, :special_chars, ['Y', 'N', 'P']])
|
84
|
+
|
85
|
+
# time_it("print_permutations_to_csv") do
|
86
|
+
# b.print_permutations_to_csv
|
87
|
+
# end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brutalitops
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- andydwyer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: "Generates permutations and returns an array, or prints to csv, or prints
|
14
|
+
to console. See https://github.com/andydwyer/brutalitops for usage.\n\n"
|
15
|
+
email: ktanyag@gmail.com
|
16
|
+
executables:
|
17
|
+
- brutalitops
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- LICENSE
|
22
|
+
- README
|
23
|
+
- bin/brutalitops
|
24
|
+
homepage: https://github.com/andydwyer/brutalitops
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.9.2
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubygems_version: 3.0.3
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Generate permutations and convert to array, print to csv, or print to console
|
47
|
+
test_files: []
|