logstash Twitter error when geo_enable=true - twitter
I am trying to connect logstash to twitter. All the twitter that user.geo_enabled=false parsed ok, but of the other hand if user.geo_enabled=true I receive this error:
Failed action. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"twitter", :_type=>"logs", :_routing=>nil}, #<LogStash::Event:0xb1b69ba #metadata_accessors=#<LogStash::Util::Accessors:0x74b553ef #store={}, #lut={}>, #cancelled=false, #data={"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, #metadata={}, #accessors=#<LogStash::Util::Accessors:0x40cb306f #store={"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, #lut={"in-reply-to"=>[{"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, "in-reply-to"], "type"=>[{"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, "type"]}>>], :response=>{"create"=>{"_index"=>"twitter", "_type"=>"logs", "_id"=>"AVXA_h0IgT1Xitpna0uT", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Mixing up field types: class org.elasticsearch.index.mapper.core.DoubleFieldMapper$DoubleFieldType != class org.elasticsearch.index.mapper.geo.BaseGeoPointFieldMapper$GeoPointFieldType on field coordinates.coordinates"}}}}, :level=>:warn}
I think that the relevent line is
{"create"=>{"_index"=>"twitter", "_type"=>"logs", "_id"=>"AVXA_h0IgT1Xitpna0uT", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Mixing up field types: class org.elasticsearch.index.mapper.core.DoubleFieldMapper$DoubleFieldType != class
org.elasticsearch.index.mapper.geo.BaseGeoPointFieldMapper$GeoPointFieldType on field coordinates.coordinates"}}}}, :level=>:warn}
my template is :
{
"template": "twitter",
"order": 1,
"settings": {
"number_of_shards": 1
},
"mappings": {
"tweet": {
"_all": {
"enabled": false
},
"properties": {
"coordinates": {
"properties": {
"coordinates": {
"type": "geo_point"
},
"type": {
"type": "string"
}
}
}
}
}
}
}
What can be the problem??
thanks.
The problem is that the field coordinates.coordinates in ES expect a type of data which is not the type received.
A solution would be to modify the template, removing the coordinates type. Then you delete your index and reindex your data. In that case the expected type of coordinates.coordinates will be dependent on the data inserted.
That should resolve the problem.
Related
MS Graph findMeetingTimes API not sorting meeting time suggestions correctly
My problem is that the Microsoft Graph findMeetingTimes API is not sorting the meeting time suggestions like I would expect it. In the documentation it says: If there are multiple meeting time suggestions, the findMeetingTimes action first orders the suggestions by their computed confidence value from high to low. If there are suggestions with the same confidence, the action then orders these suggestions chronologically. But whenever I try the API I get a "meetingTimeSuggestionsResult" sorted like this one: Confidence: 100 || 24.08.2017 16:30:00 -> 24.08.2017 17:00:00 Confidence: 100 || 24.08.2017 16:00:00 -> 24.08.2017 16:30:00 Confidence: 100 || 24.08.2017 08:30:00 -> 24.08.2017 09:00:00 Confidence: 100 || 24.08.2017 09:00:00 -> 24.08.2017 09:30:00 Confidence: 100 || 24.08.2017 14:00:00 -> 24.08.2017 14:30:00 Confidence: 100 || 24.08.2017 14:30:00 -> 24.08.2017 15:00:00 Confidence: 50 || 24.08.2017 13:00:00 -> 24.08.2017 13:30:00 Confidence: 50 || 24.08.2017 13:30:00 -> 24.08.2017 14:00:00 Confidence: 50 || 24.08.2017 15:00:00 -> 24.08.2017 15:30:00 Confidence: 100 || 24.08.2017 11:30:00 -> 24.08.2017 12:00:00 Confidence: 100 || 24.08.2017 10:30:00 -> 24.08.2017 11:00:00 Confidence: 100 || 24.08.2017 11:00:00 -> 24.08.2017 11:30:00 Confidence: 100 || 24.08.2017 10:00:00 -> 24.08.2017 10:30:00 Confidence: 100 || 24.08.2017 09:30:00 -> 24.08.2017 10:00:00 Confidence: 100 || 24.08.2017 12:30:00 -> 24.08.2017 13:00:00 Confidence: 50 || 24.08.2017 15:30:00 -> 24.08.2017 16:00:00 Confidence: 100 || 24.08.2017 12:00:00 -> 24.08.2017 12:30:00
The documentation is outdated. That's the way the API used to work, but it was changed and unfortunately the doc wasn't updated. Instead of a simple sort chronologically, the API tries to be "smart" about how it orders the results. There are a number of factors that go into it, with a major one being the user's past behavior. Showing a tendency to meet at certain times of the day can up that in the ranking.
DataTables in mvc
I have a string, named s respectively. The string s looks like : "HD-M-16-H-000001*1001*1 HD-M-16-H-000001*1001 HD-M-16-H 000001 15 JUL 201614 JUL 20170816ACHEONG SIEW FUNG 12345678I 22 DEC 1960SPO F- HD-M-16-H-000001*1001*2 HD-M-16-H-000001*1001 HD-M-16-H 000001 15 JUL 201614 JUL 20170816ACHEONG SIEW FUNG 12345678I 22 DEC 1960SPO F- HD-M-16-H-000001*1001*3 HD-M-16-H-000001*1001 HD-M-16-H 000001 15 JUL 201614 JUL 20170816ACHEONG SIEW FUNG 12345678I 22 DEC 1960SPO F- " I split the string based on rows. The code is string s = sr.ReadToEnd(); string[] Mem = s.Split('\r'); So, Now the string[] Mem looks like : "HD-M-16-H-000001*1001*1 HD-M-16-H-000001*1001 HD-M-16-H 000001 15 JUL 201614 JUL 20170816ACHEONG SIEW FUNG 12345678I 22 DEC 1960SPO F- " "HD-M-16-H-000001*1001*2 HD-M-16-H-000001*1001 HD-M-16-H 000001 15 JUL 201614 JUL 20170816ACHEONG SIEW FUNG 12345678I 22 DEC 1960SPO F- " "HD-M-16-H-000001*1001*3 HD-M-16-H-000001*1001 HD-M-16-H 000001 15 JUL 201614 JUL 20170816ACHEONG SIEW FUNG 12345678I 22 DEC 1960SPO F- " Now, actually i am looking to create a dataTable with 'n' number of columns to hold Each word of each string in Mem. The below code that takes each line of string[] and holds it into string. Then i split the string string firststr = Mem.First(); string secondstr = Mem[1]; string thirdstr = Mem[2]; string str = firststr.Substring(0, 30); string[] m = str.Split('\r'); Actually i want to store all the three string[] to one string datatype with 3 strings and split each line of string by substr using loop(foreach or While). So how can i acheive this??? Any help appreciated. Thanks in advance !!!!
Print a particular object from json in ruby
How do I print only the text from the json. I am working on ruby on rails app. tweets = JSON.parse(response.body) tweets.each do |tweet| "#{tweet["text"]}" end I tried the above code bt it displays the whole json. Response.body : [{"created_at"=>"Mon Jun 09 02:49:17 +0000 2014", "id"=>475831972812423168, "id_str"=>"475831972812423168", "text"=>"#debalec #DIST1", "source"=>"https://dev.twitter.com/docs/tfw\" rel=\"nofollow\">Twitter for Websites", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>2551123651, "in_reply_to_user_id_str"=>"2551123651", "in_reply_to_screen_name"=>"debalec", "user"=>{"id"=>1551421092, "id_str"=>"1551421092", "name"=>"The Third", "screen_name"=>"thethird", "location"=>"", "description"=>"", "url"=>nil, "entities"=>{"description"=>{"urls"=>[]}}, "protected"=>false, "followers_count"=>12, "friends_count"=>199, "listed_count"=>0, "created_at"=>"Thu Jun 27 20:24:56 +0000 2013", "favourites_count"=>54, "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>false, "verified"=>false, "statuses_count"=>82, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "is_translation_enabled"=>false, "profile_background_color"=>"59BEE4", "profile_background_image_url"=>"http://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg", "profile_background_image_url_https"=>"https://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg", "profile_background_tile"=>false, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", "profile_link_color"=>"8FCAE0", "profile_sidebar_border_color"=>"4BB7DF", "profile_sidebar_fill_color"=>"191F22", "profile_text_color"=>"4BB7DF", "profile_use_background_image"=>true, "default_profile"=>false, "default_profile_image"=>true, "following"=>false, "follow_request_sent"=>false, "notifications"=>false}, "geo"=>nil, "coordinates"=>nil, "place"=>nil, "contributors"=>nil, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[{"text"=>"DIST1", "indices"=>[10, 16]}], "symbols"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"debalec", "name"=>"DebaElec", "id"=>2551123651, "id_str"=>"2551123651", "indices"=>[0, 8]}]}, "favorited"=>false, "retweeted"=>false, "lang"=>"und"}, {"created_at"=>"Fri Jun 06 22:41:39 +0000 2014", "id"=>475044876841938944, "id_str"=>"475044876841938944", "text"=>"hi #debalec", "source"=>"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>nil, "in_reply_to_user_id_str"=>nil, "in_reply_to_screen_name"=>nil, "user"=>{"id"=>1551421092, "id_str"=>"1551421092", "name"=>"the third", "screen_name"=>"the third", "location"=>"", "description"=>"", "url"=>nil, "entities"=>{"description"=>{"urls"=>[]}}, "protected"=>false, "followers_count"=>12, "friends_count"=>199, "listed_count"=>0, "created_at"=>"Thu Jun 27 20:24:56 +0000 2013", "favourites_count"=>54, "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>false, "verified"=>false, "statuses_count"=>82, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "is_translation_enabled"=>false, "profile_background_color"=>"59BEE4", "profile_background_image_url"=>"http://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg","profile_background_image_url_https"=>"https://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg", "profile_background_tile"=>false,"profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png","profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", "profile_link_color"=>"8FCAE0", "profile_sidebar_border_color"=>"4BB7DF", "profile_sidebar_fill_color"=>"191F22", "profile_text_color"=>"4BB7DF", "profile_use_background_image"=>true, "default_profile"=>false, "default_profile_image"=>true, "following"=>false, "follow_request_sent"=>false, "notifications"=>false}, "geo"=>nil, "coordinates"=>nil, "place"=>nil, "contributors"=>nil, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "symbols"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"debalec", "name"=>"DebaElec", "id"=>2551123651, "id_str"=>"2551123651", "indices"=>[3, 11]}]}, "favorited"=>false, "retweeted"=>false, "lang"=>"und"}]
Use map instead of each: tweets = JSON.parse(response.body) tweets.map do |tweet| tweet["text"] end And there is no need to interpolate tweet["text"].
One problem here is that you're using quotes within quotes. Forgot to escape? Another issue is that you're not printing anything. Merely returning the text in a loop does nothing and would always return the tweets object when the loop is complete. So, here you go: tweets = JSON.parse(response.body) tweets.each do |tweet| puts tweet["text"] end Update: Well, I guess the quotes within quotes won't be a problem here as long as you use string interpolation. But it's still not the preferred way. I'd rather go with "#{tweet['text']}".
Can I know if a video is H.264?
I'm trying to find out whether a video uploaded through Carrierwave is encoded with H.264 or not. So far I tried the MiniExiftool gem since it lets me read a file's metadata. However I don't see it specified anywhere. Perhaps it's there and I'm just missing it. Any help, suggestions, or guidance? I'd appreciate it. Here's what I get when I use MiniExiftool.new #file.path. => #<MiniExiftool:0x007f7f82884628 #opts={:numerical=>false, :composite=>true, : ignore_minor_errors=>false, :replace_invalid_chars=>false, :timestamps=>Time}, # values={"exiftoolversion"=>8.9, "filesize"=>"35 MB", "filemodifydate"=>2014-04-2 8 18:46:51 +0000, "filepermissions"=>"rw-r--r--", "filetype"=>"MP4", "mimetype"= >"video/mp4", "majorbrand"=>"MP4 Base Media v1 [IS0 14496-12:2003]", "minorvers ion"=>"0.0.0", "compatiblebrands"=>["isom", "3gp4"], "movieheaderversion"=>0, "c reatedate"=>2014-04-23 14:56:19 +0000, "modifydate"=>2014-04-23 14:56:19 +0000, "timescale"=>1000, "duration"=>"14.28 s", "preferredrate"=>1, "preferredvolume"= >"100.00%", "previewtime"=>"0 s", "previewduration"=>"0 s", "postertime"=>"0 s", "selectiontime"=>"0 s", "selectionduration"=>"0 s", "currenttime"=>"0 s", "next trackid"=>3, "trackheaderversion"=>0, "trackcreatedate"=>2014-04-23 14:56:19 +00 00, "trackmodifydate"=>2014-04-23 14:56:19 +0000, "trackid"=>1, "trackduration"= >"13.90 s", "tracklayer"=>0, "trackvolume"=>"0.00%", "imagewidth"=>1920, "imageh eight"=>1080, "graphicsmode"=>"srcCopy", "opcolor"=>"0 0 0", "compressorid"=>"av c1", "sourceimagewidth"=>1920, "sourceimageheight"=>1080, "xresolution"=>72, "yr esolution"=>72, "bitdepth"=>24, "videoframerate"=>29.998, "matrixstructure"=>"1 0 0 0 1 0 0 0 1", "mediaheaderversion"=>0, "mediacreatedate"=>2014-04-23 14:56:1 9 +0000, "mediamodifydate"=>2014-04-23 14:56:19 +0000, "mediatimescale"=>48000, "mediaduration"=>"14.28 s", "handlertype"=>"Audio Track", "handlerdescription"=> "SoundHandle", "balance"=>0, "audioformat"=>"mp4a", "audiochannels"=>2, "audiobi tspersample"=>16, "audiosamplerate"=>48000, "moviedatasize"=>36819481, "avgbitra te"=>"20.6 Mbps", "imagesize"=>"1920x1080", "rotation"=>0}, #changed_values={}, #errors={}, #filename="/home/user/uploads/dbrvp74x6r.mp4", #output="[{\n \"SourceFile\": \"home/user/uploads/dbrvp74x6r.mp4\",\n \"ExifToolVersion\": 8.90,\n \"FileName\": \"dbrvp74x6r.mp4\",\n \"Directory\": \"home/user/uploads\",\n \"FileSize\": \"35 MB\",\n \"FileModifyDate\": \"2014:0 4:28 18:46:51+00:00\",\n \"FilePermissions\": \"rw-r--r--\",\n \"FileType\": \ "MP4\",\n \"MIMEType\": \"video/mp4\",\n \"MajorBrand\": \"MP4 Base Media v1 [IS0 14496-12:2003]\",\n \"MinorVersion\": \"0.0.0\",\n \"CompatibleBrands\": [\"isom\",\"3gp4\"],\n \"MovieHeaderVersion\": 0,\n \"CreateDate\": \"2014:04: 23 14:56:19\",\n \"ModifyDate\": \"2014:04:23 14:56:19\",\n \"TimeScale\": 100 0,\n \"Duration\": \"14.28 s\",\n \"PreferredRate\": 1,\n \"PreferredVolume\" : \"100.00%\",\n \"PreviewTime\": \"0 s\",\n \"PreviewDuration\": \"0 s\",\n \"PosterTime\": \"0 s\",\n \"SelectionTime\": \"0 s\",\n \"SelectionDuration\" : \"0 s\",\n \"CurrentTime\": \"0 s\",\n \"NextTrackID\": 3,\n \"TrackHeaderV ersion\": 0,\n \"TrackCreateDate\": \"2014:04:23 14:56:19\",\n \"TrackModifyDa te\": \"2014:04:23 14:56:19\",\n \"TrackID\": 1,\n \"TrackDuration\": \"13.90 s\",\n \"TrackLayer\": 0,\n \"TrackVolume\": \"0.00%\",\n \"ImageWidth\": 192 0,\n \"ImageHeight\": 1080,\n \"GraphicsMode\": \"srcCopy\",\n \"OpColor\": \ "0 0 0\",\n \"CompressorID\": \"avc1\",\n \"SourceImageWidth\": 1920,\n \"Sou rceImageHeight\": 1080,\n \"XResolution\": 72,\n \"YResolution\": 72,\n \"Bit Depth\": 24,\n \"VideoFrameRate\": 29.998,\n \"MatrixStructure\": \"1 0 0 0 1 0 0 0 1\",\n \"MediaHeaderVersion\": 0,\n \"MediaCreateDate\": \"2014:04:23 14 :56:19\",\n \"MediaModifyDate\": \"2014:04:23 14:56:19\",\n \"MediaTimeScale\" : 48000,\n \"MediaDuration\": \"14.28 s\",\n \"HandlerType\": \"Audio Track\", \n \"HandlerDescription\": \"SoundHandle\",\n \"Balance\": 0,\n \"AudioFormat \": \"mp4a\",\n \"AudioChannels\": 2,\n \"AudioBitsPerSample\": 16,\n \"Audio SampleRate\": 48000,\n \"MovieDataSize\": 36819481,\n \"AvgBitrate\": \"20.6 M bps\",\n \"ImageSize\": \"1920x1080\",\n \"Rotation\": 0\n}]
Yes, this video is h.264. "CompressorID": "avc1". AVC = Advanced Video Coding = h.264
Flex Date and Time Stock Chart (HOLC) - Need Help
I am trying to show BOTH the date and the time in Flex 3.5 Stock HOLC (high, open, low, close) Chart. This data shows up but not in the correct format... Problems: 1. The time are out of whack.. they do not line up with proper time.. (is it because they are not military time)? 2. The dates (days) do not show up on the bottom labels are all, is there a way to make this happen? 3. The times show up with large gaps... in the 24 hour period... Is this always the case when the data is not there for the time? Or, can I disable specific time periods like is possible with "disable days" Any suggestions? <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script><![CDATA[ import mx.collections.ArrayCollection [Bindable] public var TICKER:ArrayCollection = new ArrayCollection([ {date:"1/8/05 8:30:00 AM",open:42.57,high:43.08,low:42.08,close:42.75}, {date:"1/8/05 9:00:00 AM",open:42.89,high:43.5,low:42.61,close:43.19}, {date:"1/8/05 9:30:00 AM",open:43.19,high:43.31,low:42.77,close:43.22}, {date:"1/8/05 10:00:00 AM",open:42.89,high:43,low:42.29,close:42.71}, {date:"1/8/05 10:30:00 AM",open:42.49,high:43.36,low:42.02,close:42.99}, {date:"1/8/05 11:00:00 AM",open:43,high:43.25,low:42.61,close:42.65}, {date:"1/8/05 11:30:00 AM",open:42.93,high:43.89,low:42.91,close:43.82}, {date:"1/8/05 12:00:00 PM",open:44,high:44.39,low:43.31,close:43.38}, {date:"1/8/05 12:30:00 PM",open:43.39,high:44.12,low:43.25,close:44}, {date:"1/8/05 1:00:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"1/8/05 1:30:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"1/8/05 2:00:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"1/8/05 2:30:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"1/8/05 3:00:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"2/8/05 8:30:00 AM",open:42.57,high:43.08,low:42.08,close:42.75}, {date:"2/8/05 9:00:00 AM",open:42.89,high:43.5,low:42.61,close:43.19}, {date:"2/8/05 9:30:00 AM",open:43.19,high:43.31,low:42.77,close:43.22}, {date:"2/8/05 10:00:00 AM",open:42.89,high:43,low:42.29,close:42.71}, {date:"2/8/05 10:30:00 AM",open:42.49,high:43.36,low:42.02,close:42.99}, {date:"2/8/05 11:00:00 AM",open:43,high:43.25,low:42.61,close:42.65}, {date:"2/8/05 11:30:00 AM",open:42.93,high:43.89,low:42.91,close:43.82}, {date:"2/8/05 12:00:00 PM",open:44,high:44.39,low:43.31,close:43.38}, {date:"2/8/05 12:30:00 PM",open:43.39,high:44.12,low:43.25,close:44}, {date:"2/8/05 1:00:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"2/8/05 1:30:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"2/8/05 2:00:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"2/8/05 2:30:00 PM",open:43.46,high:46.22,low:43.36,close:46.1}, {date:"2/8/05 3:00:00 PM",open:43.46,high:46.22,low:43.36,close:46.1} ]); ]]></mx:Script> <mx:Panel title="HighLowOpenClose Chart"> <mx:HLOCChart id="myChart" dataProvider="{TICKER}" showDataTips="true" > <mx:verticalAxis> <mx:LinearAxis minimum="30" maximum="50"/> </mx:verticalAxis> <mx:series> <mx:HLOCSeries dataProvider="{TICKER}" openField="open" highField="high" lowField="low" closeField="close" displayName="TICKER" xField="date" > </mx:HLOCSeries> </mx:series> <mx:horizontalAxis> <mx:DateTimeAxis parseFunction="{myParseFunction}" id="dt1" disabledDays="[0,1]" dataUnits="hours" alignLabelsToUnits="true" labelUnits="hours" /> </mx:horizontalAxis> <mx:horizontalAxisRenderers> <mx:AxisRenderer id="dt1Rnd" showLabels="true" axis="{dt1}" visible="true" minWidth="1" /> </mx:horizontalAxisRenderers> </mx:HLOCChart> <mx:Legend dataProvider="{myChart}"/> </mx:Panel> <mx:Script> <![CDATA[ public function myParseFunction(s:String):Date { // Get an array of Strings from the // comma-separated String passed in. var a:Array = s.split(/:|\/|\s/); trace("String a : " + a.toString()); // Trace out year, month, and day values. // To create a Date object, you pass "YYYY,MM,DD", // where MM is zero-based, to the Date() constructor. var newDate:Date = new Date(a[2],a[1],a[0],a[3],a[4]); return newDate; } ]]> </mx:Script> </mx:Application>
No, dates are fine, no needs in that format. Check the code http://pastebin.com/9Y443NFv Yes, use disabledRanges also you can find interesting things in this code too: http://www.meutzner.com/blog/attachments/360/srcview/index.html Regards Eugene