Postgres performance issue in my Rails app - ruby-on-rails

I'm using derailed_benchmark gem to track my app performance:
$ PATH_TO_HIT="/api/v2/feed.json?per_page=30&page=1&category_name=Feed" USER_SERVER=webrick TEST_COUNT=20 bundle exec derailed exec perf:stackprof
==================================
Mode: cpu(1000)
Samples: 20708 (0.42% miss rate)
GC: 3219 (15.54%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
4720 (22.8%) 4694 (22.7%) block in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_cache
542 (2.6%) 502 (2.4%) ActiveSupport::Inflector#underscore
413 (2.0%) 413 (2.0%) ActiveSupport::PerThreadRegistry#instance
364 (1.8%) 364 (1.8%) ActiveRecord::QueryMethods#validate_order_args
309 (1.5%) 309 (1.5%) block in ActiveSupport::Inflector#apply_inflections
282 (1.4%) 282 (1.4%) ThreadSafe::NonConcurrentCacheBackend#[]
257 (1.2%) 257 (1.2%) ActiveRecord::Relation#initialize
410 (2.0%) 235 (1.1%) ActiveRecord::Relation#initialize_copy
229 (1.1%) 229 (1.1%) ActiveRecord::Delegation::DelegateCache#relation_delegate_class
212 (1.0%) 212 (1.0%) block in ActiveRecord::Relation::Merger#merge
562 (2.7%) 198 (1.0%) ActiveRecord::QueryMethods#preprocess_order_args
190 (0.9%) 189 (0.9%) ActiveRecord::Core::ClassMethods#arel_table
181 (0.9%) 181 (0.9%) JSON#parse
175 (0.8%) 175 (0.8%) ActiveRecord::Relation#reset
165 (0.8%) 165 (0.8%) ActiveRecord::Attribute#initialize
153 (0.7%) 153 (0.7%) ActiveRecord::Relation#values
151 (0.7%) 151 (0.7%) ActiveRecord::Inheritance::ClassMethods#base_class
333 (1.6%) 151 (0.7%) ActiveRecord::Scoping::Default::ClassMethods#build_default_scope
144 (0.7%) 144 (0.7%) Skylight::Normalizers::ActiveRecord::SQL#extract_rust
142 (0.7%) 142 (0.7%) ActiveRecord::QueryMethods#joins_values
138 (0.7%) 138 (0.7%) block (4 levels) in Class#class_attribute
195 (0.9%) 133 (0.6%) ActiveRecord::DynamicMatchers#respond_to?
158 (0.8%) 121 (0.6%) ActiveRecord::QueryMethods#where_values=
125 (0.6%) 115 (0.6%) ActiveRecord::Reflection::AssociationReflection#klass
113 (0.5%) 113 (0.5%) ActiveRecord::Result#initialize_copy
110 (0.5%) 110 (0.5%) Arel::Table#initialize
193 (0.9%) 109 (0.5%) ActiveRecord::ConnectionAdapters::PostgreSQL::Utils#extract_schema_qualified_name
114 (0.6%) 106 (0.5%) Arel::Nodes::Binary#hash
104 (0.5%) 104 (0.5%) ActiveRecord::QueryMethods#extending_values
99 (0.5%) 99 (0.5%) ActiveRecord::QueryMethods#order_values
How can I fix the "block in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_cache" performance issue?
UPDATE
After running same command with "config.middleware.delete "ActiveRecord::QueryCache" in my config/application.rb
the results are:
==================================
Mode: cpu(1000)
Samples: 21116 (0.42% miss rate)
GC: 2213 (10.48%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
5619 (26.6%) 5600 (26.5%) block in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_cache
2268 (10.7%) 2268 (10.7%) block in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_no_cache
421 (2.0%) 383 (1.8%) ActiveSupport::Inflector#underscore
304 (1.4%) 304 (1.4%) ActiveSupport::PerThreadRegistry#instance
294 (1.4%) 294 (1.4%) block in ActiveSupport::Inflector#apply_inflections
270 (1.3%) 270 (1.3%) ThreadSafe::NonConcurrentCacheBackend#[]
245 (1.2%) 245 (1.2%) ActiveRecord::Relation#initialize
229 (1.1%) 229 (1.1%) ActiveRecord::QueryMethods#validate_order_args
219 (1.0%) 219 (1.0%) ActiveRecord::Delegation::DelegateCache#relation_delegate_class
207 (1.0%) 207 (1.0%) ActiveRecord::Inheritance::ClassMethods#base_class
285 (1.3%) 188 (0.9%) ActiveRecord::Relation#initialize_copy
184 (0.9%) 184 (0.9%) ActiveRecord::Attribute#initialize
181 (0.9%) 179 (0.8%) ActiveRecord::Core::ClassMethods#arel_table
175 (0.8%) 175 (0.8%) Skylight::Normalizers::ActiveRecord::SQL#extract_rust
165 (0.8%) 165 (0.8%) block in ActiveRecord::Relation::Merger#merge
147 (0.7%) 147 (0.7%) block (4 levels) in Class#class_attribute
374 (1.8%) 145 (0.7%) ActiveRecord::QueryMethods#preprocess_order_args
113 (0.5%) 113 (0.5%) ActiveRecord::Relation#values
112 (0.5%) 112 (0.5%) ActiveRecord::QueryMethods#joins_values
171 (0.8%) 109 (0.5%) ActiveRecord::ConnectionAdapters::PostgreSQL::Utils#extract_schema_qualified_name
99 (0.5%) 99 (0.5%) Arel::Table#initialize
97 (0.5%) 97 (0.5%) ActiveRecord::Relation#reset
271 (1.3%) 96 (0.5%) ActiveRecord::Scoping::Default::ClassMethods#build_default_scope
107 (0.5%) 95 (0.4%) ActiveRecord::Reflection::AssociationReflection#klass
93 (0.4%) 93 (0.4%) ActiveRecord::QueryMethods#order_values
125 (0.6%) 93 (0.4%) ActiveRecord::QueryMethods#where_values=
88 (0.4%) 88 (0.4%) ActiveRecord::Reflection::ThroughReflection#active_record
106 (0.5%) 87 (0.4%) Skylight::Trace#start
81 (0.4%) 81 (0.4%) ActiveRecord::QueryMethods#check_cached_relation
80 (0.4%) 80 (0.4%) ActiveRecord::QueryMethods#where_values
UDPATE 2
After running the query with "wall time" mode and not "cpu time" mode, this is the results:
==================================
Mode: wall(1000)
Samples: 41424 (1.92% miss rate)
GC: 3648 (8.81%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
4780 (11.5%) 4718 (11.4%) block in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_cache
2783 (6.7%) 2783 (6.7%) block in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_no_cache
1088 (2.6%) 1088 (2.6%) ActiveSupport::PerThreadRegistry#instance
934 (2.3%) 934 (2.3%) ThreadSafe::NonConcurrentCacheBackend#[]
1031 (2.5%) 926 (2.2%) ActiveSupport::Inflector#underscore
739 (1.8%) 739 (1.8%) block in ActiveSupport::Inflector#apply_inflections
626 (1.5%) 626 (1.5%) ActiveRecord::Relation#initialize
589 (1.4%) 589 (1.4%) ActiveRecord::Delegation::DelegateCache#relation_delegate_class
577 (1.4%) 577 (1.4%) ThreadSafe::NonConcurrentCacheBackend#get_or_default
549 (1.3%) 549 (1.3%) ActiveRecord::Attribute#initialize
497 (1.2%) 497 (1.2%) block in ActiveRecord::Relation::Merger#merge
497 (1.2%) 497 (1.2%) ActiveRecord::QueryMethods#validate_order_args
702 (1.7%) 424 (1.0%) ActiveRecord::Relation#initialize_copy
419 (1.0%) 417 (1.0%) ActiveRecord::Core::ClassMethods#arel_table
384 (0.9%) 384 (0.9%) ActiveRecord::Inheritance::ClassMethods#base_class
383 (0.9%) 383 (0.9%) block (4 levels) in Class#class_attribute
358 (0.9%) 358 (0.9%) Skylight::Normalizers::ActiveRecord::SQL#extract_rust
329 (0.8%) 329 (0.8%) ActiveRecord::Base.logger
321 (0.8%) 321 (0.8%) rescue in Net::BufferedIO#rbuf_fill
315 (0.8%) 315 (0.8%) ActiveRecord::Core#update_attributes_from_transaction_state
314 (0.8%) 314 (0.8%) ActiveRecord::ConnectionAdapters::AbstractAdapter#type_map
795 (1.9%) 298 (0.7%) ActiveRecord::QueryMethods#preprocess_order_args
284 (0.7%) 284 (0.7%) Arel::Table#initialize
279 (0.7%) 279 (0.7%) ActiveRecord::Relation#values
278 (0.7%) 278 (0.7%) ActiveRecord::Relation#reset
734 (1.8%) 264 (0.6%) ActiveRecord::Scoping::Default::ClassMethods#build_default_scope
263 (0.6%) 263 (0.6%) ActiveRecord::QueryMethods#joins_values
394 (1.0%) 258 (0.6%) ActiveRecord::ConnectionAdapters::PostgreSQL::Utils#extract_schema_qualified_name
15323 (37.0%) 249 (0.6%) ActiveRecord::Querying#find_by_sql
257 (0.6%) 246 (0.6%) ActiveRecord::Reflection::AssociationReflection#klass
I'm building my feed.json using index.json.jbuilder, this is how it looks:
json.battles #battles do |battle|
if (battle.products.size == 2)
battle_results = battle.calculate_results
json.(battle, :id)
vote = battle.votes.find_by(user_id: current_user.id)
json.voted vote.present?
if vote
json.product_voted vote.product.id == battle.products[0].id ? "first" : "second"
end
json.mybattle battle.try(:user).try(:id) == current_user.id
json.user do
username = ""
if (battle.try(:user).try(:nickname).present?)
username = battle.try(:user).try(:nickname)
else
username = battle.try(:user).try(:name).try(:downcase).try(:delete,' ')
end
json.username username
json.user_id battle.try(:user_id)
json.profile_image battle.try(:user).try(:image) || ""
json.full_name battle.try(:user).try(:name) || ""
end
json.votes battle_results[:votes]
json.created_at time_ago_in_words(battle.created_at) + " ago"
json.title battle.title
json.first_product do
first_product = battle.products[0]
json.id first_product.id
json.voted first_product.votes.find_by(user_id: current_user.id).present?
json.percentage battle_results[:percentage_product_one]
# json.percentage_after_voting battle_results[:percentage_after_voting_product_one]
json.name first_product.name
json.price SearchFunctions.convert_currency(first_product.price.to_s, current_user.currency_code, 'USD')
# json.price first_product.price.to_s
json.url first_product.url
if first_product.images["sub"] && first_product.images["sub"].kind_of?(Array)
first_product.images["sub"] = first_product.images["sub"].first(10)
end
json.images first_product.images
json.manufacturer first_product.manufacturer
json.description first_product.description
json.is_user_saved first_product.saved_products.find_by(user_id: current_user.id).present?
json.saved_count first_product.saved_products.length
end
json.second_product do
second_product = battle.products[1]
json.id second_product.id
json.voted second_product.votes.find_by(user_id: current_user.id).present?
json.percentage battle_results[:percentage_product_two]
# json.percentage_after_voting battle_results[:percentage_after_voting_product_two]
json.name second_product.name
json.price SearchFunctions.convert_currency(second_product.price.to_s, current_user.currency_code, 'USD')
# json.price second_product.price.to_s
json.url second_product.url
if second_product.images["sub"] && second_product.images["sub"].kind_of?(Array)
second_product.images["sub"] = second_product.images["sub"].first(10)
end
json.images second_product.images
json.manufacturer second_product.manufacturer
json.description second_product.description
json.is_user_saved second_product.saved_products.find_by(user_id: current_user.id).present?
json.saved_count second_product.saved_products.length
end
end
end

Well, this may be silly answer, but you probably should decrease or optimise number of queries executed during building feed.json. Check for N+1 queries, for example maybe you are loading author for each feed item or something like that.
You can use bullet gem to help you find N+1 queries. And you can fix those by adding includes to your queries.
Update Based on json view.
It is pretty big json and it looks like you use a lot of models from your application. BY looking at this it is impossible to give you any clear guidelines on how to optimise this. You should probably paste your whole app here, but I think that's not appropriate for SO.
For sure there is a lot space for improvement on database side, but I think your best and easiest way is to just cache this view. By caching I mean using fragment caching for each separate battle.
json.battles #battles do |battle|
if (battle.products.size == 2)
json.cache! "#{battle.id}/#{battle.updated_at}" do
battle_results = battle.calculate_results
json.(battle, :id)
vote = battle.votes.find_by(user_id: current_user.id)
json.voted vote.present?
if vote
json.product_voted vote.product.id == battle.products[0].id ? "first" : "second"
end
json.mybattle battle.try(:user).try(:id) == current_user.id
json.user do
username = ""
if (battle.try(:user).try(:nickname).present?)
username = battle.try(:user).try(:nickname)
else
username = battle.try(:user).try(:name).try(:downcase).try(:delete,' ')
end
json.username username
json.user_id battle.try(:user_id)
json.profile_image battle.try(:user).try(:image) || ""
json.full_name battle.try(:user).try(:name) || ""
end
json.votes battle_results[:votes]
json.created_at time_ago_in_words(battle.created_at) + " ago"
json.title battle.title
json.first_product do
first_product = battle.products[0]
json.id first_product.id
json.voted first_product.votes.find_by(user_id: current_user.id).present?
json.percentage battle_results[:percentage_product_one]
# json.percentage_after_voting battle_results[:percentage_after_voting_product_one]
json.name first_product.name
json.price SearchFunctions.convert_currency(first_product.price.to_s, current_user.currency_code, 'USD')
# json.price first_product.price.to_s
json.url first_product.url
if first_product.images["sub"] && first_product.images["sub"].kind_of?(Array)
first_product.images["sub"] = first_product.images["sub"].first(10)
end
json.images first_product.images
json.manufacturer first_product.manufacturer
json.description first_product.description
json.is_user_saved first_product.saved_products.find_by(user_id: current_user.id).present?
json.saved_count first_product.saved_products.length
end
json.second_product do
second_product = battle.products[1]
json.id second_product.id
json.voted second_product.votes.find_by(user_id: current_user.id).present?
json.percentage battle_results[:percentage_product_two]
# json.percentage_after_voting battle_results[:percentage_after_voting_product_two]
json.name second_product.name
json.price SearchFunctions.convert_currency(second_product.price.to_s, current_user.currency_code, 'USD')
# json.price second_product.price.to_s
json.url second_product.url
if second_product.images["sub"] && second_product.images["sub"].kind_of?(Array)
second_product.images["sub"] = second_product.images["sub"].first(10)
end
json.images second_product.images
json.manufacturer second_product.manufacturer
json.description second_product.description
json.is_user_saved second_product.saved_products.find_by(user_id: current_user.id).present?
json.saved_count second_product.saved_products.length
end
end
end
end
I added some code at line 3. I just wrote this out of my head, I am not exactly sure if syntax is 100% correct, but it should give you a hint. Also remember that caching is not enabled in development environment. To enable it you need to set config.action_controller.perform_caching = true in config/environments/developement.rb

Related

How to overcome with this error when using Networkx's kernighan_lin_bisection

I want to use kernighan_lin_bisection from Networkx to separate a network data.
But the error below showed up and I'm stuck.
It would be highly appreciated if you could help me overcome this error.
QT-------------------------------------------------------------------------
IndexError Traceback (most recent call last)
in ()
17 for c in init_partition:
18 for n in c:
---> 19 color_map_i[n]=colors[counter]
20 counter=counter+1
21
IndexError: list assignment index out of range
UNQT---------------------------------------------------------------------------
The coding I used and data source"200224_04_act.prn" are below.
QT---------------------------------------------------
G=nx.read_edgelist("200224_04_act.prn",nodetype=int)
colors=["red","blue","green"]
pos=nx.spring_layout(G)
init_nodes=np.array_split(G.nodes(),2)
init_partition=[set(init_nodes[0]),set(init_nodes[1])]
print(init_partition)
from networkx.algorithms.community import kernighan_lin_bisection
color_map_i=["black"]*nx.number_of_nodes(G)
print(color_map_i)
counter=0
for c in init_partition:
for n in c:
color_map_i[n]=colors[counter]
counter=counter+1
print(color_map_i)
nx.draw_networkx_edges(G,pos)
nx.draw_networkx_nodes(G,pos,node_color=color_map_i)
nx.draw_networkx_labels(G,pos)
plt.axis("off")
plt.show()
lst_b=kernighan_lin_bisection(G,partition=init_partition)
color_map_b=["black"]*nx.number_of_nodes(G)
counter=0
for c in lst_b:
for n in c:
color_map_b[n]=colors[counter]
counter=counter+1
nx.draw_networkx_edges(G,pos)
nx.draw_networkx_nodes(G,pos,node_color=color_map_b)
nx.draw_networkx_labels(G,pos)
plt.axis("off")
plt.show()
UNQT--------------------------------------------------------------
"200224_04_act.prn" below.(Number of nodes is around 2000 but I made it
small due to the limit of number of character)
1 415
2 415
3 415
3 1350
4 1351
5 1352
6 383
7 993
8 1353
9 887
10 887
11 887
12 887
13 887
14 1185
15 1185
16 1185
17 1185
18 1185
19 1146
20 1146
21 1146
22 1146
21 776
23 776
24 707
25 707
26 707
27 707
28 707
29 754
21 754
30 754
31 754
32 754
33 778
34 778
35 778
36 778
37 778
38 859
39 859
40 1354
41 563
42 563
43 563
44 563
45 563
46 1209
47 1209
48 1209
49 1209
50 1209
51 715
52 715
53 715
54 715
55 715
56 1048
57 1048
58 1047
59 1047
60 1047
61 1047
62 1047
63 718
64 718
65 718
66 718
67 718
68 947
17 947
69 947
70 889
71 744
72 744
73 744
74 744
75 744
76 1137
77 1137
78 1137
79 1137
80 612
81 612
82 612
83 612
17 612
84 790
85 790
86 790
87 790
88 790
89 922
90 922
91 922
92 922
93 922
21 738
94 738
95 738
96 738
97 738
98 1355
81 807
99 807
17 807
100 725
101 725
17 725
102 725
103 725
23 1046
104 661
105 661
106 661
107 661
108 661
109 907
110 907
111 907
112 907
113 907
114 840
115 840
116 840
117 840
17 840
118 759
23 759
119 759
23 761
120 761
121 761
122 761
123 1356
124 1265
125 1265
126 1265
127 1265
128 1265
129 894
29 894
130 894
131 894
132 667
133 667
124 758
134 758
135 758
122 758
136 758
137 471
138 471
You've got
for c in init_partition:
for n in c:
color_map_i[n]=colors[counter]
counter=counter+1
It looks to me like n will loop over all of the nodes of the graph. I do not see any entries in the graph that are 0. So probably the nodes are numbered 1 to N, while color_map_i is indexed from 0 to N-1. So it would break when n=N.
A good way to hunt for bugs like this in general would be to print n right before the line giving the error. This would give a hint to what the problem is.

Why does calcHist in Opencv produce 0 array in output?

I do hist calculation using OpenCV. I have the following implementation.
//Check image
for (int i = 0; i < block.rows; i++)
{
unsigned char *ptr = block.ptr<unsigned char>(i);
for (int j = 0; j < block.cols; j++)
{
cout << (int)ptr[j] << " ";
}
cout << endl;
}
//That gave
240 130 176 129 96 122 192 127 240 123 112 122 64 121 80 118 128 129 224 119
160 138 176 132 144 128 144 132 64 128 64 126 16 128 16 129 112 126 64 127
128 128 96 133 240 124 240 132 96 126 32 124 144 128 144 129 176 128 144 124
0 136 112 136 80 131 64 131 16 132 48 131 0 128 224 129 240 126 144 129
16 132 240 138 160 132 64 134 16 131 112 129 208 126 0 128 16 126 176 122
208 139 176 133 176 135 240 138 176 136 80 131 128 133 192 132 64 129 144 132
32 136 176 138 224 139 224 136 80 127 160 135 144 132 64 131 192 131 48 126
80 144 192 138 16 136 192 138 240 135 112 135 32 133 208 132 32 130 64 130
144 141 144 135 48 139 32 135 32 134 112 134 80 130 160 126 144 131 96 128
80 144 208 139 112 141 16 137 96 138 48 134 0 136 96 137 32 135 192 130
208 143 224 140 64 140 240 132 224 132 96 133 160 133 96 134 0 129 96 131
128 148 144 140 128 139 96 139 32 136 48 135 80 132 96 137 0 133 240 140
208 136 96 144 64 137 144 135 16 135 16 132 0 134 160 136 128 134 128 132
240 147 176 144 160 138 176 144 176 139 160 143 224 135 128 137 96 139 160 136
176 139 144 133 240 142 192 139 112 133 112 135 208 131 208 132 128 135 48 133
32 150 0 144 128 139 0 141 64 142 32 136 16 137 112 136 16 137 48 133
128 143 0 141 48 141 192 135 128 144 16 138 80 136 192 134 16 134 160 131
0 144 144 148 16 143 48 136 144 140 144 138 160 136 192 137 80 138 160 136
16 142 32 141 192 140 160 135 32 136 192 135 192 135 240 135 48 138 0 143
208 142 96 149 160 146 208 146 32 138 192 141 112 136 208 138 96 142 160 137
128 145 64 142 16 136 0 137 144 132 32 136 96 138 48 136 240 131 208 130
48 142 128 143 128 143 160 149 208 140 16 142 176 137 208 136 240 138 0 143
192 146 160 141 112 144 96 143 112 135 224 140 96 135 176 135 80 135 128 135
48 144 224 147 0 139 48 139 128 142 224 143 0 144 80 140 16 139 192 140
0 146 160 143 176 138 160 146 240 135 128 136 176 137 192 134 192 136 112 136
208 147 16 143 80 149 112 146 224 134 16 145 48 141 224 138 128 137 112 135
64 146 0 140 192 140 0 143 208 140 96 138 128 137 176 138 208 138 48 135
64 148 224 142 16 140 64 143 112 137 64 141 64 143 224 135 80 138 80 138
240 143 240 142 64 145 0 142 208 142 128 139 0 136 240 141 48 138 80 137
64 147 32 148 112 145 80 140 64 143 112 144 0 139 112 137 176 136 80 143
48 148 64 146 144 142 160 139 176 140 0 140 144 139 32 138 80 137 112 139
208 145 192 145 96 148 240 145 128 139 16 141 80 142 224 137 16 144 208 140
240 142 96 139 176 148 16 139 96 143 16 141 32 139 176 141 48 134 192 141
128 147 64 145 80 150 112 140 112 143 240 142 96 143 224 139 192 143 144 137
0 148 80 145 128 142 48 146 160 140 32 141 192 139 16 136 176 138 16 143
48 149 80 143 80 144 112 144 64 144 208 143 96 142 192 142 240 138 48 138
192 143 48 149 176 145 176 142 64 142 160 139 16 138 128 139 64 139 192 138
192 147 224 144 64 143 64 148 0 144 96 143 32 147 208 142 64 141 224 137
112 146 208 144 96 141 64 142 208 141 112 138 144 138 80 135 16 140 176 140
208 146 96 144 112 148 112 146 112 147 192 148 16 141 32 143 224 137 80 140
128 149 96 146 224 144 32 141 240 144 112 136 192 141 64 139 96 135 144 138
160 144 80 149 208 146 96 145 128 142 64 142 64 147 208 141 144 141 16 141
48 145 192 145 32 140 176 142 0 143 96 136 160 139 80 136 192 138 96 138
32 151 224 152 208 143 112 142 0 142 144 145 176 145 0 139 240 141 32 139
112 142 0 139 176 136 64 140 128 140 64 135 64 139 128 140 64 137 96 138
128 150 0 153 32 146 208 140 80 149 240 141 240 136 224 140 160 140 32 146
240 141 160 142 192 144 208 138 112 141 144 138 128 138 48 135 176 140 16 135
96 150 176 148 80 142 224 142 16 148 208 140 240 136 224 141 32 140 144 137
192 139 0 144 64 142 144 143 32 139 192 138 160 139 208 137 80 140 96 134
48 148 192 146 16 149 0 141 144 137 32 140 192 142 176 138 240 140 16 138
80 146 144 142 80 143 192 137 224 141 176 140 80 139 128 138 64 135 144 134
160 146 208 143 160 143 0 145 112 140 224 144 208 142 80 144 0 138 144 142
144 143 48 139 32 141 0 147 16 140 0 143 176 140 128 133 176 139 160 134
176 150 240 145 64 146 144 142 96 138 240 141 128 141 112 140 128 137 160 135
176 140 128 139 224 144 160 138 208 138 224 135 48 139 208 132 160 137 96 134
208 143 112 148 0 141 96 143 96 136 32 143 176 138 240 139 160 141 176 141
176 148 176 142 112 140 16 143 96 136 80 139 240 139 144 138 160 139 160 137
96 145 32 151 224 142 96 143 48 143 96 141 112 135 48 141 240 136 80 138
80 145 0 140 64 141 48 144 32 141 208 137 80 136 192 134 32 135 16 137
64 147 48 148 240 143 208 139 112 140 240 138 176 141 32 144 64 138 64 139
160 142 208 141 160 142 48 140 208 138 80 136 160 137 48 141 224 137 96 134
64 149 48 147 32 142 80 148 176 142 192 142 208 138 48 139 112 136 64 139
144 144 96 143 240 140 240 138 160 140 0 140 0 135 208 133 32 134 192 132
80 143 0 145 128 140 48 143 208 141 96 143 96 139 192 138 0 139 112 140
96 144 80 140 64 144 32 141 192 137 32 138 176 137 80 137 80 138 0 136
64 147 144 145 208 140 64 138 144 145 224 137 48 140 0 140 96 139 192 134
64 141 208 143 128 144 80 135 192 135 112 139 176 135 128 139 144 135 128 134
80 145 32 146 80 142 64 143 192 143 176 140 224 142 112 141 32 139 144 141
96 141 64 141 240 143 224 136 48 142 160 132 192 136 160 136 64 137 32 134
224 147 192 144 96 145 16 140 192 142 128 138 0 141 0 145 176 136 96 140
128 146 16 143 160 139 176 141 192 138 208 137 48 141 160 129 96 137 144 134
112 145 32 146 208 135 240 139 240 137 192 142 176 132 96 138 144 131 16 140
64 143 112 141 112 142 0 140 160 141 0 135 240 136 224 141 112 137 64 134
160 144 80 143 160 145 192 141 96 135 80 140 240 134 224 138 48 137 176 137
64 140 80 138 0 138 64 136 48 136 128 133 16 133 224 132 80 135 224 133
224 142 16 146 80 145 224 137 144 138 160 138 160 132 64 137 112 133 0 135
224 140 80 141 0 138 112 135 0 132 144 136 240 131 112 137 208 133 0 135
16 143 32 139 32 142 160 138 96 133 128 136 112 132 16 136 176 133 112 136
96 141 0 138 96 133 176 136 112 133 176 136 240 126 0 131 16 127 80 130
112 142 160 138 0 136 16 140 192 132 48 138 64 136 176 135 208 130 160 140
So pixel values are there.
//Histogram calculation
int histbin = 128;//quantize
int histSize[] = { histbin };
float range[] = { 0, 255 };
const float *ranges[] = { range };
Mat hist;
int channels[] = { 0};
calcHist(&block, 1, channels, Mat(), hist, 1, histSize, ranges, true, false);
//Print output
for (int h = 0; h < histbin; h++)
{
float binVal = hist.at<float>(h);
cout << " " << binVal;
}
I have outputs as follow.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
What is wrong with my implementation?

can't run "rails server" on windows 7

I am just One hour new to ROR. I am getting trained by the "Lynda.com Ruby on Rails 4 Essential Training". And after installing all the components, I am unable to start the web server. What I do is the following:-
////////////////////////This is what i get after i type "rails server" in command prompt /////////////
port/descendants_tracker.rb
415 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/callbacks.rb
416 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.1.5/lib/active_reco
rd/connection_adapters/abstract_adapter.rb
417 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.1.5/lib/active_reco
rd/scoping.rb
418 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.1.5/lib/active_reco
rd.rb
419 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activemodel-4.1.5/lib/active_model
/railtie.rb
420 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/module/attr_internal.rb
421 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/module/anonymous.rb
422 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/abstract_cont
roller.rb
423 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_dispat
ch/http/filter_redirect.rb
424 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/request.rb
425 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/response.rb
426 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_dispat
ch/http/cache.rb
427 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_dispat
ch/http/response.rb
428 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/json/decoding.rb
429 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/json/encoding.rb
430 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/json.rb
431 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_contro
ller/metal/live.rb
432 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/hash_with_indifferent_access.rb
433 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/hash/indifferent_access.rb
434 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/rescuable.rb
435 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_dispat
ch/http/upload.rb
436 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/mock_sess
ion.rb
437 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/test/cook
ie_jar.rb
438 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/test/mock
_digest_request.rb
439 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/test/util
s.rb
440 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/test/meth
ods.rb
441 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/test/uplo
aded_file.rb
442 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/test.rb
443 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_contro
ller/metal/strong_parameters.rb
444 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/load_error.rb
445 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/name_error.rb
446 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/uri.rb
447 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_contro
ller.rb
448 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/abstract_cont
roller/railties/routes_helpers.rb
449 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_contro
ller/railties/helpers.rb
450 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/g
em_version.rb
451 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/v
ersion.rb
452 C:/Ruby200-x64/lib/ruby/2.0.0/erb.rb
453 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/string/output_safety.rb
454 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view.r
b
455 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/r
ailtie.rb
456 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.1.5/lib/action_contro
ller/railtie.rb
457 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.1.5/lib/active_reco
rd/railtie.rb
458 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-4.1.5/lib/action_mail
er/gem_version.rb
459 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-4.1.5/lib/action_mail
er/version.rb
460 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/class/delegating_attributes.rb
461 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/module/reachable.rb
462 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/class/subclasses.rb
463 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/class.rb
464 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-4.1.5/lib/action_mail
er.rb
465 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-4.1.5/lib/action_mail
er/railtie.rb
466 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.5/lib/rails/test_unit
/railtie.rb
467 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/ver
sion.rb
468 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/hike-1.2.3/lib/hike.rb
469 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb
470 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/string.rb
471 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/erb.rb
472 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/etanni.rb
473 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/haml.rb
474 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/css.rb
475 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/csv.rb
476 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/coffee.rb
477 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/nokogiri.rb
478 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/builder.rb
479 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/markaby.rb
480 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/liquid.rb
481 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/radius.rb
482 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/markdown.rb
483 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/textile.rb
484 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/rdoc.rb
485 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/wiki.rb
486 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/yajl.rb
487 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/asciidoc.rb
488 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/plain.rb
489 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt.rb
490 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/eco
_template.rb
491 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/ejs
_template.rb
492 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/jst
_processor.rb
493 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/uti
ls.rb
494 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/eng
ines.rb
495 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/mime.rb
496 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/mim
e.rb
497 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/pro
cessor.rb
498 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/pro
cessing.rb
499 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/com
pressing.rb
500 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/pat
hs.rb
501 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/hike-1.2.3/lib/hike/normalized_arr
ay.rb
502 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/hike-1.2.3/lib/hike/extensions.rb
503 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/hike-1.2.3/lib/hike/index.rb
504 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/hike-1.2.3/lib/hike/paths.rb
505 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/hike-1.2.3/lib/hike/trail.rb
506 C:/Ruby200-x64/lib/ruby/2.0.0/shellwords.rb
507 C:/Ruby200-x64/lib/ruby/2.0.0/psych/syntax_error.rb
508 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/psych.so
509 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes/node.rb
510 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes/stream.rb
511 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes/document.rb
512 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes/sequence.rb
513 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes/scalar.rb
514 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes/mapping.rb
515 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes/alias.rb
516 C:/Ruby200-x64/lib/ruby/2.0.0/psych/nodes.rb
517 C:/Ruby200-x64/lib/ruby/2.0.0/psych/streaming.rb
518 C:/Ruby200-x64/lib/ruby/2.0.0/psych/visitors/visitor.rb
519 C:/Ruby200-x64/lib/ruby/2.0.0/psych/scalar_scanner.rb
520 C:/Ruby200-x64/lib/ruby/2.0.0/psych/visitors/to_ruby.rb
521 C:/Ruby200-x64/lib/ruby/2.0.0/psych/visitors/emitter.rb
522 C:/Ruby200-x64/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb
523 C:/Ruby200-x64/lib/ruby/2.0.0/psych/json/ruby_events.rb
524 C:/Ruby200-x64/lib/ruby/2.0.0/psych/visitors/json_tree.rb
525 C:/Ruby200-x64/lib/ruby/2.0.0/psych/visitors/depth_first.rb
526 C:/Ruby200-x64/lib/ruby/2.0.0/psych/visitors.rb
527 C:/Ruby200-x64/lib/ruby/2.0.0/psych/handler.rb
528 C:/Ruby200-x64/lib/ruby/2.0.0/psych/tree_builder.rb
529 C:/Ruby200-x64/lib/ruby/2.0.0/psych/parser.rb
530 C:/Ruby200-x64/lib/ruby/2.0.0/psych/omap.rb
531 C:/Ruby200-x64/lib/ruby/2.0.0/psych/set.rb
532 C:/Ruby200-x64/lib/ruby/2.0.0/psych/coder.rb
533 C:/Ruby200-x64/lib/ruby/2.0.0/psych/core_ext.rb
534 C:/Ruby200-x64/lib/ruby/2.0.0/psych/deprecated.rb
535 C:/Ruby200-x64/lib/ruby/2.0.0/psych/stream.rb
536 C:/Ruby200-x64/lib/ruby/2.0.0/psych/json/yaml_events.rb
537 C:/Ruby200-x64/lib/ruby/2.0.0/psych/json/tree_builder.rb
538 C:/Ruby200-x64/lib/ruby/2.0.0/psych/json/stream.rb
539 C:/Ruby200-x64/lib/ruby/2.0.0/psych/handlers/document_stream.rb
540 C:/Ruby200-x64/lib/ruby/2.0.0/psych.rb
541 C:/Ruby200-x64/lib/ruby/2.0.0/yaml.rb
542 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/dir
ective_processor.rb
543 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/saf
ety_colons.rb
544 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/cha
rset_normalizer.rb
545 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/sas
s_compressor.rb
546 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/yui
_compressor.rb
547 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/clo
sure_compressor.rb
548 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/ugl
ifier_compressor.rb
549 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/sas
s_template.rb
550 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/scs
s_template.rb
551 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets.rb
552 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/benchmarkable.rb
553 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/active_model_helper.rb
554 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/asset_url_helper.rb
555 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/capture_helper.rb
556 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/tag_helper.rb
557 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/asset_tag_helper.rb
558 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/atom_feed_helper.rb
559 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/cache_helper.rb
560 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/controller_helper.rb
561 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/csrf_helper.rb
562 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/date_helper.rb
563 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/debug_helper.rb
564 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/javascript_helper.rb
565 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/array/access.rb
566 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/url_helper.rb
567 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/string/filters.rb
568 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/v
endor/html-scanner.rb
569 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/sanitize_helper.rb
570 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/output_safety_helper.rb
571 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/text_helper.rb
572 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/form_tag_helper.rb
573 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/m
odel_naming.rb
574 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/form_helper.rb
575 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/form_options_helper.rb
576 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/number_helper.rb
577 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/number_helper.rb
578 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/module/concerning.rb
579 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/module/qualified_const.rb
580 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_sup
port/core_ext/module.rb
581 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/r
ecord_identifier.rb
582 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/record_tag_helper.rb
583 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/rendering_helper.rb
584 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers/translation_helper.rb
585 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionview-4.1.5/lib/action_view/h
elpers.rb
586 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-rails-2.1.3/lib/sprocket
s/rails/helper.rb
587 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-rails-2.1.3/lib/sprocket
s/rails/version.rb
588 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.5/lib/rails/engine/co
nfiguration.rb
589 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.5/lib/rails/applicati
on/configuration.rb
590 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-rails-2.1.3/lib/sprocket
s/railtie.rb
591 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.5/lib/rails/all.rb
592 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2/version.r
b
593 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2/error.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
C:\Users\bestacademyonline\Sites\simple_cms>
//////////////////////////////////////////////End//////////////////////////////////////////
Please Help me guys, waiting for you guys!
check your cofig/database.yml file. your user and password for mysql installation should match with mentioned in database.yml.
If this is correct can you show me your gem file details.

Defining attributes with .arff file in Weka

I have a problem in Weka library.I am trying to convert txt file to .arff file.But I got some error.My txt file like below:
Atlanta.txt
0000000 Tanner's 100 253 250 178 174 063 059 036 008 074 204 052 163
0000001 Frijoleros 250 062 132 174 063 197 071 142 234 243 075 204 052 162
0000002 Indian Delights 253 250 150 174 083 059 036 117 243 076 205 051 162
0000003 Great Wall 253 191 192 174 036 039 075 204 052 163
0000004 The Brickery 100 253 086 231 250 191 192 059 036 215 005 008 075 205 052 163
0000005 Lawrence's Cafe 250 191 192 174 063 197 071 057 036 140 143 075 204 052 163
0000006 Harold's Barbecue 253 174 010 221 036 017 076 205 051 162
0000007 Zab-E-Lee 011 174 235 076 208 051 164
0000008 The Dessert Place 100 086 150 174 036 042 061 076 204 053 162
0000009 Cafe Diem 250 196 174 063 197 005 042 061 068 074 204 053 162
0000010 El Charro 100 253 250 191 192 174 001 142 234 075 204 051 162
0000011 Kurt's at River Manor 253 231 191 192 174 063 248 036 098 076 205 054 165
0000012 Peggy Sue's Diner 100 253 086 250 191 192 174 063 036 042 061 074 204 053 163
0000013 Pars 253 250 174 071 059 057 036 143 075 205 053 164
0000014 Le Rendez-Vous 253 231 250 200 191 192 174 059 036 091 076 205 053 164
0000015 Rockbridge Diner 253 231 136 191 192 059 045 076 206 053 164
0000016 Chefs' Grill 100 080 253 231 102 191 192 174 083 036 024 025 005 076 206 053 165
0000017 Jonathan Lee's 253 231 245 191 192 174 059 036 039 235 075 205 052 163
0000018 The Country Place 253 099 231 250 062 132 191 192 174 071 083 024 215 005 076 206 054 165
0000019 Hama's 253 250 245 174 128 075 205 052 164
0000020 Raja Indian Restaurant 250 191 192 174 197 036 117 075 205 051 164
0000021 PRICCI 080 253 250 245 189 102 174 114 024 215 121 076 206 054 166
0000022 Pittypat's Porch 100 253 099 250 191 192 174 071 221 083 024 220 217 074 204 052 165
0000023 Houston's 026 253 086 250 174 063 215 005 008 107 076 206 053 164
0000024 Azio 253 086 231 250 102 063 114 248 215 121 182 075 205 053 164
0000026 ABRUZZI RISTORANTE 253 099 200 245 196 189 191 192 174 146 097 036 024 123 076 206 053 167
0000027 Rio Bravo Cantina 100 253 086 250 191 192 174 063 215 138 142 234 075 205 053 163
0000028 Savannah Fish Company 250 191 192 174 040 025 212 075 205 053 165
0000029 Lombardi's 253 231 250 174 024 121 075 205 053 164
0000030 Johnny Rockets 026 100 086 250 174 063 008 107 075 205 053 162
0000031 Opus 099 150 200 196 191 192 174 063 040 071 024 025 005 243 076 206 054 167
0000032 La Paz 100 253 250 191 192 174 063 197 083 036 215 025 142 234 222 076 205 053 163
I need to attribute value as Restaurant Id,Restaurant Name,Cuisine,Price,Style,Atmosphere and Occasion(Restaurant Features).But as you can see,number of columns and number of attributes don't exactly match each other.How can i delete some noise data and how can i group all of these features in this situation.I am planning to make a .arff file like that:
Atlanta.arff
#RELATION 'Atlanta'
#ATTRIBUTE Restaurant Id NUMERIC
#ATTRIBUTE Restaurant Name String
#ATTRIBUTE Restaurant Features NUMERIC
#DATA
0000000 Tanner's {100 253 250 178 174 063 059 036 008 074 204 052 163}
0000001 Frijoleros {250 062 132 174 063 197 071 142 234 243 075 204 052 162}
0000002 Indian Delights {253 250 150 174 083 059 036 117 243 076 205 051 162}
0000003 Great Wall {253 191 192 174 036 039 075 204 052 163}
0000004 The Brickery {100 253 086 231 250 191 192 059 036 215 005 008 075 205 052 163}
0000005 Lawrence's Cafe {250 191 192 174 063 197 071 057 036 140 143 075 204 052 163}
0000006 Harold's Barbecue {253 174 010 221 036 017 076 205 051 162}
0000007 Zab-E-Lee {011 174 235 076 208 051 164}
0000008 The Dessert Place {100 086 150 174 036 042 061 076 204 053 162}
0000009 Cafe Diem {250 196 174 063 197 005 042 061 068 074 204 053 162}
0000010 El Charro {100 253 250 191 192 174 001 142 234 075 204 051 162}
0000011 Kurt's at River Manor {253 231 191 192 174 063 248 036 098 076 205 054 165}
0000012 Peggy Sue's Diner {100 253 086 250 191 192 174 063 036 042 061 074 204 053 163}
0000013 Pars {253 250 174 071 059 057 036 143 075 205 053 164}
0000014 Le Rendez-Vous {253 231 250 200 191 192 174 059 036 091 076 205 053 164}
0000015 Rockbridge Diner {253 231 136 191 192 059 045 076 206 053 164}
0000016 Chefs' Grill {100 080 253 231 102 191 192 174 083 036 024 025 005 076 206 053 165}
0000017 Jonathan Lee's {253 231 245 191 192 174 059 036 039 235 075 205 052 163}
0000018 The Country Place {253 099 231 250 062 132 191 192 174 071 083 024 215 005 076 206 054 165}
0000019 Hama's {253 250 245 174 128 075 205 052 164}
0000020 Raja Indian Restaurant {250 191 192 174 197 036 117 075 205 051 164}
0000021 PRICCI {080 253 250 245 189 102 174 114 024 215 121 076 206 054 166}
0000022 Pittypat's Porch {100 253 099 250 191 192 174 071 221 083 024 220 217 074 204 052 165}
0000023 Houston's {026 253 086 250 174 063 215 005 008 107 076 206 053 164}
0000024 Azio {253 086 231 250 102 063 114 248 215 121 182 075 205 053 164}
0000025 Banks {136 005 045 076 206 054 166}
0000026 ABRUZZI RISTORANTE {253 099 200 245 196 189 191 192 174 146 097 036 024 123 076 206 053 167}
0000027 Rio Bravo Cantina {100 253 086 250 191 192 174 063 215 138 142 234 075 205 053 163}
0000028 Savannah Fish Company {250 191 192 174 040 025 212 075 205 053 165}
0000029 Lombardi's {253 231 250 174 024 121 075 205 053 164}
0000030 Johnny Rockets {026 100 086 250 174 063 008 107 075 205 053 162}
0000031 Opus {099 150 200 196 191 192 174 063 040 071 024 025 005 243 076 206 054 167}
0000032 La Paz {100 253 250 191 192 174 063 197 083 036 215 025 142 234 222 076 205 053 163}
Thank you for your helping.Happy coding:)
If you are using the Weka GUI, I would recommend the following:
Open your data file in Excel (import the data as tab separated values)
Add the headers you want, and fill in missing data. Every row must have all column values filled in for Weka to read the data properly.
Save your file as a .csv
Open the Weka GUI, go to Explorer, then Open file, set the format as csv (see image), and open the csv file you just saved.
After you've loaded your data, you can save it to arff using the Save... button.

Convert PNG images to pixel gray-level values feature vectors

I am a newbie in MATLAB and I have a set of bmp images which I need to convert into pixel gray-level values as feature vectors of image. Can anyone suggest me the way how I can do that?
I need to use these pixel gray-level values as features and then perform operations like PCA/LDA.
I tried imread() but it returns me a matrix.. I feel feature vector will be just one row vector.
Regards,
imread() is the correct way to do it. Then just convert from a matrix into a vector. For example:
>> X = randi(255, 10)
X =
208 41 168 181 112 71 192 215 90 20
231 248 10 9 98 174 66 65 212 14
33 245 217 71 196 168 130 208 150 136
233 124 239 12 203 42 179 63 141 199
162 205 174 25 48 31 228 237 234 239
25 37 194 210 125 128 245 90 73 34
72 108 190 178 114 245 140 51 194 146
140 234 101 81 165 87 36 65 193 120
245 203 168 243 181 150 39 158 98 4
247 245 44 9 193 58 66 121 145 86
>> X(:)
ans =
208
231
33
233
162
25
72
140
245
247
...
Then you can just stack your different observations together with [] and do PCA.

Resources