-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.rb
149 lines (102 loc) · 2.74 KB
/
home.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
def csv()
# To a file:
require 'csv'
# CSV.open("myfile.csv", "w") do |csv|
# csv << ["row", "of", "CSV", "data"]
# csv << ["another", "row"]
# ...
# end
# rows = [['a1', 'a2', 'a3'],['b1', 'b2', 'b3', 'b4'], ['c1', 'c2', 'c3'], ... ]
# csv_str = rows.inject([]) { |csv, row| csv << CSV.generate_line(row) }.join("")
csv = CSV.new(string_or_io, **options)
# Reading: IO object should be open for read
csv.read # => array of rows
# or
csv.each do |row|
# ...
end
# or
row = csv.shift
# Writing: IO object should be open for write
csv << row
end
csv()
# def home
# # p = {:egg=>1, :bt=>2}
# # puts p['egg']
# # s = Hash.new
# # a = ["aa", "wef"]
# # p.each do |key,value|
# # puts "#{key} #{value}"
# # s << key
# # puts s
# # end
# array = ["apples", "bananas", "coconuts", "watermelons"]
# Hash[*array.reduce([]) { |memo, fruit| memo << fruit << fruit.length }]
# puts Hash
# end
# home()
def signer_keys_and_uids
# sample array
a=["54af642897722e4ccd000002","54af68ab97722e6a57000003", "54c0f02997722e5cc5000003", "54c0f02a97722e5cc5000013", "56cb1f6697722e219a000002", "54af68ab97722e6a57000003", "54af642897722e4ccd000002", "56cb1f6897722e219a000013"]
# make the hash default to 0 so that += will work correctly
b = Hash.new(0)
# iterate over the array, counting duplicate entries
a.each do |v|
b[v] += 1
end
b.each do |k, v|
puts "#{k} appears #{v} times"
end
puts b
# def y x
# x.length
# end
# a = ["asd","wergerggerheth","etherg"].each_with_object({}) do |y, m|
# m[x] = y(x)
# end
# puts a
end
# signer_keys_and_uids()
def extra ()
s = Hash.new
# s = {"elina" => 1}
# s.each_key {|key| puts key }
a = [“aeroplane”, “bird”, “superman”, “desktop”, “documentation”, “board”]
puts a
puts "hi"
# s = Hash.new
# s = {"elina" => 1}
# s.each_key {|key| puts key }
a = [“aeroplane”, “bird”, “superman”, “desktop”, “documentation”, “board”]
puts a
# a.each do |a|
# s[key] << a
# end
# # puts s
# s.each_key {|key| puts key }
###### same count words showing
mapping = Hash.new []
tests = [“aeroplane”, “bird”, “superman”, “desktop”, “documentation”, “board”]
tests.each do |word|
mapping[word.length] += [word]
end
puts mapping
### square
def f g
g * 2
end
t = [1, 2, 3, 4].each_with_object({}) do |g, memo|
memo[g] = f(g)
end
puts t
s = "wergerggerheth"
puts s.length
end
1. gcc
2. xcode-select --install
3. gcc --version
4. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
cf dotfiles
1. sh -c "`curl -fsSL https://raw.github.com/kajisaap/cf.files/master/install.sh`"
2. sh -c "`curl -fsSL https://raw.github.com/kajisaap/cf.files/master/install.sh`" -s ask