From 2fc6bb88c533ea1410010394e08d183236ee142e Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 31 Oct 2014 17:23:56 +0000 Subject: Add example json and el files --- sample-frontpage.json | 1 + sample-question-unauthenticated.el | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 sample-frontpage.json create mode 100644 sample-question-unauthenticated.el diff --git a/sample-frontpage.json b/sample-frontpage.json new file mode 100644 index 0000000..8e56caf --- /dev/null +++ b/sample-frontpage.json @@ -0,0 +1 @@ +{"items":[{"answers":[{"owner":{"reputation":307244,"user_id":157247,"user_type":"registered","accept_rate":90,"profile_image":"https://www.gravatar.com/avatar/ca3e484c121268e4c8302616b2395eb9?s=128&d=identicon&r=PG","display_name":"T.J. Crowder","link":"http://stackoverflow.com/users/157247/t-j-crowder"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773411,"creation_date":1414773411,"answer_id":26679414,"question_id":26679366,"body_markdown":"> Now I want to assign the color(whatever i am getting from this element) to a span element.\r\n\r\nNo you don't, you can just use `rgb(18, 115, 224)` directly for a color value in CSS.","link":"http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679414#26679414","body":"
\n

Now I want to assign the color(whatever i am getting from this element) to a span element.

\n
\n\n

No you don't, you can just use rgb(18, 115, 224) directly for a color value in CSS.

\n"},{"owner":{"reputation":26812,"user_id":717214,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/9075315c5f4b734a8f2567be54a4cc45?s=128&d=identicon&r=PG","display_name":"Aleks G","link":"http://stackoverflow.com/users/717214/aleks-g"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773433,"creation_date":1414773433,"answer_id":26679423,"question_id":26679366,"body_markdown":"You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:\r\n\r\n var clr = rgb(18, 115, 224);\r\n $('#myspan').css('color', clr);","link":"http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679423#26679423","body":"

You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:

\n\n
var clr = rgb(18, 115, 224);\n$('#myspan').css('color', clr);\n
\n"}],"tags":["javascript","jquery","html","css","colors"],"owner":{"reputation":90,"user_id":3867678,"user_type":"registered","accept_rate":45,"profile_image":"http://graph.facebook.com/100001985977413/picture?type=large","display_name":"Rasmita Dash","link":"http://stackoverflow.com/users/3867678/rasmita-dash"},"comments":[{"owner":{"reputation":76145,"user_id":14104,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/760b4da77fd54d37c104029ff1f56749?s=128&d=identicon&r=PG","display_name":"epascarello","link":"http://stackoverflow.com/users/14104/epascarello"},"edited":false,"score":0,"creation_date":1414773413,"post_id":26679366,"comment_id":41957708}],"comment_count":1,"is_answered":false,"view_count":16,"answer_count":2,"score":0,"last_activity_date":1414773433,"creation_date":1414773223,"question_id":26679366,"body_markdown":"I am getting "rgb(18, 115, 224)" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use \r\n \r\n "#" + componentToHex(r) + componentToHex(g) + componentToHex(b)\r\nbut, My question here's how can I get the r, g,b component values from "rgb(18, 115, 224)"","link":"http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format","title":"get r, g, b component of a color in rgb() format","body":"

I am getting \"rgb(18, 115, 224)\" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use

\n\n
\"#\" + componentToHex(r) + componentToHex(g) + componentToHex(b)\n
\n\n

but, My question here's how can I get the r, g,b component values from \"rgb(18, 115, 224)\"

\n"},{"tags":["sql","sql-server","tsql"],"owner":{"reputation":1,"user_id":3406133,"user_type":"registered","profile_image":"http://graph.facebook.com/665814025/picture?type=large","display_name":"user3406133","link":"http://stackoverflow.com/users/3406133/user3406133"},"comment_count":0,"is_answered":false,"view_count":1,"answer_count":0,"score":0,"last_activity_date":1414773431,"creation_date":1414773431,"question_id":26679421,"body_markdown":"I have a table in SQL which contains the name's of certain Functions. \r\n\r\nIs it possible to select a function based on a string stored in a table? \r\n\r\nNormally I would execute the below in SSMS \r\n \r\n\r\n SELECT dbo.udfGetFileName () \r\n\r\n\r\nBut instead I want to be able to get the same result by getting the name of the function out of a Table \r\n \r\n\r\n DECLARE @GetFileName VARCHAR(30); \r\n SET @GetFileName = (SELECT FunctionName FROM Functions)\r\n SELECT @GetFileName () \r\n \r\nSomething like the above, obviosuly variables won't work but I was wondering if I could get some ideas. \r\n \r\nAny help would be apprecaited.","link":"http://stackoverflow.com/questions/26679421/sql-2005-i-would-like-to-able-to-select-a-function-which-i-declared-as-a-variabl","title":"SQL 2005 I would like to able to select a function which i declared as a variable","body":"

I have a table in SQL which contains the name's of certain Functions.

\n\n

Is it possible to select a function based on a string stored in a table?

\n\n

Normally I would execute the below in SSMS

\n\n
SELECT dbo.udfGetFileName ()  \n
\n\n

But instead I want to be able to get the same result by getting the name of the function out of a Table

\n\n
DECLARE @GetFileName VARCHAR(30); \nSET @GetFileName = (SELECT FunctionName FROM Functions)\nSELECT @GetFileName ()  \n
\n\n

Something like the above, obviosuly variables won't work but I was wondering if I could get some ideas.

\n\n

Any help would be apprecaited.

\n"},{"tags":["ruby","rvm","uninstall"],"owner":{"reputation":1,"user_id":4203256,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-jhwW1DuKmMA/AAAAAAAAAAI/AAAAAAAAAFU/-24UhRZRMSA/photo.jpg?sz=128","display_name":"ReJam","link":"http://stackoverflow.com/users/4203256/rejam"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773430,"creation_date":1414773430,"question_id":26679422,"body_markdown":"I'm fairly new to coding and I recently came back to it after installing Homebrew and RVM months ago. Now I can't update RVM or update to the newest version of ruby through RVM so I wanted to uninstall it completely and then reinstall the newest versions from scratch. However when I run rvm implode, it doesn't seem to do anything. I can still write commands for RVM and they work. I want to completely remove all traces of RVM. What do?","link":"http://stackoverflow.com/questions/26679422/after-i-use-rvm-implode-to-uninstall-rvm-its-still-fully-functional","title":"After I use rvm implode to uninstall rvm, it's still fully functional","body":"

I'm fairly new to coding and I recently came back to it after installing Homebrew and RVM months ago. Now I can't update RVM or update to the newest version of ruby through RVM so I wanted to uninstall it completely and then reinstall the newest versions from scratch. However when I run rvm implode, it doesn't seem to do anything. I can still write commands for RVM and they work. I want to completely remove all traces of RVM. What do?

\n"},{"answers":[{"owner":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"comment_count":0,"is_accepted":false,"score":3,"last_activity_date":1414773171,"creation_date":1414773171,"answer_id":26679350,"question_id":26679277,"body_markdown":"Use jquery filter to filter out based on your needs, like below:\r\n\r\n $('input').filter(function() {\r\n\t\treturn this.id.match(/contact_attributes_addresses_attributes_\\d+_address/i)\r\n\t}).css('prop', 'val'); // for example, set some css props for the matched elements","link":"http://stackoverflow.com/questions/26679277/jquery-find-a-selector-whose-id-contains-a-string-using-regex/26679350#26679350","body":"

Use jquery filter to filter out based on your needs, like below:

\n\n
$('input').filter(function() {\n    return this.id.match(/contact_attributes_addresses_attributes_\\d+_address/i)\n}).css('prop', 'val'); // for example, set some css props for the matched elements\n
\n"},{"owner":{"reputation":896,"user_id":1052928,"user_type":"registered","accept_rate":71,"profile_image":"http://i.stack.imgur.com/NU1jN.jpg?s=128&g=1","display_name":"Ragnar","link":"http://stackoverflow.com/users/1052928/ragnar"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773430,"creation_date":1414773430,"answer_id":26679420,"question_id":26679277,"body_markdown":"James Padolsey created a wonderful filter that allows regex to be used for selection.\r\n\r\nTake a look at this question:\r\n\r\nhttp://stackoverflow.com/questions/190253/jquery-selector-regular-expressions\r\n","link":"http://stackoverflow.com/questions/26679277/jquery-find-a-selector-whose-id-contains-a-string-using-regex/26679420#26679420","body":"

James Padolsey created a wonderful filter that allows regex to be used for selection.

\n\n

Take a look at this question:

\n\n

jQuery selector regular expressions

\n"}],"tags":["jquery","regex"],"owner":{"reputation":100,"user_id":3957231,"user_type":"registered","accept_rate":50,"profile_image":"http://graph.facebook.com/100008180384390/picture?type=large","display_name":"Dan Stayntouch","link":"http://stackoverflow.com/users/3957231/dan-stayntouch"},"comment_count":0,"is_answered":true,"view_count":25,"answer_count":2,"score":0,"last_activity_date":1414773430,"creation_date":1414772862,"question_id":26679277,"body_markdown":"I want to match input fields that match the following pattern:\r\n\r\na_profile_contact_attributes_addresses_attributes_0_address\r\nb_store_contact_attributes_addresses_attributes_3_address\r\nsomethingelse_contact_attributes_addresses_attributes_44_address\r\n\r\nIn other words, I want to use the following regex:\r\n\r\n /contact_attributes_addresses_attributes_\\d+_address/\r\n\r\nUsing jQuery, I tried the following but it returns an empty result set:\r\n\r\n $('input[id*="contact_attributes_addresses_attributes_' + /\\d+/ + '_address"]')\r\n\r\nWhat might I be doing wrong?","link":"http://stackoverflow.com/questions/26679277/jquery-find-a-selector-whose-id-contains-a-string-using-regex","title":"jquery find a selector whose id contains a string using regex","body":"

I want to match input fields that match the following pattern:

\n\n

a_profile_contact_attributes_addresses_attributes_0_address\nb_store_contact_attributes_addresses_attributes_3_address\nsomethingelse_contact_attributes_addresses_attributes_44_address

\n\n

In other words, I want to use the following regex:

\n\n
/contact_attributes_addresses_attributes_\\d+_address/\n
\n\n

Using jQuery, I tried the following but it returns an empty result set:

\n\n
$('input[id*=\"contact_attributes_addresses_attributes_' + /\\d+/ + '_address\"]')\n
\n\n

What might I be doing wrong?

\n"},{"answers":[{"owner":{"reputation":389,"user_id":3027848,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/povDg.jpg?s=128&g=1","display_name":"aledustet","link":"http://stackoverflow.com/users/3027848/aledustet"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773425,"creation_date":1414773425,"answer_id":26679419,"question_id":26678784,"body_markdown":"You need to use on your second line:\r\n\r\n\r\n<!-- language: ruby -->\r\n\r\n module Spree\r\n module BaseHelper.class_eval \r\n ...\r\n end\r\n end\r\n\r\nthis should work.\r\n\r\n","link":"http://stackoverflow.com/questions/26678784/custom-meta-description-and-keyword-tags-in-spree/26679419#26679419","body":"

You need to use on your second line:

\n\n
module Spree\n  module  BaseHelper.class_eval \n     ...\n  end\nend\n
\n\n

this should work.

\n"}],"tags":["ruby-on-rails","spree"],"owner":{"reputation":848,"user_id":2229277,"user_type":"registered","accept_rate":91,"profile_image":"http://i.stack.imgur.com/LZg07.jpg?s=128&g=1","display_name":"newUserNameHere","link":"http://stackoverflow.com/users/2229277/newusernamehere"},"comment_count":0,"is_answered":false,"view_count":8,"answer_count":1,"score":0,"last_activity_date":1414773425,"creation_date":1414771170,"last_edit_date":1414772928,"question_id":26678784,"body_markdown":"I'm trying to modify the default meta descriptions and keyword tags. I'm stuck on this issue, and I don't know spree all that well.\r\n\r\nI believe they're being set here: `spree / core / app / helpers / spree / base_helper.rb`\r\n\r\nI've tried creating a file under /app/helpers/spree/base_helper_decorator.rb and put this code into it in hope of overriding the meta_data function. \r\n\r\n\r\n\r\n\r\n module Spree\r\n module BaseHelper\r\n \r\n def meta_data\r\n meta = {}\r\n \r\n meta.reverse_merge!({\r\n keywords: "test keyword",\r\n description: "test description",\r\n })\r\n meta\r\n end\r\n \r\n end\r\n end\r\n\r\nThis is not working as all my meta tags remain the same. Any help would be greatly appreciated!\r\n","link":"http://stackoverflow.com/questions/26678784/custom-meta-description-and-keyword-tags-in-spree","title":"Custom Meta Description and Keyword tags in Spree","body":"

I'm trying to modify the default meta descriptions and keyword tags. I'm stuck on this issue, and I don't know spree all that well.

\n\n

I believe they're being set here: spree / core / app / helpers / spree / base_helper.rb

\n\n

I've tried creating a file under /app/helpers/spree/base_helper_decorator.rb and put this code into it in hope of overriding the meta_data function.

\n\n
module Spree\n  module BaseHelper\n\n    def meta_data\n      meta = {}\n\n      meta.reverse_merge!({\n        keywords: \"test keyword\",\n        description: \"test description\",\n      })\n      meta\n    end\n\n  end\nend\n
\n\n

This is not working as all my meta tags remain the same. Any help would be greatly appreciated!

\n"},{"answers":[{"owner":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"comments":[{"owner":{"reputation":71271,"user_id":1270695,"user_type":"registered","accept_rate":88,"profile_image":"http://i.stack.imgur.com/Fl3Sn.png?s=128&g=1","display_name":"Ananda Mahto","link":"http://stackoverflow.com/users/1270695/ananda-mahto"},"edited":false,"score":1,"creation_date":1414772001,"post_id":26678852,"comment_id":41956999},{"owner":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"reply_to_user":{"reputation":71271,"user_id":1270695,"user_type":"registered","accept_rate":88,"profile_image":"http://i.stack.imgur.com/Fl3Sn.png?s=128&g=1","display_name":"Ananda Mahto","link":"http://stackoverflow.com/users/1270695/ananda-mahto"},"edited":false,"score":0,"creation_date":1414772052,"post_id":26678852,"comment_id":41957030}],"last_editor":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"comment_count":2,"is_accepted":false,"score":1,"last_activity_date":1414772503,"last_edit_date":1414772503,"creation_date":1414771370,"answer_id":26678852,"question_id":26678722,"body_markdown":"You could also use\r\n\r\n sum(!rowSums(is.na(df[,-1])))\r\n #[1] 5\r\n\r\n###Update\r\n\r\nBased on the new dataset\r\n\r\n indx <- combn(colnames(df)[-1],2)\r\n res <- sapply(split(indx, col(indx)), function(x) \r\n sum(!rowSums(is.na(df[,x]))))\r\n\r\n names(res) <- apply(indx,2, paste, collapse="_")\r\n res\r\n # England_USA England_Brazil USA_Brazil \r\n # 5 4 3 \r\n\r\nA shorter code (as suggested by @Ananda Mahto) would be:\r\n\r\n\r\n unlist(combn(df[-1], 2, function(x) \r\n setNames(sum(complete.cases(x)), \r\n paste(names(x), collapse = "-")), simplify = FALSE))\r\n \r\n # England-USA England-Brazil USA-Brazil \r\n # 5 4 3 \r\n\r\n","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na/26678852#26678852","body":"

You could also use

\n\n
sum(!rowSums(is.na(df[,-1])))\n#[1] 5\n
\n\n

Update

\n\n

Based on the new dataset

\n\n
 indx <- combn(colnames(df)[-1],2)\n res <- sapply(split(indx, col(indx)), function(x) \n                          sum(!rowSums(is.na(df[,x]))))\n\n names(res) <- apply(indx,2, paste, collapse=\"_\")\n res\n # England_USA England_Brazil     USA_Brazil \n #        5              4              3 \n
\n\n

A shorter code (as suggested by @Ananda Mahto) would be:

\n\n
 unlist(combn(df[-1], 2, function(x) \n            setNames(sum(complete.cases(x)), \n            paste(names(x), collapse = \"-\")), simplify = FALSE))\n\n# England-USA England-Brazil     USA-Brazil \n#         5              4              3 \n
\n"},{"owner":{"reputation":17073,"user_id":3063910,"user_type":"registered","accept_rate":94,"profile_image":"http://graph.facebook.com/1267583007/picture?type=large","display_name":"Richard Scriven","link":"http://stackoverflow.com/users/3063910/richard-scriven"},"last_editor":{"reputation":17073,"user_id":3063910,"user_type":"registered","accept_rate":94,"profile_image":"http://graph.facebook.com/1267583007/picture?type=large","display_name":"Richard Scriven","link":"http://stackoverflow.com/users/3063910/richard-scriven"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773424,"last_edit_date":1414773424,"creation_date":1414771533,"answer_id":26678897,"question_id":26678722,"body_markdown":"Here's another posibility\r\n\r\n rowSums(apply(!is.na(df[-1]), 1, function(x) {\r\n c(EU = all(x[-3]), UB = all(x[-1]), EB = all(x[-2]))\r\n }))\r\n # EU UB EB \r\n # 5 3 4 ","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na/26678897#26678897","body":"

Here's another posibility

\n\n
rowSums(apply(!is.na(df[-1]), 1, function(x) {\n    c(EU = all(x[-3]), UB = all(x[-1]), EB = all(x[-2]))\n}))\n# EU UB EB \n#  5  3  4 \n
\n"},{"owner":{"reputation":529,"user_id":3969377,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/3f8dfdb77167183582d1d62390e0838b?s=128&d=identicon&r=PG&f=1","display_name":"user3969377","link":"http://stackoverflow.com/users/3969377/user3969377"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414771580,"creation_date":1414771580,"answer_id":26678909,"question_id":26678722,"body_markdown":"Use is.na with and...\r\n\r\n txt<-'players England USA\r\n 1 ben 0 3\r\n 2 josh 3 0\r\n 3 mike 3 0\r\n 4 sam 0 3\r\n 5 luis NA 1\r\n 6 john 1 NA\r\n 7 javi NA NA\r\n 8 terry 1 1 '\r\n \r\n df<-read.table(text=txt)\r\n \r\n bothNArows <- which(is.na(df$England) & is.na(df$USA))\r\n (nbad<-length(bothNArows))","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na/26678909#26678909","body":"

Use is.na with and...

\n\n
txt<-'players England USA\n1     ben       0   3\n2    josh       3   0\n3    mike       3   0\n4     sam       0   3\n5    luis      NA   1\n6    john       1   NA\n7    javi       NA  NA\n8   terry       1   1 '\n\ndf<-read.table(text=txt)\n\nbothNArows <- which(is.na(df$England) & is.na(df$USA))\n(nbad<-length(bothNArows))\n
\n"}],"tags":["r"],"owner":{"reputation":768,"user_id":1849997,"user_type":"registered","accept_rate":70,"profile_image":"http://i.stack.imgur.com/coeIX.jpg?s=128&g=1","display_name":"goldisfine","link":"http://stackoverflow.com/users/1849997/goldisfine"},"comments":[{"owner":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"edited":false,"score":0,"creation_date":1414771581,"post_id":26678722,"comment_id":41956755},{"owner":{"reputation":768,"user_id":1849997,"user_type":"registered","accept_rate":70,"profile_image":"http://i.stack.imgur.com/coeIX.jpg?s=128&g=1","display_name":"goldisfine","link":"http://stackoverflow.com/users/1849997/goldisfine"},"reply_to_user":{"reputation":17726,"user_id":3732271,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ee6e12042dc31b1ef27471482f9ff91f?s=128&d=identicon&r=PG&f=1","display_name":"akrun","link":"http://stackoverflow.com/users/3732271/akrun"},"edited":false,"score":0,"creation_date":1414771620,"post_id":26678722,"comment_id":41956783},{"owner":{"reputation":17073,"user_id":3063910,"user_type":"registered","accept_rate":94,"profile_image":"http://graph.facebook.com/1267583007/picture?type=large","display_name":"Richard Scriven","link":"http://stackoverflow.com/users/3063910/richard-scriven"},"edited":false,"score":1,"creation_date":1414772034,"post_id":26678722,"comment_id":41957014}],"comment_count":3,"is_answered":true,"view_count":23,"answer_count":3,"score":0,"last_activity_date":1414773424,"creation_date":1414771010,"last_edit_date":1414771456,"question_id":26678722,"body_markdown":"Let's say that I am working with data from soccer players. I have players' names, and countries that they have played in, and how many goals they've scored in these respective countries. \r\n\r\n players England USA Brazil\r\n 1 ben 0 3 NA\r\n 2 josh 3 0 2\r\n 3 mike 3 0 4\r\n 4 sam 0 3 3\r\n 5 luis NA 1 NA\r\n 6 john 1 NA 1\r\n 7 javi NA NA 3\r\n 8 terry 1 1 NA\r\n\r\nI would like to compare every pair of columns. So what I would like here is three numbers: the number of times there are two numbers in a row for the England, USA columns (5 here), the number of times there are two numbers in a row for USA, Brazil (3 here), and the number of times there are two numbers in the England, Brazil Columns (4 here).\r\n\r\n* I edited the question after a comment made me realize that posting the question with only two columns reduced the problem too much.\r\n","link":"http://stackoverflow.com/questions/26678722/how-to-count-every-time-values-in-two-columns-are-both-not-na","title":"How to count every time values in two columns are both NOT NA?","body":"

Let's say that I am working with data from soccer players. I have players' names, and countries that they have played in, and how many goals they've scored in these respective countries.

\n\n
  players England USA Brazil\n1     ben       0   3    NA\n2    josh       3   0     2\n3    mike       3   0     4\n4     sam       0   3     3\n5    luis      NA   1    NA\n6    john       1   NA    1\n7    javi       NA  NA    3\n8   terry       1   1     NA\n
\n\n

I would like to compare every pair of columns. So what I would like here is three numbers: the number of times there are two numbers in a row for the England, USA columns (5 here), the number of times there are two numbers in a row for USA, Brazil (3 here), and the number of times there are two numbers in the England, Brazil Columns (4 here).

\n\n\n"},{"answers":[{"owner":{"reputation":7472,"user_id":820127,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/81f8fffeec4f2ba3e75aebe941e4e5dd?s=128&d=identicon&r=PG","display_name":"rossum","link":"http://stackoverflow.com/users/820127/rossum"},"comments":[{"owner":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":0,"creation_date":1413987871,"post_id":26497045,"comment_id":41649744},{"owner":{"reputation":7472,"user_id":820127,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/81f8fffeec4f2ba3e75aebe941e4e5dd?s=128&d=identicon&r=PG","display_name":"rossum","link":"http://stackoverflow.com/users/820127/rossum"},"reply_to_user":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":0,"creation_date":1413989955,"post_id":26497045,"comment_id":41651195},{"owner":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":1,"creation_date":1413996711,"post_id":26497045,"comment_id":41655596},{"owner":{"reputation":7472,"user_id":820127,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/81f8fffeec4f2ba3e75aebe941e4e5dd?s=128&d=identicon&r=PG","display_name":"rossum","link":"http://stackoverflow.com/users/820127/rossum"},"reply_to_user":{"reputation":1342,"user_id":2336725,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20a0b96a26cf233d752469445595f872?s=128&d=identicon&r=PG","display_name":"Teepeemm","link":"http://stackoverflow.com/users/2336725/teepeemm"},"edited":false,"score":0,"creation_date":1414000356,"post_id":26497045,"comment_id":41657579},{"owner":{"reputation":7580,"user_id":2095090,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/4s3og.jpg?s=128&g=1","display_name":"Vincent van der Weele","link":"http://stackoverflow.com/users/2095090/vincent-van-der-weele"},"edited":false,"score":1,"creation_date":1414259055,"post_id":26497045,"comment_id":41749889}],"comment_count":5,"is_accepted":false,"score":-1,"last_activity_date":1413928505,"creation_date":1413928505,"answer_id":26497045,"question_id":26463250,"body_markdown":"The states are one more than the powers of primes. You have numbers up to 2^8, so the power of 2 is in [0..8], which is 9 states. Similarly for the other states.\r\n\r\n"dp" could well stand for dynamic programming, I'm not sure.\r\n\r\nThe recurrence relation is the heart of the problem, so you will learn more by solving it yourself. Start with some small, simple examples.\r\n\r\nFor the large primes, try solving a reduced problem without using them (or their equivalents) and then add them back in to see their effect on the final result.","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set/26497045#26497045","body":"

The states are one more than the powers of primes. You have numbers up to 2^8, so the power of 2 is in [0..8], which is 9 states. Similarly for the other states.

\n\n

\"dp\" could well stand for dynamic programming, I'm not sure.

\n\n

The recurrence relation is the heart of the problem, so you will learn more by solving it yourself. Start with some small, simple examples.

\n\n

For the large primes, try solving a reduced problem without using them (or their equivalents) and then add them back in to see their effect on the final result.

\n"},{"owner":{"reputation":15647,"user_id":2144669,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5e7393f439028063515255b63ed94cfd?s=128&d=identicon&r=PG","display_name":"David Eisenstat","link":"http://stackoverflow.com/users/2144669/david-eisenstat"},"comments":[{"owner":{"reputation":4166,"user_id":2956115,"user_type":"registered","profile_image":"http://i.stack.imgur.com/zVi0W.jpg?s=128&g=1","display_name":"artur grzesiak","link":"http://stackoverflow.com/users/2956115/artur-grzesiak"},"edited":false,"score":0,"creation_date":1414707179,"post_id":26663246,"comment_id":41930248},{"owner":{"reputation":15647,"user_id":2144669,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5e7393f439028063515255b63ed94cfd?s=128&d=identicon&r=PG","display_name":"David Eisenstat","link":"http://stackoverflow.com/users/2144669/david-eisenstat"},"reply_to_user":{"reputation":4166,"user_id":2956115,"user_type":"registered","profile_image":"http://i.stack.imgur.com/zVi0W.jpg?s=128&g=1","display_name":"artur grzesiak","link":"http://stackoverflow.com/users/2956115/artur-grzesiak"},"edited":false,"score":0,"creation_date":1414726462,"post_id":26663246,"comment_id":41935689}],"comment_count":2,"is_accepted":false,"score":2,"last_activity_date":1414703009,"creation_date":1414703009,"answer_id":26663246,"question_id":26463250,"body_markdown":"The first part of the editorial seems useful, but the second part is rather vague (and perhaps unhelpful; I'd rather finish this answer than figure it out).\r\n\r\nLet's suppose for the moment that the input consists of pairwise distinct primes, e.g., 2, 3, 5, and 7. Then the answer (for summing all sets, where the LCM of 0 integers is 1) is\r\n\r\n (1 + 2) (1 + 3) (1 + 5) (1 + 7),\r\n\r\nbecause the LCM of a subset is exactly equal to the product here, so just multiply it out.\r\n\r\nLet's relax the restriction that the primes be pairwise distinct. If we have an input like 2, 2, 3, 3, 3, and 5, then the multiplication looks like\r\n\r\n (1 + (2^2 - 1) 2) (1 + (2^3 - 1) 3) (1 + (2^1 - 1) 5),\r\n\r\nbecause 2 appears with multiplicity 2, and 3 appears with multiplicity 3, and 5 appears with multiplicity 1. With respect to, e.g., just the set of 3s, there are `2^3 - 1` ways to choose a subset that includes a 3, and `1` way to choose the empty set.\r\n\r\nCall a prime *small* if it's 19 or less and *large* otherwise. Note that integers 500 or less are divisible by at most one large prime (with multiplicity). The small primes are more problematic. What we're going to do is to compute, for each possible small portion of the prime factorization of the LCM (i.e., one of the ~70,000 states), the sum of LCMs for the problem derived by discarding the integers that could not divide such an LCM and leaving only the large prime factor (or 1) for the other integers.\r\n\r\nFor example, if the input is 2, 30, 41, 46, and 51, and the state is 2, then we retain 2 as 1, discard 30 (= 2 * 3 * 5; 3 and 5 are small), retain 41 as 41 (41 is large), retain 46 as 23 (= 2 * 23; 23 is large), and discard 51 (= 3 * 17; 3 and 17 are small). Now, we compute the sum of LCMs using the previously described technique. Use [inclusion-exclusion](https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle) to get rid of the subsets whose LCM whose small portion properly divides the state instead of being exactly equal. Maybe I'll work a complete example later.","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set/26663246#26663246","body":"

The first part of the editorial seems useful, but the second part is rather vague (and perhaps unhelpful; I'd rather finish this answer than figure it out).

\n\n

Let's suppose for the moment that the input consists of pairwise distinct primes, e.g., 2, 3, 5, and 7. Then the answer (for summing all sets, where the LCM of 0 integers is 1) is

\n\n
(1 + 2) (1 + 3) (1 + 5) (1 + 7),\n
\n\n

because the LCM of a subset is exactly equal to the product here, so just multiply it out.

\n\n

Let's relax the restriction that the primes be pairwise distinct. If we have an input like 2, 2, 3, 3, 3, and 5, then the multiplication looks like

\n\n
(1 + (2^2 - 1) 2) (1 + (2^3 - 1) 3) (1 + (2^1 - 1) 5),\n
\n\n

because 2 appears with multiplicity 2, and 3 appears with multiplicity 3, and 5 appears with multiplicity 1. With respect to, e.g., just the set of 3s, there are 2^3 - 1 ways to choose a subset that includes a 3, and 1 way to choose the empty set.

\n\n

Call a prime small if it's 19 or less and large otherwise. Note that integers 500 or less are divisible by at most one large prime (with multiplicity). The small primes are more problematic. What we're going to do is to compute, for each possible small portion of the prime factorization of the LCM (i.e., one of the ~70,000 states), the sum of LCMs for the problem derived by discarding the integers that could not divide such an LCM and leaving only the large prime factor (or 1) for the other integers.

\n\n

For example, if the input is 2, 30, 41, 46, and 51, and the state is 2, then we retain 2 as 1, discard 30 (= 2 * 3 * 5; 3 and 5 are small), retain 41 as 41 (41 is large), retain 46 as 23 (= 2 * 23; 23 is large), and discard 51 (= 3 * 17; 3 and 17 are small). Now, we compute the sum of LCMs using the previously described technique. Use inclusion-exclusion to get rid of the subsets whose LCM whose small portion properly divides the state instead of being exactly equal. Maybe I'll work a complete example later.

\n"},{"owner":{"reputation":4216,"user_id":873886,"user_type":"registered","accept_rate":56,"profile_image":"https://www.gravatar.com/avatar/344697d54c0db06b0a9a426f6e319374?s=128&d=identicon&r=PG","display_name":"Kaganar","link":"http://stackoverflow.com/users/873886/kaganar"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773420,"creation_date":1414773420,"answer_id":26679418,"question_id":26463250,"body_markdown":"Discussion\r\n-\r\nAfter reading the actual contest description ([page 10 or 11][1]) and the solution sketch, I have to conclude the author of the solution sketch is quite imprecise in their writing.\r\n\r\nThe high level problem is to calculate an expected lifetime if components are chosen randomly by fair coin toss. This is what's leading to computing the LCM of all subsets -- all subsets effectively represent the sample space. You could end up with any possible set of components. The failure time for the device is based on the LCM of the set. The expected lifetime is therefore the average of the LCM of all sets.\r\n\r\nNote that this ought to include the LCM of sets with only one item (in which case we'd assume the LCM to be the element itself). The solution sketch seems to sabotage, perhaps because they handled it in a less elegant manner.\r\n\r\nWhat is meant by these states?\r\n-\r\nThe sketch author only uses the word *state* twice, but apparently manages to switch meanings. In the first use of the word *state* it appears they're talking about a possible selection of components. In the second use they're likely talking about possible failure times. They're could be muddling this terminology because their dynamic programming solution initializes values from one use of the word and the recurrence relation stems from the other.\r\n\r\n\r\nDoes dp stand for dynamic programming?\r\n-\r\nI would say either it does or it's a coincidence as the solution sketch seems to heavily imply dynamic programming.\r\n\r\nIf so, what recurrence relation is being solved? How is dp[i] computed from dp[i-1]?\r\n-\r\n\r\nAll I can think is that in their solution, *state* `i` represents a time to failure , `T(i)`, with the number of times this time to failure has been counted, `dp[i]`. The resulting sum would be to sum all `dp[i] * T(i)`.\r\n\r\n`dp[i][0]` would then be the failure times counted for only the first component. `dp[i][1]` would then be the failure times counted for the first and second component. `dp[i][2]` would be for the first, second, and third. Etc..\r\n\r\nInitialize `dp[i][0]` with zeroes except for `dp[T(c)][0]` (where `c` is the first component considered) which should be 1 (since this component's failure time has been counted once so far).\r\n\r\nTo populate `dp[i][n]` from `dp[i][n-1]` for each component `c`:\r\n\r\n- For each `i`, copy `dp[i][n-1]` into `dp[i][n]`.\r\n- Add 1 to `dp[T(c)][n]`.\r\n- For each `i`, add `dp[i][n-1]` to `dp[LCM(T(i), T(c))][n]`.\r\n\r\nWhat is this doing? Suppose you knew that you had a time to failure of `j`, but you added a component with a time to failure of `k`. Regardless of what components you had before, your new time to fail is `LCM(j, k)`. This follows from the fact that for two sets `A` and `B`, `LCM(A union B} = LCM(LCM(A), LCM(B))`.\r\n\r\nSimilarly, if we're considering a time to failure of `T(i)` and our new component's time to failure of `T(c)`, the resultant time to failure is `LCM(T(i), T(c))`. Note that we recorded this time to failure for `dp[i][n-1]` configurations, so we should record that many new times to failure once the new component is introduced.\r\n\r\nWhy do the big primes not contribute to the number of states?\r\n-\r\n> Each of them occurs either 0 or 1 times. Should the number of states not be multiplied by 2 for each of these primes (leading to a non-feasible state space again)?\r\n\r\nYou're right, of course. However, the solution sketch states that numbers with large primes are handled in another (unspecified) fashion.\r\n\r\nWhat would happen if we did include them? The number of *states* we would need to represent would explode into an impractical number. Hence the author accounts for such numbers differently. Note that if a number less than or equal to 500 includes a prime larger than 19 the other factors multiply to 21 or less. This makes such numbers amenable for brute forcing, no tables necessary.\r\n\r\n\r\n [1]: http://acm-icpc.coe.psu.ac.th/contest-problem/contest-acm-asia-hy-2012-final.pdf","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set/26679418#26679418","body":"

Discussion

\n\n

After reading the actual contest description (page 10 or 11) and the solution sketch, I have to conclude the author of the solution sketch is quite imprecise in their writing.

\n\n

The high level problem is to calculate an expected lifetime if components are chosen randomly by fair coin toss. This is what's leading to computing the LCM of all subsets -- all subsets effectively represent the sample space. You could end up with any possible set of components. The failure time for the device is based on the LCM of the set. The expected lifetime is therefore the average of the LCM of all sets.

\n\n

Note that this ought to include the LCM of sets with only one item (in which case we'd assume the LCM to be the element itself). The solution sketch seems to sabotage, perhaps because they handled it in a less elegant manner.

\n\n

What is meant by these states?

\n\n

The sketch author only uses the word state twice, but apparently manages to switch meanings. In the first use of the word state it appears they're talking about a possible selection of components. In the second use they're likely talking about possible failure times. They're could be muddling this terminology because their dynamic programming solution initializes values from one use of the word and the recurrence relation stems from the other.

\n\n

Does dp stand for dynamic programming?

\n\n

I would say either it does or it's a coincidence as the solution sketch seems to heavily imply dynamic programming.

\n\n

If so, what recurrence relation is being solved? How is dp[i] computed from dp[i-1]?

\n\n

All I can think is that in their solution, state i represents a time to failure , T(i), with the number of times this time to failure has been counted, dp[i]. The resulting sum would be to sum all dp[i] * T(i).

\n\n

dp[i][0] would then be the failure times counted for only the first component. dp[i][1] would then be the failure times counted for the first and second component. dp[i][2] would be for the first, second, and third. Etc..

\n\n

Initialize dp[i][0] with zeroes except for dp[T(c)][0] (where c is the first component considered) which should be 1 (since this component's failure time has been counted once so far).

\n\n

To populate dp[i][n] from dp[i][n-1] for each component c:

\n\n\n\n

What is this doing? Suppose you knew that you had a time to failure of j, but you added a component with a time to failure of k. Regardless of what components you had before, your new time to fail is LCM(j, k). This follows from the fact that for two sets A and B, LCM(A union B} = LCM(LCM(A), LCM(B)).

\n\n

Similarly, if we're considering a time to failure of T(i) and our new component's time to failure of T(c), the resultant time to failure is LCM(T(i), T(c)). Note that we recorded this time to failure for dp[i][n-1] configurations, so we should record that many new times to failure once the new component is introduced.

\n\n

Why do the big primes not contribute to the number of states?

\n\n
\n

Each of them occurs either 0 or 1 times. Should the number of states not be multiplied by 2 for each of these primes (leading to a non-feasible state space again)?

\n
\n\n

You're right, of course. However, the solution sketch states that numbers with large primes are handled in another (unspecified) fashion.

\n\n

What would happen if we did include them? The number of states we would need to represent would explode into an impractical number. Hence the author accounts for such numbers differently. Note that if a number less than or equal to 500 includes a prime larger than 19 the other factors multiply to 21 or less. This makes such numbers amenable for brute forcing, no tables necessary.

\n"}],"tags":["algorithm","computer-science","dynamic-programming","primes","prime-factoring"],"owner":{"reputation":146,"user_id":2472641,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d734b762d636b11eca7cf2303325c2c0?s=128&d=identicon&r=PG","display_name":"MasterMind","link":"http://stackoverflow.com/users/2472641/mastermind"},"comments":[{"owner":{"reputation":313,"user_id":3455829,"user_type":"registered","profile_image":"http://i.stack.imgur.com/DxqTQ.gif?s=128&g=1","display_name":"Ralor","link":"http://stackoverflow.com/users/3455829/ralor"},"reply_to_user":{"reputation":2440,"user_id":2741705,"user_type":"registered","profile_image":"http://graph.facebook.com/1478197909/picture?type=large","display_name":"Pham Trung","link":"http://stackoverflow.com/users/2741705/pham-trung"},"edited":false,"score":1,"creation_date":1413904304,"post_id":26463250,"comment_id":41614065},{"owner":{"reputation":7580,"user_id":2095090,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/4s3og.jpg?s=128&g=1","display_name":"Vincent van der Weele","link":"http://stackoverflow.com/users/2095090/vincent-van-der-weele"},"edited":false,"score":1,"creation_date":1413922983,"post_id":26463250,"comment_id":41624393},{"owner":{"reputation":146,"user_id":2472641,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d734b762d636b11eca7cf2303325c2c0?s=128&d=identicon&r=PG","display_name":"MasterMind","link":"http://stackoverflow.com/users/2472641/mastermind"},"reply_to_user":{"reputation":7580,"user_id":2095090,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/4s3og.jpg?s=128&g=1","display_name":"Vincent van der Weele","link":"http://stackoverflow.com/users/2095090/vincent-van-der-weele"},"edited":false,"score":0,"creation_date":1414017796,"post_id":26463250,"comment_id":41666332}],"comment_count":3,"is_answered":true,"view_count":186,"bounty_amount":100,"bounty_closes_date":1415297825,"answer_count":3,"score":9,"last_activity_date":1414773420,"creation_date":1413800137,"last_edit_date":1413922680,"question_id":26463250,"body_markdown":"**Given:** set <code>A = {a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>N-1</sub>}</code> (<code>1 &leq; N &leq; 100</code>), with <code>2 &leq; a<sub>i</sub> &leq; 500</code>.\r\n\r\n**Asked:** Find the sum of all least common multiples (LCM) of all subsets of `A` of size at least 2.\r\n\r\nThe LCM of a set<code>B = {b<sub>0</sub>, b<sub>1</sub>, ..., b<sub>k-1</sub>}</code> is defined as the minimum integer <code>B<sub>min</sub></code> such that <code>b<sub>i</sub> | B<sub>min</sub></code>, for all <code>0 &leq; i < k</code>.\r\n\r\n**Example:**\r\n\r\nLet `N = 3` and `A = {2, 6, 7}`, then:\r\n\r\n LCM({2, 6}) = 6\r\n LCM({2, 7}) = 14\r\n LCM({6, 7}) = 42\r\n LCM({2, 6, 7}) = 42\r\n ----------------------- +\r\n answer 104\r\n\r\nThe naive approach would be to simply calculate the LCM for all <code>O(2<sup>N</sup>)</code> subsets, which is not feasible for reasonably large `N`.\r\n\r\n---\r\n\r\n**Solution sketch:**\r\n\r\nThe problem is obtained from a competition<sup>*</sup>, which also provided a [solution sketch][1]. This is where my problem comes in: I do not understand the hinted approach.\r\n\r\nThe solution reads (modulo some small fixed grammar issues):\r\n\r\n> The solution is a bit tricky. If we observe carefully we see that the integers are between `2` and `500`. So, if we prime factorize the numbers, we get the following maximum powers:\r\n\r\n 2 8 \r\n 3 5\r\n 5 3\r\n 7 3\r\n 11 2\r\n 13 2\r\n 17 2\r\n 19 2\r\n\r\n> Other than this, all primes have power 1. So, we can easily calculate all possible states, using these integers, leaving `9 * 6 * 4 * 4 * 3 * 3 * 3 * 3` states, which is nearly `70000`. For other integers we can make a dp like the following: `dp[70000][i]`, where `i` can be `0` to `100`. However, as `dp[i]` is dependent on `dp[i-1]`, so `dp[70000][2]` is enough. This leaves the complexity to `n * 70000` which is feasible.\r\n\r\nI have the following concrete questions:\r\n\r\n - What is meant by these states?\r\n - Does `dp` stand for dynamic programming and if so, what recurrence relation is being solved?\r\n - How is `dp[i]` computed from `dp[i-1]`?\r\n - Why do the big primes not contribute to the number of states? Each of them occurs either `0` or `1` times. Should the number of states not be multiplied by `2` for each of these primes (leading to a non-feasible state space again)?\r\n\r\n<sub><sup>*</sup>The original problem description can be found from [this source][2] (problem F). This question is a simplified version of that description.</sub>\r\n\r\n\r\n [1]: http://acm-icpc.coe.psu.ac.th/contest-problem/solution-sketch-UltimateDevice.pdf\r\n [2]: http://acm-icpc.coe.psu.ac.th/contest-problem/contest-acm-asia-hy-2012-final.pdf","link":"http://stackoverflow.com/questions/26463250/find-the-sum-of-least-common-multiples-of-all-subsets-of-a-given-set","title":"Find the sum of least common multiples of all subsets of a given set","body":"

Given: set A = {a0, a1, ..., aN-1} (1 ≤ N ≤ 100), with 2 ≤ ai ≤ 500.

\n\n

Asked: Find the sum of all least common multiples (LCM) of all subsets of A of size at least 2.

\n\n

The LCM of a setB = {b0, b1, ..., bk-1} is defined as the minimum integer Bmin such that bi | Bmin, for all 0 ≤ i < k.

\n\n

Example:

\n\n

Let N = 3 and A = {2, 6, 7}, then:

\n\n
LCM({2, 6})      =    6\nLCM({2, 7})      =   14\nLCM({6, 7})      =   42\nLCM({2, 6, 7})   =   42\n----------------------- +\nanswer              104\n
\n\n

The naive approach would be to simply calculate the LCM for all O(2N) subsets, which is not feasible for reasonably large N.

\n\n
\n\n

Solution sketch:

\n\n

The problem is obtained from a competition*, which also provided a solution sketch. This is where my problem comes in: I do not understand the hinted approach.

\n\n

The solution reads (modulo some small fixed grammar issues):

\n\n
\n

The solution is a bit tricky. If we observe carefully we see that the integers are between 2 and 500. So, if we prime factorize the numbers, we get the following maximum powers:

\n
\n\n
 2 8  \n 3 5\n 5 3\n 7 3\n11 2\n13 2\n17 2\n19 2\n
\n\n
\n

Other than this, all primes have power 1. So, we can easily calculate all possible states, using these integers, leaving 9 * 6 * 4 * 4 * 3 * 3 * 3 * 3 states, which is nearly 70000. For other integers we can make a dp like the following: dp[70000][i], where i can be 0 to 100. However, as dp[i] is dependent on dp[i-1], so dp[70000][2] is enough. This leaves the complexity to n * 70000 which is feasible.

\n
\n\n

I have the following concrete questions:

\n\n\n\n

*The original problem description can be found from this source (problem F). This question is a simplified version of that description.

\n"},{"tags":["java","swing","graphics","rotation","awt"],"owner":{"reputation":1,"user_id":1485930,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2bc89b982edddfc9ef0c8aa3f7d45181?s=128&d=identicon&r=PG","display_name":"Ali Abdallah","link":"http://stackoverflow.com/users/1485930/ali-abdallah"},"comment_count":0,"is_answered":false,"view_count":1,"answer_count":0,"score":0,"last_activity_date":1414773419,"creation_date":1414773419,"question_id":26679417,"body_markdown":"i have an extended JLabel class, called OrientationLabel, holding a single character. That character is '>' and inside my extended class is a function called flip which basically changes the character from '>' to '<'. anyway what i want to do is rotate the label in order for it to align with an edge. \r\n\r\nNote: I also have an edge class which consists of two Point objects. inside that class is a function called center() which returns a computed center Point object in between the two points that form the edge. and also an angle() function that computes the angle that the edge makes.\r\n\r\ni pass the angle and center point to my constructor of my orientation label and here is my resulting paintComponent function:\r\n\r\n\r\n @Override\r\n public void paintComponent(Graphics g){\r\n \r\n Graphics2D g2 = (Graphics2D)g;\r\n \r\n this.setLocation(Math.round(center.getX() - (getWidth()/2)), Math.round(center.getY() - (getHeight()/2)));\r\n g2.rotate(-rotation, getWidth() / 2, getHeight() / 2);\r\n \r\n super.paintComponent(g);\r\n \r\n }\r\n\r\n\r\nThe problem is that as i rotate the label, sometimes it does not align exactly with the line. It points along the direction ok and the flip() function works perfectly but like i said sometimes you can tell its not perfectly aligned. Also i feel it sometimes comes out a little skewed.\r\n\r\nI'm guessing this has something to do with the rotational center. If the width of the character is an odd number then the center will be a pixel rather than half a pixel? \r\n\r\nKeep in mind i have been using java for a very long time in uni however we never really explored using the Graphics/Graphics2D classes therefore i would also appreciate some good resources where i can quickly learn these concepts/hierarchies a little better.","link":"http://stackoverflow.com/questions/26679417/java-rotation-of-a-jlabel-using-arbitrary-angles","title":"Java rotation of a JLabel using arbitrary angles","body":"

i have an extended JLabel class, called OrientationLabel, holding a single character. That character is '>' and inside my extended class is a function called flip which basically changes the character from '>' to '<'. anyway what i want to do is rotate the label in order for it to align with an edge.

\n\n

Note: I also have an edge class which consists of two Point objects. inside that class is a function called center() which returns a computed center Point object in between the two points that form the edge. and also an angle() function that computes the angle that the edge makes.

\n\n

i pass the angle and center point to my constructor of my orientation label and here is my resulting paintComponent function:

\n\n

@Override\n public void paintComponent(Graphics g){

\n\n
    Graphics2D g2 = (Graphics2D)g;\n\n    this.setLocation(Math.round(center.getX() - (getWidth()/2)), Math.round(center.getY() - (getHeight()/2)));\n    g2.rotate(-rotation, getWidth() / 2, getHeight() / 2);\n\n    super.paintComponent(g);\n\n}\n
\n\n

The problem is that as i rotate the label, sometimes it does not align exactly with the line. It points along the direction ok and the flip() function works perfectly but like i said sometimes you can tell its not perfectly aligned. Also i feel it sometimes comes out a little skewed.

\n\n

I'm guessing this has something to do with the rotational center. If the width of the character is an odd number then the center will be a pixel rather than half a pixel?

\n\n

Keep in mind i have been using java for a very long time in uni however we never really explored using the Graphics/Graphics2D classes therefore i would also appreciate some good resources where i can quickly learn these concepts/hierarchies a little better.

\n"},{"answers":[{"owner":{"reputation":69820,"user_id":165737,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/odROI.jpg?s=128&g=1","display_name":"Anurag","link":"http://stackoverflow.com/users/165737/anurag"},"last_editor":{"reputation":69820,"user_id":165737,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/odROI.jpg?s=128&g=1","display_name":"Anurag","link":"http://stackoverflow.com/users/165737/anurag"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1262921229,"last_edit_date":1262921229,"creation_date":1262915058,"answer_id":2024926,"question_id":2024691,"body_markdown":"Actually, you can resize a canvas using stylesheets. The results may vary across browsers as HTML5 is still in the process of being finalized. \r\n\r\nThere is no `width` or `height` property for a drawing context, only for canvas. A context's `scale` is used to resize the unit step size in `x` or `y` dimensions and it doesn't have to be proportional. For example,\r\n\r\n context.scale(5, 1);\r\n\r\nchanges the `x` unit size to 5, and y's to 1. If we draw a 30x30 square now, it will actually come out to be 150x30 as `x` has been scaled 5 times while `y` remains the same. If you want the logo to be larger, increase the context scale **before** drawing your logo.\r\n\r\nMozilla has a good tutorial on [scaling and transformations][1] in general.\r\n\r\n**Edit**: In response to your comment, the logo's size and canvas dimensions will determine what should be the scaling factor for enlarging the image. If the logo is 100x100 px in size and the canvas is 800x600, then you are limited by canvas height (600) as its smaller. So the maximum scaling that you can do without clipping part of the logo outside canvas will be 600/100 = 6\r\n\r\n context.scale(6, 6)\r\n\r\nThese numbers will vary and you can do your own calculations to find the optimal size.\r\n\r\n [1]: https://developer.mozilla.org/en/Canvas_tutorial/Transformations "Scaling and Transformations"","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/2024926#2024926","body":"

Actually, you can resize a canvas using stylesheets. The results may vary across browsers as HTML5 is still in the process of being finalized.

\n\n

There is no width or height property for a drawing context, only for canvas. A context's scale is used to resize the unit step size in x or y dimensions and it doesn't have to be proportional. For example,

\n\n
context.scale(5, 1);\n
\n\n

changes the x unit size to 5, and y's to 1. If we draw a 30x30 square now, it will actually come out to be 150x30 as x has been scaled 5 times while y remains the same. If you want the logo to be larger, increase the context scale before drawing your logo.

\n\n

Mozilla has a good tutorial on scaling and transformations in general.

\n\n

Edit: In response to your comment, the logo's size and canvas dimensions will determine what should be the scaling factor for enlarging the image. If the logo is 100x100 px in size and the canvas is 800x600, then you are limited by canvas height (600) as its smaller. So the maximum scaling that you can do without clipping part of the logo outside canvas will be 600/100 = 6

\n\n
context.scale(6, 6)\n
\n\n

These numbers will vary and you can do your own calculations to find the optimal size.

\n"},{"owner":{"reputation":22827,"user_id":109374,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b6939793be07c69fe4f783dd442e902d?s=128&d=identicon&r=PG","display_name":"Erik Dahlström","link":"http://stackoverflow.com/users/109374/erik-dahlstr%c3%b6m"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1262942338,"creation_date":1262942338,"answer_id":2026532,"question_id":2024691,"body_markdown":"You could convert the logo to svg and let the browser do the scaling for you, with or without adding css mediaqueries.\r\n\r\nCheck out Andreas Bovens' [presentation and examples][1].\r\n\r\n\r\n [1]: http://my.opera.com/ODIN/blog/2009/10/12/how-media-queries-allow-you-to-optimize-svg-icons-for-several-sizes","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/2026532#2026532","body":"

You could convert the logo to svg and let the browser do the scaling for you, with or without adding css mediaqueries.

\n\n

Check out Andreas Bovens' presentation and examples.

\n"},{"owner":{"reputation":2549,"user_id":172378,"user_type":"registered","accept_rate":100,"profile_image":"http://i.stack.imgur.com/Ceji6.jpg?s=128&g=1","display_name":"Delta","link":"http://stackoverflow.com/users/172378/delta"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1263158749,"creation_date":1263158749,"answer_id":2038693,"question_id":2024691,"body_markdown":"You can resize the image when you draw it\r\n\r\n imageobject=new Image();\r\n imageobject.src="imagefile";\r\n imageobject.onload=function(){\r\n \tcontext.drawImage(imageobject,0,0,imageobject.width,imageobject.height,0,0,800,600);\r\n }\r\n\r\nThe last 2 arguments are the width an height to resize the image\r\n\r\nhttp://www.w3.org/TR/html5/the-canvas-element.html#dom-context-2d-drawimage\r\n","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/2038693#2038693","body":"

You can resize the image when you draw it

\n\n
imageobject=new Image();\nimageobject.src=\"imagefile\";\nimageobject.onload=function(){\n    context.drawImage(imageobject,0,0,imageobject.width,imageobject.height,0,0,800,600);\n}\n
\n\n

The last 2 arguments are the width an height to resize the image

\n\n

http://www.w3.org/TR/html5/the-canvas-element.html#dom-context-2d-drawimage

\n"},{"owner":{"reputation":2697,"user_id":379650,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/294c2d2b6a287b133e66c35bb3de57cd?s=128&d=identicon&r=PG","display_name":"qw3n","link":"http://stackoverflow.com/users/379650/qw3n"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1278307742,"creation_date":1278307742,"answer_id":3177368,"question_id":2024691,"body_markdown":"If you set the `element.style.width` and `element.style.height` attributes (assuming element is a canvas element) you are stretching the contents of the canvas. If you set the `element.width` and `element.height` you are resizing the canvas itself not the content. The `ctx.scale` is for dynamic resizing whenever you drawing something with javascript and gives you the same stretching effect as `element.style`.","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas/3177368#3177368","body":"

If you set the element.style.width and element.style.height attributes (assuming element is a canvas element) you are stretching the contents of the canvas. If you set the element.width and element.height you are resizing the canvas itself not the content. The ctx.scale is for dynamic resizing whenever you drawing something with javascript and gives you the same stretching effect as element.style.

\n"}],"tags":["html","html5","canvas"],"owner":{"reputation":1,"user_id":246039,"user_type":"unregistered","profile_image":"https://www.gravatar.com/avatar/30a83423ee0a48578a5ede86c7f77b52?s=128&d=identicon&r=PG","display_name":"miles","link":"http://stackoverflow.com/users/246039/miles"},"comment_count":0,"is_answered":false,"view_count":5423,"answer_count":4,"score":0,"last_activity_date":1414773417,"creation_date":1262910150,"last_edit_date":1317898832,"question_id":2024691,"body_markdown":"Having trouble scaling with <canvas>. It seems to make sense to code up a drawing in canvas to a fixed size (ie 800x600) then scale it for specific locations - but sizing occurs in 4 places: 1) in the context definition (ie ctx.width = 800 2) with ctx.scale; 3) in html with <canvas width=... and with css for the div - what is the best way if the drawing is done at 800 x 600 to fit it into different div sizes ie 200 x 150 ? \r\n\r\nI can scale it with ctx.scale(0.25,0.25) and use <canvas width="200" height="150"> but this doesn't appear right - it seems to want the scale to be proportional. \r\n\r\ncss sizing simply makes it fuzzy so not a good way to go. Any ideas? ","link":"http://stackoverflow.com/questions/2024691/scaling-logo-in-html5-canvas","title":"scaling logo in html5 <canvas>?","body":"

Having trouble scaling with . It seems to make sense to code up a drawing in canvas to a fixed size (ie 800x600) then scale it for specific locations - but sizing occurs in 4 places: 1) in the context definition (ie ctx.width = 800 2) with ctx.scale; 3) in html with \n\n

I can scale it with ctx.scale(0.25,0.25) and use but this doesn't appear right - it seems to want the scale to be proportional.

\n\n

css sizing simply makes it fuzzy so not a good way to go. Any ideas?

\n"},{"answers":[{"owner":{"reputation":4993,"user_id":1185262,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5a3d9f0dcb7b133e92d2cd76e748702d?s=128&d=identicon&r=PG","display_name":"jesse mcconnell","link":"http://stackoverflow.com/users/1185262/jesse-mcconnell"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1342216018,"creation_date":1342216018,"answer_id":11478817,"question_id":11473294,"body_markdown":"\r\n1) http://wiki.eclipse.org/Jetty/Howto/Configure_SSL\r\n\r\n2) http://git.codehaus.org/gitweb.cgi?p=jetty-project.git;a=tree;f=jetty-win32;h=e296255dc355f3abf37bf3f4faddfe383505416c;hb=HEAD\r\n\r\nYou'll need to adapt that for you particular usage, we stopped building it with release quite a while back because its license changed and the version we were using was getting crufty. Alternately take a look at the updated version of the tanuki stuff and if you can handle the license use that.\r\n","link":"http://stackoverflow.com/questions/11473294/jetty-v8-x-how-to-configure-enable-ssl-for-https-and-steps-to-create-windows/11478817#11478817","body":"

1) http://wiki.eclipse.org/Jetty/Howto/Configure_SSL

\n\n

2) http://git.codehaus.org/gitweb.cgi?p=jetty-project.git;a=tree;f=jetty-win32;h=e296255dc355f3abf37bf3f4faddfe383505416c;hb=HEAD

\n\n

You'll need to adapt that for you particular usage, we stopped building it with release quite a while back because its license changed and the version we were using was getting crufty. Alternately take a look at the updated version of the tanuki stuff and if you can handle the license use that.

\n"}],"tags":["ssl","windows-services","web","jetty","maven-plugin"],"owner":{"reputation":11,"user_id":1523915,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/3b66d237299929f0f0468c363ad29017?s=128&d=identicon&r=PG","display_name":"Sandy Dalal","link":"http://stackoverflow.com/users/1523915/sandy-dalal"},"comment_count":0,"is_answered":false,"view_count":5482,"answer_count":1,"score":2,"last_activity_date":1414773417,"creation_date":1342192438,"last_edit_date":1343053146,"question_id":11473294,"body_markdown":"I have currently deployed a war file in my Jetty 8.x webapps container. I can start the Jetty server and connect to my server using HTTP. I want to be able to connect using HTTPS. What is the easiest way to enable HTTPS on Jetty 8.x? I am willing to use a self-signed certificate if necesssary. \r\n\r\nI need the following:\r\n\r\na) steps to generate and import cert into Jetty (preferably using a self-signed cert)\r\nb) configuration required in Jetty to support HTTPS / SSL\r\nc) command line parameters to start Jetty with SSL enabled\r\n\r\nSecondly, is anyone aware of how to turn Jetty 8.x so that it can be run as a Windows service?\r\n\r\nFor more details, I am running into problems enabling SSL on Jetty. I am trying to use a self signed cert for this purpose. I'm using keytool to create a keypair and self signed cert as follows:\r\n\r\nkeytool -genkey -alias domain -keyalg RSA -keysize 2048 -validity 365 -keystore keystore\r\n\r\nI then copy the keystore to my c:\\jetty\\etc directory. I edit the file 'jetty-ssl.xml' to make sure that the HTTPS port is set to 8443. When I restart the Jetty server, it seems to be listening on port 8443 and the startup sequence doesn't return any errors. However, when I try to connect using HTTPS, I get errors. Is there a prescribed method for generating a self signed cert and using this cert in the SSL configuration with Jetty?\r\n","link":"http://stackoverflow.com/questions/11473294/jetty-v8-x-how-to-configure-enable-ssl-for-https-and-steps-to-create-windows","title":"Jetty v8.x - How to Configure / Enable SSL for HTTPS and steps to create Windows Service","body":"

I have currently deployed a war file in my Jetty 8.x webapps container. I can start the Jetty server and connect to my server using HTTP. I want to be able to connect using HTTPS. What is the easiest way to enable HTTPS on Jetty 8.x? I am willing to use a self-signed certificate if necesssary.

\n\n

I need the following:

\n\n

a) steps to generate and import cert into Jetty (preferably using a self-signed cert)\nb) configuration required in Jetty to support HTTPS / SSL\nc) command line parameters to start Jetty with SSL enabled

\n\n

Secondly, is anyone aware of how to turn Jetty 8.x so that it can be run as a Windows service?

\n\n

For more details, I am running into problems enabling SSL on Jetty. I am trying to use a self signed cert for this purpose. I'm using keytool to create a keypair and self signed cert as follows:

\n\n

keytool -genkey -alias domain -keyalg RSA -keysize 2048 -validity 365 -keystore keystore

\n\n

I then copy the keystore to my c:\\jetty\\etc directory. I edit the file 'jetty-ssl.xml' to make sure that the HTTPS port is set to 8443. When I restart the Jetty server, it seems to be listening on port 8443 and the startup sequence doesn't return any errors. However, when I try to connect using HTTPS, I get errors. Is there a prescribed method for generating a self signed cert and using this cert in the SSL configuration with Jetty?

\n"},{"answers":[{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"comments":[{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365221777,"post_id":15846934,"comment_id":22550772},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365221907,"post_id":15846934,"comment_id":22550799},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365222180,"post_id":15846934,"comment_id":22550842},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365222547,"post_id":15846934,"comment_id":22550893},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365224712,"post_id":15846934,"comment_id":22551194},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365225150,"post_id":15846934,"comment_id":22551271},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365225521,"post_id":15846934,"comment_id":22551340},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"reply_to_user":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365225616,"post_id":15846934,"comment_id":22551355},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"reply_to_user":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"edited":false,"score":0,"creation_date":1365225735,"post_id":15846934,"comment_id":22551385},{"owner":{"reputation":243,"user_id":1421379,"user_type":"registered","accept_rate":20,"profile_image":"https://www.gravatar.com/avatar/75fe583f071ca51f6ec29aca635f3c22?s=128&d=identicon&r=PG","display_name":"L K","link":"http://stackoverflow.com/users/1421379/l-k"},"edited":false,"score":0,"creation_date":1378907543,"post_id":15846934,"comment_id":27624201},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1379060514,"post_id":15846934,"comment_id":27691408}],"last_editor":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"comment_count":11,"is_accepted":false,"score":-1,"last_activity_date":1365224281,"last_edit_date":1365224281,"creation_date":1365221597,"answer_id":15846934,"question_id":15846864,"body_markdown":"In gridview you have to define an event `onselectedindexchanged` and `onrowdatabound` as below:\r\n\r\n onselectedindexchanged="GridView1_SelectedIndexChanged" onrowdatabound="GridView1_RowDataBound" \r\n\r\n**to show the selected row you can use following style in your grid view:**\r\n\r\n <SelectedRowStyle BackColor="Red" />\r\n\r\n**in code behind:**\r\n\r\n protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n }\r\n\r\n protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)\r\n {\r\n\r\n if (e.Row.RowType == DataControlRowType.DataRow)\r\n {\r\n // Set the hand mouse cursor for the selected row.\r\n e.Row.Attributes.Add("OnMouseOver", "this.style.cursor = 'hand';");\r\n\r\n // The seelctButton exists for ensuring the selection functionality\r\n // and bind it with the appropriate event hanlder.\r\n LinkButton selectButton = new LinkButton()\r\n {\r\n CommandName = "Select",\r\n Text = e.Row.Cells[0].Text\r\n };\r\n selectButton.Font.Underline = false;\r\n selectButton.ForeColor = Color.Black;\r\n\r\n e.Row.Cells[0].Controls.Add(selectButton);\r\n //e.Row.Attributes["OnClick"] =\r\n // Page.ClientScript.GetPostBackClientHyperlink(selectButton, "");\r\n e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);\r\n }\r\n }\r\n**note:** you can find the event in event window. ","link":"http://stackoverflow.com/questions/15846864/asp-net-gridview-enabling-row-selection/15846934#15846934","body":"

In gridview you have to define an event onselectedindexchanged and onrowdatabound as below:

\n\n
onselectedindexchanged=\"GridView1_SelectedIndexChanged\"  onrowdatabound=\"GridView1_RowDataBound\"  \n
\n\n

to show the selected row you can use following style in your grid view:

\n\n
 <SelectedRowStyle BackColor=\"Red\" />\n
\n\n

in code behind:

\n\n
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\n{\n}\n\nprotected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)\n{\n\nif (e.Row.RowType == DataControlRowType.DataRow)\n    {\n        // Set the hand mouse cursor for the selected row.\n        e.Row.Attributes.Add(\"OnMouseOver\", \"this.style.cursor = 'hand';\");\n\n        // The seelctButton exists for ensuring the selection functionality\n        // and bind it with the appropriate event hanlder.\n        LinkButton selectButton = new LinkButton()\n        {\n            CommandName = \"Select\",\n            Text = e.Row.Cells[0].Text\n        };\n        selectButton.Font.Underline = false;\n        selectButton.ForeColor = Color.Black;\n\n        e.Row.Cells[0].Controls.Add(selectButton);\n        //e.Row.Attributes[\"OnClick\"] =\n        //     Page.ClientScript.GetPostBackClientHyperlink(selectButton, \"\");\n        e.Row.Attributes[\"onclick\"] =         ClientScript.GetPostBackClientHyperlink(this.GridView1, \"Select$\" + e.Row.RowIndex);\n    }\n    }\n
\n\n

note: you can find the event in event window.

\n"},{"owner":{"reputation":88,"user_id":1280840,"user_type":"registered","accept_rate":79,"profile_image":"https://www.gravatar.com/avatar/9b82e77b6f30e662a608503adaef33bb?s=128&d=identicon&r=PG","display_name":"user1280840","link":"http://stackoverflow.com/users/1280840/user1280840"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1393235291,"creation_date":1393235291,"answer_id":21984059,"question_id":15846864,"body_markdown":"I think the MultiSelect and SelectionMode properties are only available with the VB.NET grid, not in ASP.NET. Bear in mind that all controls in ASP.NET are HTML-in-disguise, so they may be more limited. There is no reason why you can't have a multi-select table, but you have to do the plumbing yourself. So you need to enable row selection, either by handling the RowDataBound event as in\r\n\r\nhttp://forums.asp.net/t/992062.aspx?How+to+select+row+in+gridview+on+click\r\n\r\nor else using the MS-provided option as in\r\n\r\nhttp://msdn.microsoft.com/en-us/library/wbk82279(v=vs.100).aspx\r\n\r\nThen you need to handle the SelectedIndexChanging event, figure out which row the user clicked on, and handle the row-colouring yourself.","link":"http://stackoverflow.com/questions/15846864/asp-net-gridview-enabling-row-selection/21984059#21984059","body":"

I think the MultiSelect and SelectionMode properties are only available with the VB.NET grid, not in ASP.NET. Bear in mind that all controls in ASP.NET are HTML-in-disguise, so they may be more limited. There is no reason why you can't have a multi-select table, but you have to do the plumbing yourself. So you need to enable row selection, either by handling the RowDataBound event as in

\n\n

http://forums.asp.net/t/992062.aspx?How+to+select+row+in+gridview+on+click

\n\n

or else using the MS-provided option as in

\n\n

http://msdn.microsoft.com/en-us/library/wbk82279(v=vs.100).aspx

\n\n

Then you need to handle the SelectedIndexChanging event, figure out which row the user clicked on, and handle the row-colouring yourself.

\n"}],"tags":["asp.net","gridview"],"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"comments":[{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365222954,"post_id":15846864,"comment_id":22550950},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223369,"post_id":15846864,"comment_id":22550996},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"reply_to_user":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223531,"post_id":15846864,"comment_id":22551021},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223587,"post_id":15846864,"comment_id":22551029},{"owner":{"reputation":430,"user_id":1134412,"user_type":"registered","accept_rate":53,"profile_image":"http://i.stack.imgur.com/cm9Gg.jpg?s=128&g=1","display_name":"chathura2020","link":"http://stackoverflow.com/users/1134412/chathura2020"},"reply_to_user":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365223677,"post_id":15846864,"comment_id":22551042},{"owner":{"reputation":395,"user_id":1896787,"user_type":"registered","accept_rate":56,"profile_image":"http://i.stack.imgur.com/cJFvJ.jpg?s=128&g=1","display_name":"Code Rider","link":"http://stackoverflow.com/users/1896787/code-rider"},"edited":false,"score":0,"creation_date":1365224325,"post_id":15846864,"comment_id":22551141}],"comment_count":6,"is_answered":false,"view_count":10711,"answer_count":2,"score":0,"last_activity_date":1414773417,"creation_date":1365220696,"last_edit_date":1365223257,"question_id":15846864,"body_markdown":"I am using GridView in asp.net. I want to select a single data row. I looked for MultiSelect and SelectionMode in property panel, but I can't find it. \r\n\r\nSo how to enable selecting rows in GridView? \r\n\r\nThanks.\r\n\r\n![enter image description here][1]\r\n [1]: http://i.stack.imgur.com/6jJ7Q.jpg\r\n\r\nCode Behind\r\n\r\n public partial class SearchCourse : System.Web.UI.Page\r\n {\r\n Connection dbCon;\r\n DataTable tbl;\r\n\r\n protected void Page_Load(object sender, EventArgs e)\r\n {\r\n dbCon = new Connection();\r\n \r\n \r\n }\r\n protected void RadioButton1_CheckedChanged(object sender, EventArgs e)\r\n {\r\n if (RadioButton1.Checked) {\r\n txtSubName.Enabled = true;\r\n comboSemester.Enabled = false;\r\n comboYear.Enabled = false;\r\n comboProgram.Enabled =false;\r\n txtSubName.Text = "";\r\n }\r\n }\r\n protected void RadioButton2_CheckedChanged(object sender, EventArgs e)\r\n {\r\n if (RadioButton2.Checked) {\r\n\r\n comboProgram.Enabled = true;\r\n\r\n if (comboProgram.SelectedItem.ToString() == "Foundation Course")\r\n {\r\n comboSemester.Enabled = false;\r\n comboYear.Enabled = false;\r\n }\r\n else {\r\n comboSemester.Enabled = true;\r\n comboYear.Enabled = true;\r\n }\r\n txtSubName.Text = "";\r\n txtSubName.Enabled = false;\r\n }\r\n }\r\n\r\n protected void imgBtnSearch_Click(object sender, ImageClickEventArgs e)\r\n {\r\n if (RadioButton1.Checked) {\r\n String name = txtSubName.Text;\r\n tbl = dbCon.getResultsBySubjectName(name);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n else if (RadioButton2.Checked)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year = comboYear.SelectedItem.ToString();\r\n String sem= comboSemester.SelectedItem.ToString();\r\n tbl = dbCon.getResultsByProgram(program,year,sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n else if (RadioButton3.Checked)\r\n {\r\n String name = txtSubName.Text;\r\n tbl = dbCon.getResultsBySubjectNo(name);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n \r\n }\r\n\r\n protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year, sem;\r\n if (program == "Foundation Course")\r\n {\r\n comboYear.Enabled = false;\r\n comboSemester.Enabled = false;\r\n year = null;\r\n sem = null;\r\n }\r\n else {\r\n comboYear.Enabled = true;\r\n comboSemester.Enabled = true;\r\n year = comboYear.SelectedItem.ToString();\r\n sem = comboSemester.SelectedItem.ToString();\r\n }\r\n\r\n tbl = dbCon.getResultsByProgram(program, year, sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n\r\n protected void comboYear_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year = comboYear.SelectedItem.ToString();\r\n String sem = comboSemester.SelectedItem.ToString();\r\n tbl = dbCon.getResultsByProgram(program, year, sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n }\r\n protected void comboSemester_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n String program = comboProgram.SelectedItem.ToString();\r\n String year = comboYear.SelectedItem.ToString();\r\n String sem = comboSemester.SelectedItem.ToString();\r\n tbl = dbCon.getResultsByProgram(program, year, sem);\r\n GridView1.DataSource = tbl;\r\n GridView1.DataBind();\r\n \r\n }\r\n\r\n\r\n \r\n protected void RadioButton3_CheckedChanged(object sender, EventArgs e)\r\n {\r\n if (RadioButton3.Checked)\r\n {\r\n txtSubName.Enabled = true;\r\n comboSemester.Enabled = false;\r\n comboYear.Enabled = false;\r\n comboProgram.Enabled = false;\r\n txtSubName.Text = "";\r\n }\r\n }\r\n protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\r\n {\r\n \r\n }\r\n}\r\n\r\n**GridView Code** \r\n\r\n <asp:GridView ID="GridView1" CssClass="grid" runat="server" AllowPaging="True" \r\n BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" \r\n GridLines="Horizontal" EnableViewState="False" \r\n PageSize="5" onselectedindexchanged="GridView1_SelectedIndexChanged" >\r\n \r\n <HeaderStyle ForeColor="White" />\r\n \r\n <RowStyle CssClass="gridRow" Width="800px" />\r\n \r\n <SelectedRowStyle BackColor="#FF0066" ForeColor="White" />\r\n \r\n </asp:GridView> ","link":"http://stackoverflow.com/questions/15846864/asp-net-gridview-enabling-row-selection","title":"Asp.net GridView Enabling row selection","body":"

I am using GridView in asp.net. I want to select a single data row. I looked for MultiSelect and SelectionMode in property panel, but I can't find it.

\n\n

So how to enable selecting rows in GridView?

\n\n

Thanks.

\n\n

\"enter\nCode Behind

\n\n
public partial class SearchCourse : System.Web.UI.Page\n{\nConnection dbCon;\nDataTable tbl;\n\nprotected void Page_Load(object sender, EventArgs e)\n{\n    dbCon = new Connection();\n\n\n}\nprotected void RadioButton1_CheckedChanged(object sender, EventArgs e)\n{\n    if (RadioButton1.Checked) {\n        txtSubName.Enabled = true;\n        comboSemester.Enabled = false;\n        comboYear.Enabled = false;\n        comboProgram.Enabled =false;\n        txtSubName.Text = \"\";\n    }\n}\nprotected void RadioButton2_CheckedChanged(object sender, EventArgs e)\n{\n    if (RadioButton2.Checked) {\n\n        comboProgram.Enabled = true;\n\n        if (comboProgram.SelectedItem.ToString() == \"Foundation Course\")\n        {\n            comboSemester.Enabled = false;\n            comboYear.Enabled = false;\n        }\n        else {\n            comboSemester.Enabled = true;\n            comboYear.Enabled = true;\n        }\n        txtSubName.Text = \"\";\n        txtSubName.Enabled = false;\n    }\n}\n\nprotected void imgBtnSearch_Click(object sender, ImageClickEventArgs e)\n{\n    if (RadioButton1.Checked) {\n        String name = txtSubName.Text;\n        tbl = dbCon.getResultsBySubjectName(name);\n        GridView1.DataSource = tbl;\n        GridView1.DataBind();\n    }\n    else if (RadioButton2.Checked)\n    {\n        String program = comboProgram.SelectedItem.ToString();\n        String year = comboYear.SelectedItem.ToString();\n        String sem= comboSemester.SelectedItem.ToString();\n        tbl = dbCon.getResultsByProgram(program,year,sem);\n        GridView1.DataSource = tbl;\n        GridView1.DataBind();\n    }\n    else if (RadioButton3.Checked)\n        {\n            String name = txtSubName.Text;\n            tbl = dbCon.getResultsBySubjectNo(name);\n            GridView1.DataSource = tbl;\n            GridView1.DataBind();\n        }\n\n}\n\nprotected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)\n{\n    String program = comboProgram.SelectedItem.ToString();\n    String year, sem;\n    if (program == \"Foundation Course\")\n    {\n        comboYear.Enabled = false;\n        comboSemester.Enabled = false;\n        year = null;\n        sem = null;\n    }\n    else {\n        comboYear.Enabled = true;\n        comboSemester.Enabled = true;\n        year = comboYear.SelectedItem.ToString();\n        sem = comboSemester.SelectedItem.ToString();\n    }\n\n    tbl = dbCon.getResultsByProgram(program, year, sem);\n    GridView1.DataSource = tbl;\n    GridView1.DataBind();\n}\n\nprotected void comboYear_SelectedIndexChanged(object sender, EventArgs e)\n{\n    String program = comboProgram.SelectedItem.ToString();\n    String year = comboYear.SelectedItem.ToString();\n    String sem = comboSemester.SelectedItem.ToString();\n    tbl = dbCon.getResultsByProgram(program, year, sem);\n    GridView1.DataSource = tbl;\n    GridView1.DataBind();\n}\nprotected void comboSemester_SelectedIndexChanged(object sender, EventArgs e)\n{\n    String program = comboProgram.SelectedItem.ToString();\n    String year = comboYear.SelectedItem.ToString();\n    String sem = comboSemester.SelectedItem.ToString();\n    tbl = dbCon.getResultsByProgram(program, year, sem);\n    GridView1.DataSource = tbl;\n    GridView1.DataBind();\n\n}\n\n\n\nprotected void RadioButton3_CheckedChanged(object sender, EventArgs e)\n{\n    if (RadioButton3.Checked)\n    {\n        txtSubName.Enabled = true;\n        comboSemester.Enabled = false;\n        comboYear.Enabled = false;\n        comboProgram.Enabled = false;\n        txtSubName.Text = \"\";\n    }\n}\nprotected void GridView1_SelectedIndexChanged(object sender, EventArgs e)\n{\n\n}\n
\n\n

}

\n\n

GridView Code

\n\n
<asp:GridView ID=\"GridView1\" CssClass=\"grid\" runat=\"server\" AllowPaging=\"True\" \nBorderColor=\"Black\" BorderStyle=\"Solid\" BorderWidth=\"2px\" \nGridLines=\"Horizontal\"  EnableViewState=\"False\" \nPageSize=\"5\"   onselectedindexchanged=\"GridView1_SelectedIndexChanged\" >\n
\n\n

\n\n
<RowStyle CssClass=\"gridRow\" Width=\"800px\" />\n\n<SelectedRowStyle BackColor=\"#FF0066\" ForeColor=\"White\" />\n\n</asp:GridView> \n
\n"},{"answers":[{"owner":{"reputation":2958,"user_id":1161743,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/18aebb65726f793706e6bba28e921420?s=128&d=identicon&r=PG","display_name":"Jonathan Lin","link":"http://stackoverflow.com/users/1161743/jonathan-lin"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1386680460,"creation_date":1386680460,"answer_id":20495291,"question_id":20495112,"body_markdown":"In each of your `KFZFragment`, `LogFragment`, and `TrackFragment`, you should be able to override `onResume` in your fragment class and put your necessary refresh/reload code there.","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager/20495291#20495291","body":"

In each of your KFZFragment, LogFragment, and TrackFragment, you should be able to override onResume in your fragment class and put your necessary refresh/reload code there.

\n"},{"owner":{"reputation":76,"user_id":1806231,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/3f432d5ca5a2d177e9c4a89ffaf55606?s=128&d=identicon&r=PG","display_name":"user1806231","link":"http://stackoverflow.com/users/1806231/user1806231"},"comments":[{"owner":{"reputation":3176,"user_id":1501613,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/a917ec0fd44810a1c18dac1822198994?s=128&d=identicon&r=PG&f=1","display_name":"cYrixmorten","link":"http://stackoverflow.com/users/1501613/cyrixmorten"},"edited":false,"score":0,"creation_date":1386682879,"post_id":20495692,"comment_id":30635018}],"comment_count":1,"is_accepted":false,"score":0,"last_activity_date":1386681583,"creation_date":1386681583,"answer_id":20495692,"question_id":20495112,"body_markdown":"Why not? use static methods to refresh the data ","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager/20495692#20495692","body":"

Why not? use static methods to refresh the data

\n"},{"owner":{"reputation":3176,"user_id":1501613,"user_type":"registered","accept_rate":75,"profile_image":"https://www.gravatar.com/avatar/a917ec0fd44810a1c18dac1822198994?s=128&d=identicon&r=PG&f=1","display_name":"cYrixmorten","link":"http://stackoverflow.com/users/1501613/cyrixmorten"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1386681623,"creation_date":1386681623,"answer_id":20495703,"question_id":20495112,"body_markdown":"I agree with Jonathan Lin\r\n\r\nBut if the fragment you want to update is the fragment that is currently shown you can do something similar to this:\r\n\r\n public class DisplayPagerAdapter extends FragmentPagerAdapter {\r\n\t\r\n private static final String TAG = "DisplayPagerAdapter";\r\n \r\n\tSparseArray<DisplayFragment> registeredFragments = new SparseArray<DisplayFragment>();\r\n\r\n public DisplayPagerAdapter(FragmentManager fm) {\r\n super(fm);\r\n }\r\n\r\n @Override\r\n public int getCount() {\r\n \tDisplayCoreModule display = DisplayCoreModule.getInstance();\r\n return (display != null && display.getPagesCount() > 0) ? display.getPagesCount() : 1;\r\n }\r\n \r\n @Override\r\n public int getItemPosition(Object object) {\r\n return POSITION_NONE;\r\n }\r\n \r\n\r\n @Override\r\n public Fragment getItem(int position) {\r\n \tLog.d(TAG, "getItem " + position);\r\n return DisplayFragment.newInstance(position); \r\n }\r\n\r\n @Override\r\n public CharSequence getPageTitle(int position) {\r\n \tDisplayCoreModule display = DisplayCoreModule.getInstance();\r\n \tif (display != null && display.getPagesCount() > 0) {\r\n \t\treturn "Side " + (position+1);\r\n \t} else {\r\n \t\treturn super.getPageTitle(position);\r\n \t}\r\n }\r\n \r\n @Override\r\n public Object instantiateItem(ViewGroup container, int position) {\r\n \tLog.d(TAG, "instantiateItem " + position);\r\n \tDisplayFragment fragment = (DisplayFragment) super.instantiateItem(container, position);\r\n registeredFragments.put(position, fragment);\r\n return fragment;\r\n }\r\n\r\n @Override\r\n public void destroyItem(ViewGroup container, int position, Object object) {\r\n \tLog.d(TAG, "destroyItem " + position);\r\n registeredFragments.remove(position);\r\n super.destroyItem(container, position, object);\r\n }\r\n\r\n public Fragment getRegisteredFragment(int position) {\r\n return registeredFragments.get(position);\r\n }\r\n \r\n public SparseArray<DisplayFragment> getRegisteredFragments() {\r\n return registeredFragments;\r\n }\r\n\r\n }\r\n\r\nIt is the registeredFragments part that I wanted to show you.\r\n\r\nSince you use FragmentPagerAdapter then getRegisteredFragment(int position) will always return one of your fragments given that you provide a valid position. Should you change to FragmentStatePagerAdapter at some point, it can return null on some of the positions.\r\n\r\nNow, in TrackFragment create a callback to your MainActivity, which then informs LogFragment, shown here in pseudo code:\r\n\r\n Fragment TrackFragment {\r\n \r\n interface TrackFragmentCallback() {\r\n public void newInfo()\r\n }\r\n\r\n TrackFragmentCallback trackFragmentCallback;\r\n\r\n onAttatch() {\r\n // make sure to implement TrackFragmentCallback on MainActivity \r\n trackFragmentCallback = (TrackFragmentCallback)getActivity();\r\n } \r\n\r\n // When this fragment has new info, simply do:\r\n trackFragmentCallback.newInfo();\r\n }\r\n\r\n MainActivity implements TrackFragmentCallback {\r\n\r\n newInfo() {\r\n // get LogFragment\r\n LogFragment logFragment = pagerAdapter.getRegisteredFragment(1); \r\n if (logFragment != null) {\r\n logFragment.update();\r\n }\r\n }\r\n }\r\n\r\n\r\nHope this helps.","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager/20495703#20495703","body":"

I agree with Jonathan Lin

\n\n

But if the fragment you want to update is the fragment that is currently shown you can do something similar to this:

\n\n
public class DisplayPagerAdapter extends FragmentPagerAdapter {\n\nprivate static final String TAG = \"DisplayPagerAdapter\";\n\nSparseArray<DisplayFragment> registeredFragments = new SparseArray<DisplayFragment>();\n\npublic DisplayPagerAdapter(FragmentManager fm) {\n    super(fm);\n}\n\n@Override\npublic int getCount() {\n    DisplayCoreModule display = DisplayCoreModule.getInstance();\n    return (display != null && display.getPagesCount() > 0) ? display.getPagesCount() : 1;\n}\n\n@Override\npublic int getItemPosition(Object object) {\n    return POSITION_NONE;\n}\n\n\n@Override\npublic Fragment getItem(int position) {\n    Log.d(TAG, \"getItem \" + position);\n    return DisplayFragment.newInstance(position); \n}\n\n@Override\npublic CharSequence getPageTitle(int position) {\n    DisplayCoreModule display = DisplayCoreModule.getInstance();\n    if (display != null && display.getPagesCount() > 0) {\n        return \"Side \" + (position+1);\n    } else {\n        return super.getPageTitle(position);\n    }\n}\n\n@Override\npublic Object instantiateItem(ViewGroup container, int position) {\n    Log.d(TAG, \"instantiateItem \" + position);\n    DisplayFragment fragment = (DisplayFragment) super.instantiateItem(container, position);\n    registeredFragments.put(position, fragment);\n    return fragment;\n}\n\n@Override\npublic void destroyItem(ViewGroup container, int position, Object object) {\n    Log.d(TAG, \"destroyItem \" + position);\n    registeredFragments.remove(position);\n    super.destroyItem(container, position, object);\n}\n\npublic Fragment getRegisteredFragment(int position) {\n    return registeredFragments.get(position);\n}\n\npublic SparseArray<DisplayFragment> getRegisteredFragments() {\n    return registeredFragments;\n}\n\n}\n
\n\n

It is the registeredFragments part that I wanted to show you.

\n\n

Since you use FragmentPagerAdapter then getRegisteredFragment(int position) will always return one of your fragments given that you provide a valid position. Should you change to FragmentStatePagerAdapter at some point, it can return null on some of the positions.

\n\n

Now, in TrackFragment create a callback to your MainActivity, which then informs LogFragment, shown here in pseudo code:

\n\n
Fragment TrackFragment  {\n\n    interface TrackFragmentCallback() {\n        public void newInfo()\n    }\n\n    TrackFragmentCallback trackFragmentCallback;\n\n    onAttatch() {\n        // make sure to implement TrackFragmentCallback on MainActivity \n        trackFragmentCallback = (TrackFragmentCallback)getActivity();\n    } \n\n    // When this fragment has new info, simply do:\n    trackFragmentCallback.newInfo();\n}\n\nMainActivity implements TrackFragmentCallback {\n\n    newInfo() {\n        // get LogFragment\n        LogFragment logFragment = pagerAdapter.getRegisteredFragment(1); \n        if (logFragment != null) {\n            logFragment.update();\n        }\n    }\n}\n
\n\n

Hope this helps.

\n"}],"tags":["android","android-fragments","android-viewpager"],"owner":{"reputation":135,"user_id":2940365,"user_type":"registered","accept_rate":67,"profile_image":"https://www.gravatar.com/avatar/692463659bb2037320958e5d3dcaf628?s=128&d=identicon&r=PG&f=1","display_name":"aut_silvia","link":"http://stackoverflow.com/users/2940365/aut-silvia"},"comment_count":0,"is_answered":false,"view_count":7048,"answer_count":3,"score":0,"last_activity_date":1414773417,"creation_date":1386679957,"question_id":20495112,"body_markdown":"I know there are already some questions to this problem. But I am really new in Android and ecspecially to `Fragments` and `Viewpager`. Pls have passion with me. I didn't found a answer which fits to my code.\r\n\r\nI dont know how to refresh a fragment or reload it when it's "active" again.\r\n\r\n**TabsPagerAdapter.java:**\r\n\r\n public class TabsPagerAdapter extends FragmentPagerAdapter{\r\n \r\n \t\r\n \tpublic TabsPagerAdapter(FragmentManager fm){\r\n \t\tsuper(fm);\r\n \t}\r\n \r\n \t@Override\r\n \tpublic Fragment getItem(int index) {\r\n \t\t\r\n \t\tswitch (index) {\r\n case 0:\r\n \r\n return new KFZFragment();\r\n case 1:\r\n \r\n return new LogFragment();\r\n case 2:\r\n \r\n return new TrackFragment();\r\n }\r\n \r\n return null;\r\n \t}\r\n \t\r\n \t@Override\r\n \tpublic int getCount() {\r\n \t\t// get item count - equal to number of tabs\r\n \t\treturn 3;\r\n \t}\r\n \r\n }\r\n\r\nI have this 3 Fragments (`KFZFragment,LogFragment,TrackFragment`) and on the `TrackFragment` I calculate some data and this data should be display in a ListView in `LogFragment`.\r\nBut when I change to LogFragment it's not the latest data. So it doesnt refresh.\r\n\r\nNow how should I modify my code to refresh the fragments when it's "active"?\r\n\r\n\r\n**MainActivityFragment.java:**\r\n\r\n public class MainActivityFragment extends FragmentActivity implements ActionBar.TabListener{\r\n \r\n \tprivate ViewPager viewPager;\r\n private TabsPagerAdapter mAdapter;\r\n private ActionBar actionBar;\r\n List<Fragment> fragments;\r\n \r\n private String[] tabs = { "KFZ", "Fahrten Log", "Kosten Track" };\r\n \r\n @Override\r\n protected void onCreate(Bundle savedInstanceState) {\r\n super.onCreate(savedInstanceState);\r\n setContentView(R.layout.activity_main_fragment);\r\n \r\n // Initilization\r\n viewPager = (ViewPager) findViewById(R.id.pager);\r\n actionBar = getActionBar();\r\n mAdapter = new TabsPagerAdapter(getSupportFragmentManager());\r\n \r\n fragments = new Vector<Fragment>();\r\n fragments.add(Fragment.instantiate(this, KFZFragment.class.getName(),savedInstanceState));\r\n fragments.add(Fragment.instantiate(this, LogFragment.class.getName(),savedInstanceState));\r\n \r\n viewPager.setAdapter(mAdapter);\r\n actionBar.setHomeButtonEnabled(false);\r\n actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); \r\n \r\n // Adding Tabs\r\n for (String tab_name : tabs) {\r\n actionBar.addTab(actionBar.newTab().setText(tab_name)\r\n .setTabListener(this));\r\n }\r\n \r\n viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {\r\n \t \r\n @Override\r\n public void onPageSelected(int position) {\r\n // on changing the page\r\n // make respected tab selected\r\n actionBar.setSelectedNavigationItem(position);\r\n \r\n }\r\n \r\n @Override\r\n public void onPageScrolled(int arg0, float arg1, int arg2) {\r\n }\r\n \r\n @Override\r\n public void onPageScrollStateChanged(int arg0) {\r\n }\r\n });\r\n } \r\n \t@Override\r\n \tpublic void onTabReselected(Tab tab, FragmentTransaction ft) {\r\n \t\t// TODO Auto-generated method stub\r\n \t\t\r\n \t}\r\n \r\n \t@Override\r\n \tpublic void onTabSelected(Tab tab, FragmentTransaction ft) {\r\n \t\tviewPager.setCurrentItem(tab.getPosition());\r\n \t\t\r\n \t}\r\n \r\n \t@Override\r\n \tpublic void onTabUnselected(Tab tab, FragmentTransaction ft) {\r\n \t\t// TODO Auto-generated method stub\r\n \t\t\r\n \t}\r\n \t\r\n \t@Override\r\n \tpublic boolean onKeyDown(int keyCode, KeyEvent event) {\r\n \t if (keyCode == KeyEvent.KEYCODE_BACK) {\r\n \r\n \t \r\n \t }\r\n \t return super.onKeyDown(keyCode, event);\r\n \t}\r\n \r\n }\r\n\r\nPls help me out.","link":"http://stackoverflow.com/questions/20495112/how-to-refresh-a-fragment-in-a-viewpager","title":"How to refresh a fragment in a viewpager?","body":"

I know there are already some questions to this problem. But I am really new in Android and ecspecially to Fragments and Viewpager. Pls have passion with me. I didn't found a answer which fits to my code.

\n\n

I dont know how to refresh a fragment or reload it when it's \"active\" again.

\n\n

TabsPagerAdapter.java:

\n\n
public class TabsPagerAdapter extends FragmentPagerAdapter{\n\n\n    public TabsPagerAdapter(FragmentManager fm){\n        super(fm);\n    }\n\n    @Override\n    public Fragment getItem(int index) {\n\n        switch (index) {\n        case 0:\n\n            return new KFZFragment();\n        case 1:\n\n            return new LogFragment();\n        case 2:\n\n            return new TrackFragment();\n        }\n\n        return null;\n    }\n\n    @Override\n    public int getCount() {\n        // get item count - equal to number of tabs\n        return 3;\n    }\n\n}\n
\n\n

I have this 3 Fragments (KFZFragment,LogFragment,TrackFragment) and on the TrackFragment I calculate some data and this data should be display in a ListView in LogFragment.\nBut when I change to LogFragment it's not the latest data. So it doesnt refresh.

\n\n

Now how should I modify my code to refresh the fragments when it's \"active\"?

\n\n

MainActivityFragment.java:

\n\n
public class MainActivityFragment extends FragmentActivity implements ActionBar.TabListener{\n\n    private ViewPager viewPager;\n    private TabsPagerAdapter mAdapter;\n    private ActionBar actionBar;\n    List<Fragment> fragments;\n\n    private String[] tabs = { \"KFZ\", \"Fahrten Log\", \"Kosten Track\" };\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main_fragment);\n\n        // Initilization\n        viewPager = (ViewPager) findViewById(R.id.pager);\n        actionBar = getActionBar();\n        mAdapter = new TabsPagerAdapter(getSupportFragmentManager());\n\n       fragments = new Vector<Fragment>();\n        fragments.add(Fragment.instantiate(this, KFZFragment.class.getName(),savedInstanceState));\n        fragments.add(Fragment.instantiate(this, LogFragment.class.getName(),savedInstanceState));\n\n        viewPager.setAdapter(mAdapter);\n        actionBar.setHomeButtonEnabled(false);\n        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);        \n\n        // Adding Tabs\n        for (String tab_name : tabs) {\n            actionBar.addTab(actionBar.newTab().setText(tab_name)\n                    .setTabListener(this));\n        }\n\n        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {\n\n            @Override\n            public void onPageSelected(int position) {\n                // on changing the page\n                // make respected tab selected\n                actionBar.setSelectedNavigationItem(position);\n\n            }\n\n            @Override\n            public void onPageScrolled(int arg0, float arg1, int arg2) {\n            }\n\n            @Override\n            public void onPageScrollStateChanged(int arg0) {\n            }\n        });\n    }   \n    @Override\n    public void onTabReselected(Tab tab, FragmentTransaction ft) {\n        // TODO Auto-generated method stub\n\n    }\n\n    @Override\n    public void onTabSelected(Tab tab, FragmentTransaction ft) {\n        viewPager.setCurrentItem(tab.getPosition());\n\n    }\n\n    @Override\n    public void onTabUnselected(Tab tab, FragmentTransaction ft) {\n        // TODO Auto-generated method stub\n\n    }\n\n    @Override\n    public boolean onKeyDown(int keyCode, KeyEvent event) {\n        if (keyCode == KeyEvent.KEYCODE_BACK) {\n\n\n        }\n        return super.onKeyDown(keyCode, event);\n    }\n\n}\n
\n\n

Pls help me out.

\n"},{"tags":["ios","cordova","phonecalls"],"owner":{"reputation":23,"user_id":939075,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/25489fce3562ca05a170ca3846233f2b?s=128&d=identicon&r=PG","display_name":"Rodrigo Gil","link":"http://stackoverflow.com/users/939075/rodrigo-gil"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773414,"creation_date":1414773414,"question_id":26679416,"body_markdown":"I need to start a telephone call and I am using this code (that works perfectly):\r\n\r\n NSString *phoneCallNum = [NSString stringWithFormat:@"tel://%@",phoneNumber];\r\n\r\n [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\r\n\r\nBut I need to check if the call was connected or simply the call ended without connect.\r\n\r\nI found that Core Telephony notifies this using something like:\r\n\r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\r\n object:[UIApplication sharedApplication]];\r\n \r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\r\n\r\nSo how can I link both? I tried this code:\r\n\r\n - (void)callNumber:(CDVInvokedUrlCommand*)command\r\n {\r\n CDVPluginResult* pluginResult = nil;\r\n NSString* phoneNumber = [command.arguments objectAtIndex:0];\r\n \r\n self.callbackID = command.callbackId;\r\n \r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\r\n object:[UIApplication sharedApplication]];\r\n \r\n [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\r\n \r\n NSString *phoneCallNum = [NSString stringWithFormat:@"tel://%@",phoneNumber];\r\n\r\n [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\r\n\r\n NSLog(@"phone btn touch %@", phoneCallNum);\r\n }\r\n\r\n - (void) callConnected: (NSNotification *)notification\r\n {\r\n BOOL succeeded = YES;\r\n NSLog(@"Call connected");\r\n }\r\n\r\nThanks in advance,\r\n\r\nRodrigo.","link":"http://stackoverflow.com/questions/26679416/check-if-a-call-was-connected-on-ios","title":"check if a call was connected on iOS","body":"

I need to start a telephone call and I am using this code (that works perfectly):

\n\n
NSString *phoneCallNum = [NSString stringWithFormat:@\"tel://%@\",phoneNumber];\n\n[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\n
\n\n

But I need to check if the call was connected or simply the call ended without connect.

\n\n

I found that Core Telephony notifies this using something like:

\n\n
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\n                                           object:[UIApplication sharedApplication]];\n\n[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\n
\n\n

So how can I link both? I tried this code:

\n\n
- (void)callNumber:(CDVInvokedUrlCommand*)command\n{\n   CDVPluginResult* pluginResult = nil;\n   NSString* phoneNumber = [command.arguments objectAtIndex:0];\n\n   self.callbackID = command.callbackId;\n\n   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected\n                                           object:[UIApplication sharedApplication]];\n\n   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:[UIApplication sharedApplication]];\n\n   NSString *phoneCallNum = [NSString stringWithFormat:@\"tel://%@\",phoneNumber];\n\n   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneCallNum]];\n\n   NSLog(@\"phone btn touch %@\", phoneCallNum);\n}\n\n- (void) callConnected: (NSNotification *)notification\n{\n   BOOL succeeded = YES;\n   NSLog(@\"Call connected\");\n}\n
\n\n

Thanks in advance,

\n\n

Rodrigo.

\n"},{"tags":["java","postgresql","maven","jooq"],"owner":{"reputation":103,"user_id":669378,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/321895588335717d7855b0e70c64b646?s=128&d=identicon&r=PG","display_name":"csgeek","link":"http://stackoverflow.com/users/669378/csgeek"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773414,"creation_date":1414773414,"question_id":26679415,"body_markdown":"I'm trying to use maven to auto generate pojo for my postgres database. Though even if I take maven out of the equation I have the issue.\r\n\r\nMy data is split upon multiple schemas, and I'll need to work with all of them in my code base. I'd like to know how I can accomplish this short of setting up a task for each one of them in maven. This is what I have so far.\r\n\r\nObviously this only seems to work for a single schema. I'd like to be able to generate POJOs for multiple ones. I tried multiple xml elements, or comma delimited but it just errors out.\r\n\r\n```\r\n mvn -PDBGen generate-sources #is the command i use\r\n ```\r\n\r\n <?xml version="1.0" encoding="UTF-8"?>\r\n <project xmlns="http://maven.apache.org/POM/4.0.0"\r\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r\n <modelVersion>4.0.0</modelVersion>\r\n \r\n <groupId>com.foobar.sandbox</groupId>\r\n <artifactId>playBox</artifactId>\r\n <version>1.0-SNAPSHOT</version>\r\n <packaging>war</packaging>\r\n \r\n <properties>\r\n <jooq-version>3.4.4</jooq-version>\r\n <psql-version>9.1-901-1.jdbc4</psql-version>\r\n </properties>\r\n \r\n <profiles>\r\n <profile>\r\n <id>DBGen</id>\r\n \r\n <build>\r\n <plugins>\r\n \r\n <!-- Maven Auto Generation -->\r\n <plugin>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq-codegen-maven</artifactId>\r\n <version>${jooq-version}</version>\r\n \r\n <!-- The plugin should hook into the generate goal -->\r\n <executions>\r\n <execution>\r\n <goals>\r\n <goal>generate</goal>\r\n </goals>\r\n </execution>\r\n </executions>\r\n \r\n <!-- Manage the plugin's dependency. In this example, we'll use a PostgreSQL database -->\r\n <dependencies>\r\n <dependency>\r\n <groupId>postgresql</groupId>\r\n <artifactId>postgresql</artifactId>\r\n <version>${psql-version}</version>\r\n </dependency>\r\n </dependencies>\r\n \r\n <!-- Specify the plugin configuration.\r\n The configuration format is the same as for the standalone code generator -->\r\n <configuration>\r\n \r\n <!-- JDBC connection parameters -->\r\n <jdbc>\r\n <driver>org.postgresql.Driver</driver>\r\n <url>jdbc:postgresql://localhost:5433/mydb</url>\r\n <user>user</user>\r\n <password>s3cret</password>\r\n </jdbc>\r\n \r\n <!-- Generator parameters -->\r\n <generator>\r\n <name>org.jooq.util.DefaultGenerator</name>\r\n <database>\r\n <name>org.jooq.util.postgres.PostgresDatabase</name>\r\n <includes>.*</includes>\r\n <inputSchema>ui</inputSchema>\r\n <excludes></excludes>\r\n </database>\r\n <target>\r\n <packageName>com.foobar.playbox.jooq.generated</packageName>\r\n <directory>target/generated-sources/jooq</directory>\r\n </target>\r\n </generator>\r\n </configuration>\r\n </plugin>\r\n </plugins>\r\n </build>\r\n </profile>\r\n \r\n </profiles>\r\n \r\n \r\n <build>\r\n <plugins>\r\n <!-- compiler -->\r\n <plugin>\r\n <artifactId>maven-compiler-plugin</artifactId>\r\n <version>3.1</version>\r\n <configuration>\r\n <source>1.7</source>\r\n <target>1.7</target>\r\n </configuration>\r\n </plugin>\r\n <plugin>\r\n <groupId>org.codehaus.mojo</groupId>\r\n <artifactId>build-helper-maven-plugin</artifactId>\r\n <executions>\r\n <execution>\r\n <phase>generate-sources</phase>\r\n <goals>\r\n <goal>add-source</goal>\r\n </goals>\r\n <configuration>\r\n <sources>\r\n <source>target/generated-sources/jooq</source>\r\n </sources>\r\n </configuration>\r\n </execution>\r\n </executions>\r\n </plugin>\r\n \r\n </plugins>\r\n </build>\r\n \r\n \r\n <dependencies>\r\n <!-- postgres -->\r\n <dependency>\r\n <groupId>postgresql</groupId>\r\n <artifactId>postgresql</artifactId>\r\n <version>${psql-version}</version>\r\n </dependency>\r\n <!-- mysql -->\r\n <dependency>\r\n <groupId>mysql</groupId>\r\n <artifactId>mysql-connector-java</artifactId>\r\n <version>5.1.33</version>\r\n </dependency>\r\n <!-- DataBase -->\r\n <dependency>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq</artifactId>\r\n <version>${jooq-version}</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq-meta</artifactId>\r\n <version>${jooq-version}</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>org.jooq</groupId>\r\n <artifactId>jooq-codegen</artifactId>\r\n <version>${jooq-version}</version>\r\n </dependency>\r\n <!-- Logging -->\r\n <dependency>\r\n <groupId>org.slf4j</groupId>\r\n <artifactId>slf4j-api</artifactId>\r\n <version>1.7.7</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>org.slf4j</groupId>\r\n <artifactId>slf4j-log4j12</artifactId>\r\n <version>1.7.7</version>\r\n </dependency>\r\n <dependency>\r\n <groupId>log4j</groupId>\r\n <artifactId>log4j</artifactId>\r\n <version>1.2.16</version>\r\n </dependency>\r\n <!-- Test -->\r\n <dependency>\r\n <groupId>org.mockito</groupId>\r\n <artifactId>mockito-all</artifactId>\r\n <version>1.9.5</version>\r\n <scope>test</scope>\r\n </dependency>\r\n </dependencies>\r\n \r\n </project>","link":"http://stackoverflow.com/questions/26679415/jooq-maven-and-multiple-schemas","title":"Jooq Maven and multiple schemas","body":"

I'm trying to use maven to auto generate pojo for my postgres database. Though even if I take maven out of the equation I have the issue.

\n\n

My data is split upon multiple schemas, and I'll need to work with all of them in my code base. I'd like to know how I can accomplish this short of setting up a task for each one of them in maven. This is what I have so far.

\n\n

Obviously this only seems to work for a single schema. I'd like to be able to generate POJOs for multiple ones. I tried multiple xml elements, or comma delimited but it just errors out.

\n\n

\n mvn -PDBGen generate-sources #is the command i use\n

\n\n
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <groupId>com.foobar.sandbox</groupId>\n    <artifactId>playBox</artifactId>\n    <version>1.0-SNAPSHOT</version>\n    <packaging>war</packaging>\n\n    <properties>\n        <jooq-version>3.4.4</jooq-version>\n        <psql-version>9.1-901-1.jdbc4</psql-version>\n    </properties>\n\n    <profiles>\n        <profile>\n            <id>DBGen</id>\n\n            <build>\n                <plugins>\n\n                    <!-- Maven Auto Generation -->\n                    <plugin>\n                        <groupId>org.jooq</groupId>\n                        <artifactId>jooq-codegen-maven</artifactId>\n                        <version>${jooq-version}</version>\n\n                        <!-- The plugin should hook into the generate goal -->\n                        <executions>\n                            <execution>\n                                <goals>\n                                    <goal>generate</goal>\n                                </goals>\n                            </execution>\n                        </executions>\n\n                        <!-- Manage the plugin's dependency. In this example, we'll use a PostgreSQL database -->\n                        <dependencies>\n                            <dependency>\n                                <groupId>postgresql</groupId>\n                                <artifactId>postgresql</artifactId>\n                                <version>${psql-version}</version>\n                            </dependency>\n                        </dependencies>\n\n                        <!-- Specify the plugin configuration.\n                             The configuration format is the same as for the standalone code generator -->\n                        <configuration>\n\n                            <!-- JDBC connection parameters -->\n                            <jdbc>\n                                <driver>org.postgresql.Driver</driver>\n                                <url>jdbc:postgresql://localhost:5433/mydb</url>\n                                <user>user</user>\n                                <password>s3cret</password>\n                            </jdbc>\n\n                            <!-- Generator parameters -->\n                            <generator>\n                                <name>org.jooq.util.DefaultGenerator</name>\n                                <database>\n                                    <name>org.jooq.util.postgres.PostgresDatabase</name>\n                                    <includes>.*</includes>\n                                    <inputSchema>ui</inputSchema>\n                                    <excludes></excludes>\n                                </database>\n                                <target>\n                                    <packageName>com.foobar.playbox.jooq.generated</packageName>\n                                    <directory>target/generated-sources/jooq</directory>\n                                </target>\n                            </generator>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </build>\n        </profile>\n\n    </profiles>\n\n\n    <build>\n        <plugins>\n            <!-- compiler -->\n            <plugin>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.1</version>\n                <configuration>\n                    <source>1.7</source>\n                    <target>1.7</target>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.codehaus.mojo</groupId>\n                <artifactId>build-helper-maven-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <phase>generate-sources</phase>\n                        <goals>\n                            <goal>add-source</goal>\n                        </goals>\n                        <configuration>\n                            <sources>\n                                <source>target/generated-sources/jooq</source>\n                            </sources>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n\n        </plugins>\n    </build>\n\n\n    <dependencies>\n        <!-- postgres -->\n        <dependency>\n            <groupId>postgresql</groupId>\n            <artifactId>postgresql</artifactId>\n            <version>${psql-version}</version>\n        </dependency>\n        <!-- mysql -->\n        <dependency>\n            <groupId>mysql</groupId>\n            <artifactId>mysql-connector-java</artifactId>\n            <version>5.1.33</version>\n        </dependency>\n        <!-- DataBase -->\n        <dependency>\n            <groupId>org.jooq</groupId>\n            <artifactId>jooq</artifactId>\n            <version>${jooq-version}</version>\n        </dependency>\n        <dependency>\n            <groupId>org.jooq</groupId>\n            <artifactId>jooq-meta</artifactId>\n            <version>${jooq-version}</version>\n        </dependency>\n        <dependency>\n            <groupId>org.jooq</groupId>\n            <artifactId>jooq-codegen</artifactId>\n            <version>${jooq-version}</version>\n        </dependency>\n        <!-- Logging -->\n        <dependency>\n            <groupId>org.slf4j</groupId>\n            <artifactId>slf4j-api</artifactId>\n            <version>1.7.7</version>\n        </dependency>\n        <dependency>\n            <groupId>org.slf4j</groupId>\n            <artifactId>slf4j-log4j12</artifactId>\n            <version>1.7.7</version>\n        </dependency>\n        <dependency>\n            <groupId>log4j</groupId>\n            <artifactId>log4j</artifactId>\n            <version>1.2.16</version>\n        </dependency>\n        <!-- Test -->\n        <dependency>\n            <groupId>org.mockito</groupId>\n            <artifactId>mockito-all</artifactId>\n            <version>1.9.5</version>\n            <scope>test</scope>\n        </dependency>\n    </dependencies>\n\n</project>\n
\n"},{"tags":["sharepoint","sharepoint-2010","sharepoint-2013","event-receiver","sharepoint-feature"],"owner":{"reputation":1390,"user_id":34683,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/28ebb0bf4b489823ac766ad87c87ba9b?s=128&d=identicon&r=PG","display_name":"GR7","link":"http://stackoverflow.com/users/34683/gr7"},"comment_count":0,"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1414773410,"creation_date":1414773410,"question_id":26679412,"body_markdown":"I'm very new to SharePoint development, and I'm just trying to add an XML file to a Feature to reference the XML file content in the feature Event Receiver.\r\n\r\nIt seems that the general recommendation is to use do so like in this SO question:\r\n\r\nhttp://stackoverflow.com/questions/5571028/how-to-retreive-data-from-an-xml-file-in-a-sharepoint-2010-feature-event-recieve\r\n\r\nHowever, my code does not compile when I reference the RootDirectory property. The error I see is below\r\n\r\n'Microsoft.SharePoint.Administration.SPFeatureDefinition' does not contain a definition for 'RootDirectory' and no extension method 'RootDirectory' accepting a first argument of type 'Microsoft.SharePoint.Administration.SPFeatureDefinition' could be found (are you missing a using directive or an assembly reference?\r\n\r\nNow, the weird part is that while debugging, I am able to evaluate the RootDirectory property correctly in the Quick Debug window.\r\n\r\nAm I missing something obvious? Like I said, I'm completely new to SharePoint.\r\n\r\nMy feature is scoped to the Web level, and I do have a reference to Microsoft.Sharepoint.Administration in my using statements.\r\n\r\nAny help is greatly appreciated, thanks.","link":"http://stackoverflow.com/questions/26679412/how-to-fix-spfeaturedefinition-does-not-contain-a-definition-for-rootdirectory","title":"How to fix SPFeatureDefinition does not contain a definition for RootDirectory","body":"

I'm very new to SharePoint development, and I'm just trying to add an XML file to a Feature to reference the XML file content in the feature Event Receiver.

\n\n

It seems that the general recommendation is to use do so like in this SO question:

\n\n

How to retreive data from an XML file in a sharepoint 2010 Feature Event Reciever?

\n\n

However, my code does not compile when I reference the RootDirectory property. The error I see is below

\n\n

'Microsoft.SharePoint.Administration.SPFeatureDefinition' does not contain a definition for 'RootDirectory' and no extension method 'RootDirectory' accepting a first argument of type 'Microsoft.SharePoint.Administration.SPFeatureDefinition' could be found (are you missing a using directive or an assembly reference?

\n\n

Now, the weird part is that while debugging, I am able to evaluate the RootDirectory property correctly in the Quick Debug window.

\n\n

Am I missing something obvious? Like I said, I'm completely new to SharePoint.

\n\n

My feature is scoped to the Web level, and I do have a reference to Microsoft.Sharepoint.Administration in my using statements.

\n\n

Any help is greatly appreciated, thanks.

\n"},{"answers":[{"owner":{"reputation":203,"user_id":579343,"user_type":"registered","accept_rate":71,"profile_image":"https://www.gravatar.com/avatar/896cde12ae62bb66f06773cd53f15233?s=128&d=identicon&r=PG","display_name":"cksum","link":"http://stackoverflow.com/users/579343/cksum"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1295335187,"creation_date":1295335187,"answer_id":4721427,"question_id":4721396,"body_markdown":"No. Serial numbers are optional on USB drives. Some manufacturers use them, others do not.","link":"http://stackoverflow.com/questions/4721396/every-usb-flash-drives-manufactured-by-any-company-have-unique-serial-key-or-not/4721427#4721427","body":"

No. Serial numbers are optional on USB drives. Some manufacturers use them, others do not.

\n"}],"tags":["usb","key","serial-number","usb-flash-drive"],"owner":{"reputation":6,"user_id":579533,"user_type":"unregistered","profile_image":"https://www.gravatar.com/avatar/daca322d8b0fa69c61a5661340d67029?s=128&d=identicon&r=PG","display_name":"prajjwal shakya","link":"http://stackoverflow.com/users/579533/prajjwal-shakya"},"comment_count":0,"is_answered":true,"view_count":422,"answer_count":1,"score":1,"last_activity_date":1414773410,"creation_date":1295334926,"last_edit_date":1414773410,"question_id":4721396,"body_markdown":"I would like to know, if every usb flash drives manufactured by any company have unique serial key or not? If yes, can we retrieve it using any programming languages.","link":"http://stackoverflow.com/questions/4721396/every-usb-flash-drives-manufactured-by-any-company-have-unique-serial-key-or-not","title":"every usb flash drives manufactured by any company have unique serial key or not?","body":"

I would like to know, if every usb flash drives manufactured by any company have unique serial key or not? If yes, can we retrieve it using any programming languages.

\n"},{"answers":[{"owner":{"reputation":26812,"user_id":717214,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/9075315c5f4b734a8f2567be54a4cc45?s=128&d=identicon&r=PG","display_name":"Aleks G","link":"http://stackoverflow.com/users/717214/aleks-g"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1414773311,"creation_date":1414773311,"answer_id":26679386,"question_id":26679341,"body_markdown":"Just url-decode the value before returning. Replace\r\n\r\n return sParameterName[1];\r\n\r\nwith \r\n\r\n return decodeURIComponent(sParameterName[1]);","link":"http://stackoverflow.com/questions/26679341/function-geturlparametersparam-is-returning-20-as-white-space-on-page/26679386#26679386","body":"

Just url-decode the value before returning. Replace

\n\n
return sParameterName[1];\n
\n\n

with

\n\n
return decodeURIComponent(sParameterName[1]);\n
\n"},{"owner":{"reputation":386,"user_id":3509191,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/20154f137f9370563e03d9ca04d4552d?s=128&d=identicon&r=PG","display_name":"JonathanAMcCann","link":"http://stackoverflow.com/users/3509191/jonathanamccann"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773410,"creation_date":1414773410,"answer_id":26679413,"question_id":26679341,"body_markdown":"The text you are seeing is what's called `url-encoded`. You simply need to decode it before displaying it:\r\n\r\n function GetURLParameter(sParam)\r\n { \r\n var sPageURL = window.location.search.substring(1);\r\n var sURLVariables = sPageURL.split('&');\r\n for (var i = 0; i < sURLVariables.length; i++) \r\n {\r\n var sParameterName = sURLVariables[i].split('=');\r\n if (sParameterName[0] == sParam) \r\n {\r\n return return decodeURIComponent(sParameterName[1]);\r\n }\r\n }\r\n }","link":"http://stackoverflow.com/questions/26679341/function-geturlparametersparam-is-returning-20-as-white-space-on-page/26679413#26679413","body":"

The text you are seeing is what's called url-encoded. You simply need to decode it before displaying it:

\n\n
function GetURLParameter(sParam)\n   {   \n     var sPageURL = window.location.search.substring(1);\n     var sURLVariables = sPageURL.split('&');\n     for (var i = 0; i < sURLVariables.length; i++) \n  {\n    var sParameterName = sURLVariables[i].split('=');\n    if (sParameterName[0] == sParam) \n    {\n        return return decodeURIComponent(sParameterName[1]);\n    }\n  }\n}\n
\n"}],"tags":["javascript","jquery"],"owner":{"reputation":1,"user_id":4203170,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/61cdd93e5c204e75065074a99cda76ec?s=128&d=identicon&r=PG&f=1","display_name":"drm930","link":"http://stackoverflow.com/users/4203170/drm930"},"comment_count":0,"is_answered":true,"view_count":18,"answer_count":2,"score":0,"last_activity_date":1414773410,"creation_date":1414773150,"last_edit_date":1414773238,"question_id":26679341,"body_markdown":"I have this code that pulls the URL parameter into the landing page, the issue is it is pulling white space in as %20. So if my url parameter is:\r\nexample.com/?title=my website it wil display my%20website on the page i want it to display my website without the %20. Here is the code\r\n\r\n\r\n function GetURLParameter(sParam)\r\n { \r\n var sPageURL = window.location.search.substring(1);\r\n var sURLVariables = sPageURL.split('&');\r\n for (var i = 0; i < sURLVariables.length; i++) \r\n {\r\n var sParameterName = sURLVariables[i].split('=');\r\n if (sParameterName[0] == sParam) \r\n {\r\n return sParameterName[1];\r\n }\r\n }\r\n }\r\n\r\n (function ($) {\r\n // fire once DOM is loaded\r\n $(document).ready(function() {\r\n // set the cookie name\r\n var cookie_name = 'node-title';\r\n // get the "phone" URL param\r\n var phone_number = GetURLParameter('title');\r\n // check if there is a phone number in the URL\r\n if (phone_number) {\r\n // set the cookie\r\n $.cookie(cookie_name, phone_number, { path: '/' });\r\n }\r\n // get the phone cookie value\r\n var phone_cookie = $.cookie(cookie_name);\r\n // check if there is a value set in the phone cookie\r\n if (phone_cookie) {\r\n // swap the phone number\r\n $('.' + cookie_name).html(phone_cookie);\r\n // update the href too\r\n $('a.' + cookie_name).attr('href', 'tel://' + phone_cookie);\r\n }\r\n });\r\n })(jQuery);\r\n\r\n","link":"http://stackoverflow.com/questions/26679341/function-geturlparametersparam-is-returning-20-as-white-space-on-page","title":"function GetURLParameter(sParam) is returning %20 as white space on page","body":"

I have this code that pulls the URL parameter into the landing page, the issue is it is pulling white space in as %20. So if my url parameter is:\nexample.com/?title=my website it wil display my%20website on the page i want it to display my website without the %20. Here is the code

\n\n
function GetURLParameter(sParam)\n   {   \n     var sPageURL = window.location.search.substring(1);\n     var sURLVariables = sPageURL.split('&');\n     for (var i = 0; i < sURLVariables.length; i++) \n  {\n    var sParameterName = sURLVariables[i].split('=');\n    if (sParameterName[0] == sParam) \n    {\n        return sParameterName[1];\n    }\n  }\n  }\n\n(function ($) {\n// fire once DOM is loaded\n$(document).ready(function() {\n    // set the cookie name\n    var cookie_name = 'node-title';\n    // get the \"phone\" URL param\n    var phone_number = GetURLParameter('title');\n    // check if there is a phone number in the URL\n    if (phone_number) {\n        // set the cookie\n        $.cookie(cookie_name, phone_number, { path: '/' });\n    }\n    // get the phone cookie value\n    var phone_cookie = $.cookie(cookie_name);\n    // check if there is a value set in the phone cookie\n    if (phone_cookie) {\n        // swap the phone number\n        $('.' + cookie_name).html(phone_cookie);\n        // update the href too\n        $('a.' + cookie_name).attr('href', 'tel://' + phone_cookie);\n    }\n    });\n    })(jQuery);\n
\n"},{"answers":[{"owner":{"reputation":2468,"user_id":2679518,"user_type":"registered","accept_rate":89,"profile_image":"https://www.gravatar.com/avatar/edd2a1f8eda8121add9c4fc9d4d544e0?s=128&d=identicon&r=PG&f=1","display_name":"John Paul","link":"http://stackoverflow.com/users/2679518/john-paul"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773320,"creation_date":1414773320,"answer_id":26679391,"question_id":26678702,"body_markdown":"You need to pass a list of limits to the `xyplot`. Here I did that outside of the `xyplot` but you could do that right in the `scales` argument if you wish.\r\n\r\n library(lattice)\r\n size <- rep(c("da","db","ca","cb"),each=5) \r\n age <- rep(1:5,4)\r\n growth <- rep(c(-75,-55,-25,-20),each=5)\r\n test <- data.frame(size,age,growth)\r\n\r\n YLims<-list(c(-20,30),c(-20,30),c(-50,-80),c(-50,-80) )\r\n\r\n xyplot(growth~age|factor(size),\r\n layout=c(2,2), \r\n type=c("p","g"), \r\n scales=list(x=list(tick.number=3), y=list(relation="free", limits=YLims)), \r\n ylab="growth %",xlab="age",pch=20,col="black", data=test)\r\n\r\n![enter image description here][1]\r\n\r\n\r\n [1]: http://i.stack.imgur.com/ywhc2.jpg","link":"http://stackoverflow.com/questions/26678702/lattice-separate-y-axes-for-row-of-xyplot/26679391#26679391","body":"

You need to pass a list of limits to the xyplot. Here I did that outside of the xyplot but you could do that right in the scales argument if you wish.

\n\n
library(lattice)\nsize <- rep(c(\"da\",\"db\",\"ca\",\"cb\"),each=5) \nage <- rep(1:5,4)\ngrowth <- rep(c(-75,-55,-25,-20),each=5)\ntest <- data.frame(size,age,growth)\n\nYLims<-list(c(-20,30),c(-20,30),c(-50,-80),c(-50,-80) )\n\nxyplot(growth~age|factor(size),\n   layout=c(2,2), \n   type=c(\"p\",\"g\"), \n   scales=list(x=list(tick.number=3), y=list(relation=\"free\", limits=YLims)), \n   ylab=\"growth %\",xlab=\"age\",pch=20,col=\"black\",  data=test)\n
\n\n

\"enter

\n"}],"tags":["r","lattice"],"owner":{"reputation":16,"user_id":1632334,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ca33bb312b676687386535c8cac0e77d?s=128&d=identicon&r=PG","display_name":"ma-d","link":"http://stackoverflow.com/users/1632334/ma-d"},"comment_count":0,"is_answered":false,"view_count":7,"answer_count":1,"score":0,"last_activity_date":1414773409,"creation_date":1414770944,"last_edit_date":1414773409,"question_id":26678702,"body_markdown":"I wish to have the same y-axis limits for a row of an `xyplot` with a 2 by 2 display. Neither `scales = "free"`, nor `scales = "sliced"` will achieve this. \r\n\r\n### toy example\r\n\r\n size <- rep(c("da","db","ca","cb"),each=5) \r\n age <- rep(1:5,4) \r\n growth <- rep(c(-75,-55,-25,-20),each=5) \r\n\r\n test <- data.frame(size,age,growth)\r\n\r\n\r\n xyplot(growth~age|factor(size),layout=c(2,2),\r\n type=c("p","g"),\r\n scales=list(x=list(tick.number=3)),\r\n ylab="growth %",xlab="age",pch=20,col="black",\r\n data=test)\r\n\r\nin this case I would like to have (in base graphics): `ylim=c(-50,-80)` for the first row and `y=c(-20,-30)` for the second row.","link":"http://stackoverflow.com/questions/26678702/lattice-separate-y-axes-for-row-of-xyplot","title":"lattice separate y axes for row of xyplot","body":"

I wish to have the same y-axis limits for a row of an xyplot with a 2 by 2 display. Neither scales = \"free\", nor scales = \"sliced\" will achieve this.

\n\n

toy example

\n\n
size <- rep(c(\"da\",\"db\",\"ca\",\"cb\"),each=5)  \nage <- rep(1:5,4)  \ngrowth <- rep(c(-75,-55,-25,-20),each=5)  \n\ntest <- data.frame(size,age,growth)\n\n\nxyplot(growth~age|factor(size),layout=c(2,2),\n type=c(\"p\",\"g\"),\n scales=list(x=list(tick.number=3)),\n ylab=\"growth %\",xlab=\"age\",pch=20,col=\"black\",\n data=test)\n
\n\n

in this case I would like to have (in base graphics): ylim=c(-50,-80) for the first row and y=c(-20,-30) for the second row.

\n"},{"answers":[{"owner":{"reputation":23767,"user_id":1415724,"user_type":"registered","accept_rate":82,"profile_image":"http://i.stack.imgur.com/uBEOB.jpg?s=128&g=1","display_name":"Fred -ii-","link":"http://stackoverflow.com/users/1415724/fred-ii"},"comments":[{"owner":{"reputation":7086,"user_id":999553,"user_type":"registered","accept_rate":95,"profile_image":"https://www.gravatar.com/avatar/b7519342f152f031523782cf1ee44f09?s=128&d=identicon&r=PG","display_name":"Set Sail Media","link":"http://stackoverflow.com/users/999553/set-sail-media"},"edited":false,"score":1,"creation_date":1414772061,"post_id":26679013,"comment_id":41957032},{"owner":{"reputation":23767,"user_id":1415724,"user_type":"registered","accept_rate":82,"profile_image":"http://i.stack.imgur.com/uBEOB.jpg?s=128&g=1","display_name":"Fred -ii-","link":"http://stackoverflow.com/users/1415724/fred-ii"},"reply_to_user":{"reputation":7086,"user_id":999553,"user_type":"registered","accept_rate":95,"profile_image":"https://www.gravatar.com/avatar/b7519342f152f031523782cf1ee44f09?s=128&d=identicon&r=PG","display_name":"Set Sail Media","link":"http://stackoverflow.com/users/999553/set-sail-media"},"edited":false,"score":0,"creation_date":1414772094,"post_id":26679013,"comment_id":41957046}],"last_editor":{"reputation":23767,"user_id":1415724,"user_type":"registered","accept_rate":82,"profile_image":"http://i.stack.imgur.com/uBEOB.jpg?s=128&g=1","display_name":"Fred -ii-","link":"http://stackoverflow.com/users/1415724/fred-ii"},"comment_count":2,"is_accepted":false,"score":0,"last_activity_date":1414772676,"last_edit_date":1414772676,"creation_date":1414772045,"answer_id":26679013,"question_id":26678972,"body_markdown":"Change `$body, "From:" . $headers)` to `$body, $headers)` \r\n\r\nYou already have the `From:` in:\r\n\r\n $headers = "From: Staff <contacto@evento.com>"...\r\n\r\nPlus as noted in comments, change and remove the `"To:" .`\r\n\r\n mail( "To:" . $memberemail , "Nuevo registro", $body, "From:" . $headers);\r\n\r\nto\r\n\r\n mail($memberemail, "Nuevo registro", $body, $headers);\r\n\r\n\r\n\r\nMail automatically sets the first parameter as the recipient `To:`\r\n\r\nHowever, you may have wanted to use `$youremail` as the first parameter and `$memberemail` as the `From:`, because mail will be sent to the person who sent the Email, but I will let you decide on that.\r\n\r\nConsult the manual:\r\n\r\n - **http://php.net/manual/en/function.mail.php**\r\n\r\n","link":"http://stackoverflow.com/questions/26678972/sender-mail-with-php/26679013#26679013","body":"

Change $body, \"From:\" . $headers) to $body, $headers)

\n\n

You already have the From: in:

\n\n
$headers = \"From: Staff <contacto@evento.com>\"...\n
\n\n

Plus as noted in comments, change and remove the \"To:\" .

\n\n
mail( \"To:\" . $memberemail , \"Nuevo registro\", $body, \"From:\" . $headers);\n
\n\n

to

\n\n
mail($memberemail, \"Nuevo registro\", $body, $headers);\n
\n\n

Mail automatically sets the first parameter as the recipient To:

\n\n

However, you may have wanted to use $youremail as the first parameter and $memberemail as the From:, because mail will be sent to the person who sent the Email, but I will let you decide on that.

\n\n

Consult the manual:

\n\n\n"},{"owner":{"reputation":785,"user_id":467367,"user_type":"registered","accept_rate":60,"profile_image":"https://www.gravatar.com/avatar/b04e055a9c45fe9bdbee2ebe4c2d4957?s=128&d=identicon&r=PG","display_name":"Alexey","link":"http://stackoverflow.com/users/467367/alexey"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414772154,"creation_date":1414772154,"answer_id":26679051,"question_id":26678972,"body_markdown":"I think it has to do with the following:\r\n\r\n1. Set SPF record on evento.com domain to allow this ip or subnet to use this From address. You can use a tool like this: http://www.spfwizard.net/\r\n2. Add PTR record on event.com domain pointing to the IP of the sending host\r\n3. Remove the whole body and try to add line-by-line (making sure content-based spam filters are not in effect)\r\n4. Watch your mail log and see whether it's sent out by MTA and your smarthost response code. \r\n\r\nAnd you should specify what exactly you mean by "stopped working": was it sent out from the server? Did it land into junk box? Was it rejected by your smarthost?\r\n\r\n","link":"http://stackoverflow.com/questions/26678972/sender-mail-with-php/26679051#26679051","body":"

I think it has to do with the following:

\n\n
    \n
  1. Set SPF record on evento.com domain to allow this ip or subnet to use this From address. You can use a tool like this: http://www.spfwizard.net/
  2. \n
  3. Add PTR record on event.com domain pointing to the IP of the sending host
  4. \n
  5. Remove the whole body and try to add line-by-line (making sure content-based spam filters are not in effect)
  6. \n
  7. Watch your mail log and see whether it's sent out by MTA and your smarthost response code.
  8. \n
\n\n

And you should specify what exactly you mean by \"stopped working\": was it sent out from the server? Did it land into junk box? Was it rejected by your smarthost?

\n"}],"tags":["php","email"],"owner":{"reputation":10,"user_id":3588175,"user_type":"registered","accept_rate":50,"profile_image":"http://i.stack.imgur.com/uQelN.jpg?s=128&g=1","display_name":"hmaceves","link":"http://stackoverflow.com/users/3588175/hmaceves"},"comments":[{"owner":{"reputation":456,"user_id":2923632,"user_type":"registered","profile_image":"http://graph.facebook.com/1672665750/picture?type=large","display_name":"Joseph Neathawk","link":"http://stackoverflow.com/users/2923632/joseph-neathawk"},"edited":false,"score":0,"creation_date":1414772024,"post_id":26678972,"comment_id":41957012},{"owner":{"reputation":54,"user_id":2737474,"user_type":"registered","profile_image":"http://graph.facebook.com/100000063508080/picture?type=large","display_name":"Charles Rojas","link":"http://stackoverflow.com/users/2737474/charles-rojas"},"edited":false,"score":1,"creation_date":1414772524,"post_id":26678972,"comment_id":41957259}],"comment_count":2,"is_answered":false,"view_count":25,"answer_count":2,"score":0,"last_activity_date":1414773409,"creation_date":1414771849,"last_edit_date":1414773409,"question_id":26678972,"body_markdown":"I use this code to send mail. But it stopped working when I added the **$headers** and lines to **$body**. Can anyone support me in finding the error or errors? \r\n\r\nI would appreciate the support.\r\n\r\n <?PHP\r\n\r\n // Email Address\r\n $youremail = 'correo@correo.com';\r\n\t$memberemail = $_POST['email'];\r\n\t\r\n // Register Form\r\n if ( isset($_POST['email']) && isset($_POST['name']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {\r\n\r\n // Detect & Prevent Header Injections\r\n $test = "/(content-type|bcc:|cc:|to:)/i";\r\n foreach ( $_POST as $key => $val ) {\r\n if ( preg_match( $test, $val ) ) {\r\n exit;\r\n }\r\n }\r\n\r\n // Email Format\r\n $body = "Hola! $_POST[name]. Gracias por solicitar tu inscripción. \\n";\r\n $body .= "Analizaremos tú solicitud y en caso de resultar positiva recibirás un correo de confirmación en las próximas 24 horas. \\n\\n";\r\n\t\t$body .=\t"Tus datos de solicitud son: \\r\\n"\r\n\t\t$body .=\t"============================ \\r\\n";\r\n $body .= "Nombre: $_POST[name] \\n";\r\n $body .= "eMail: $_POST[email] \\n";\r\n $body .= "Empresa: $_POST[telephone] \\n";\r\n $body .= "Sector: $_POST[ticket] \\n\\n";\r\n\t\t$body .= "Atentamente, \\n";\r\n\t\t$body .= "Staff \\n\\n";\r\n\t\t$body .= "NOTA: Para culaquier duda sobre tu proceso de inscripción te recomendamos leer las preguntas frecuentes en el sito web del evento http://www.evento.com";\r\n\t\t\r\n //Send email\r\n\t\r\n\t\t$headers = "From: Staff <contacto@evento.com>" . "\\r\\n" . "Bcc: admin@evento.com" . "\\r\\n";\r\n\t\t\r\n mail( "To:" . $memberemail , "Nuevo registro", $body, "From:" . $headers);\r\n\r\n }\r\n\r\n // Subscribe Form\r\n if( isset($_POST['subscriber']) && filter_var($_POST['subscriber'], FILTER_VALIDATE_EMAIL) ) {\r\n $data = $_POST['subscriber'] . ";" . "\\n";\r\n $ret = file_put_contents('subscribers.txt', $data, FILE_APPEND | LOCK_EX);\r\n if($ret === false) {\r\n die('Ouch! Al parecer hay un error.');\r\n }\r\n } else {\r\n die('No se pueden enviar los datos.');\r\n }\r\n\r\n ?>","link":"http://stackoverflow.com/questions/26678972/sender-mail-with-php","title":"sender mail with php","body":"

I use this code to send mail. But it stopped working when I added the $headers and lines to $body. Can anyone support me in finding the error or errors?

\n\n

I would appreciate the support.

\n\n
<?PHP\n\n// Email Address\n$youremail = 'correo@correo.com';\n$memberemail = $_POST['email'];\n\n// Register Form\nif ( isset($_POST['email']) && isset($_POST['name']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {\n\n    // Detect & Prevent Header Injections\n    $test = \"/(content-type|bcc:|cc:|to:)/i\";\n    foreach ( $_POST as $key => $val ) {\n        if ( preg_match( $test, $val ) ) {\n            exit;\n        }\n    }\n\n    // Email Format\n    $body  =    \"Hola! $_POST[name]. Gracias por solicitar tu inscripción. \\n\";\n    $body .=    \"Analizaremos tú solicitud y en caso de resultar positiva recibirás un correo de confirmación en las próximas 24 horas. \\n\\n\";\n    $body .=    \"Tus datos de solicitud son: \\r\\n\"\n    $body .=    \"============================ \\r\\n\";\n    $body .=    \"Nombre:  $_POST[name] \\n\";\n    $body .=    \"eMail:  $_POST[email] \\n\";\n    $body .=    \"Empresa:  $_POST[telephone] \\n\";\n    $body .=    \"Sector:  $_POST[ticket] \\n\\n\";\n    $body .=    \"Atentamente, \\n\";\n    $body .=    \"Staff \\n\\n\";\n    $body .=    \"NOTA: Para culaquier duda sobre tu proceso de inscripción te recomendamos leer las preguntas frecuentes en el sito web del evento http://www.evento.com\";\n\n    //Send email\n\n    $headers = \"From: Staff <contacto@evento.com>\" . \"\\r\\n\" . \"Bcc: admin@evento.com\" . \"\\r\\n\";\n\n    mail( \"To:\" . $memberemail , \"Nuevo registro\", $body, \"From:\" . $headers);\n\n}\n\n// Subscribe Form\nif( isset($_POST['subscriber']) && filter_var($_POST['subscriber'], FILTER_VALIDATE_EMAIL) ) {\n    $data = $_POST['subscriber'] . \";\" . \"\\n\";\n    $ret = file_put_contents('subscribers.txt', $data, FILE_APPEND | LOCK_EX);\n    if($ret === false) {\n        die('Ouch! Al parecer hay un error.');\n    }\n} else {\n    die('No se pueden enviar los datos.');\n}\n\n?>\n
\n"},{"answers":[{"owner":{"reputation":15335,"user_id":3859027,"user_type":"registered","profile_image":"http://i.stack.imgur.com/EzRaV.jpg?s=128&g=1","display_name":"Ghost","link":"http://stackoverflow.com/users/3859027/ghost"},"comments":[{"owner":{"reputation":1857,"user_id":240385,"user_type":"registered","accept_rate":77,"profile_image":"http://i.stack.imgur.com/ZEcfq.jpg?s=128&g=1","display_name":"jason","link":"http://stackoverflow.com/users/240385/jason"},"edited":false,"score":0,"creation_date":1414772823,"post_id":26677790,"comment_id":41957411},{"owner":{"reputation":15335,"user_id":3859027,"user_type":"registered","profile_image":"http://i.stack.imgur.com/EzRaV.jpg?s=128&g=1","display_name":"Ghost","link":"http://stackoverflow.com/users/3859027/ghost"},"reply_to_user":{"reputation":1857,"user_id":240385,"user_type":"registered","accept_rate":77,"profile_image":"http://i.stack.imgur.com/ZEcfq.jpg?s=128&g=1","display_name":"jason","link":"http://stackoverflow.com/users/240385/jason"},"edited":false,"score":0,"creation_date":1414773341,"post_id":26677790,"comment_id":41957673}],"comment_count":2,"is_accepted":true,"score":1,"last_activity_date":1414768076,"creation_date":1414768076,"answer_id":26677790,"question_id":26677257,"body_markdown":"No, I wouldn't recommend regex, I strongly recommend build on what you have right now with the use of this beautiful HTML Parser. You could use `->replaceChild` in this case:\r\n\r\n $dom = new DOMDocument;\r\n $dom->loadHTML($getVal);\r\n $xPath = new DOMXPath($dom);\r\n \r\n $spans = $xPath->query('//span');\r\n foreach ($spans as $span) {\r\n \t$class = $xPath->evaluate('string(./@class)', $span);\r\n \tif(strpos($class, 'ice-ins') !== false || $class == '') {\r\n \t\t$span->parentNode->removeChild($span);\r\n \t} elseif(strpos($class, 'ice-del') !== false) {\r\n \t\t$span->parentNode->replaceChild(new DOMText($span->nodeValue), $span);\r\n \t}\r\n }\r\n \r\n $newString = $dom->saveHTML();","link":"http://stackoverflow.com/questions/26677257/php-using-domxpath-to-strip-tags-and-remove-nodes/26677790#26677790","body":"

No, I wouldn't recommend regex, I strongly recommend build on what you have right now with the use of this beautiful HTML Parser. You could use ->replaceChild in this case:

\n\n
$dom = new DOMDocument;\n$dom->loadHTML($getVal);\n$xPath = new DOMXPath($dom);\n\n$spans = $xPath->query('//span');\nforeach ($spans as $span) {\n    $class = $xPath->evaluate('string(./@class)', $span);\n    if(strpos($class, 'ice-ins') !== false || $class == '') {\n        $span->parentNode->removeChild($span);\n    } elseif(strpos($class, 'ice-del') !== false) {\n        $span->parentNode->replaceChild(new DOMText($span->nodeValue), $span);\n    }\n}\n\n$newString = $dom->saveHTML();\n
\n"}],"tags":["php","html","xpath","domdocument"],"owner":{"reputation":1857,"user_id":240385,"user_type":"registered","accept_rate":77,"profile_image":"http://i.stack.imgur.com/ZEcfq.jpg?s=128&g=1","display_name":"jason","link":"http://stackoverflow.com/users/240385/jason"},"comment_count":0,"is_answered":true,"view_count":9,"accepted_answer_id":26677790,"answer_count":1,"score":1,"last_activity_date":1414773405,"creation_date":1414766368,"last_edit_date":1414773405,"question_id":26677257,"body_markdown":"I am trying to work with DOMDocument but I am encountering some problems. I have a string like this:\r\n\r\n Some Content to keep\r\n <span class="ice-cts-1 ice-del" data-changedata="" data-cid="5" data-time="1414514760583" data-userid="1" data-username="Site Administrator" undefined="Site Administrator">\r\n This content should remain, but span around it should be stripped\r\n </span> \r\n Keep this content too\r\n <span>\r\n <span class="ice-cts-1 ice-ins" data-changedata="" data-cid="2" data-time="1414512278297" data-userid="1" data-username="Site Administrator" undefined="Site Administrator">\r\n This whole node should be deleted\r\n </span>\r\n </span>\r\n\r\nWhat I want to do is, if the span has a class like `ice-del` keep the inner content but remove the span tags. If it has `ice-ins`, remove the whole node. \r\n\r\nIf it is just an empty span `<span></span>` remove it as well. This is the code I have:\r\n\r\n //this get the above mentioned string\r\n $getVal = $array['body'][0][$a];\r\n $dom = new DOMDocument;\r\n $dom->loadHTML($getVal );\r\n $xPath = new DOMXPath($dom);\r\n $delNodes = $xPath->query('//span[@class="ice-cts-1 ice-del"]');\r\n $insNodes = $xPath->query('//span[@class="ice-cts-1 ice-ins"]');\r\n \r\n foreach($insNodes as $span){\r\n //reject these changes, so remove whole node\r\n $span->parentNode->removeChild($span);\r\n }\r\n \r\n foreach($delNodes as $span){\r\n //accept these changes, so just strip out the tags but keep the content\r\n }\r\n \r\n $newString = $dom->saveHTML();\r\n\r\nSo, my code works to delete the entire span node, but how do I take a node and strip out it tags but keep its content? \r\n\r\nAlso, how would I just delete and empty span? I'm sure I could do this using regex or replace but I kind of want to do this using the dom.\r\n\r\nthanks","link":"http://stackoverflow.com/questions/26677257/php-using-domxpath-to-strip-tags-and-remove-nodes","title":"PHP Using DOMXPath to strip tags and remove nodes","body":"

I am trying to work with DOMDocument but I am encountering some problems. I have a string like this:

\n\n
Some Content to keep\n<span class=\"ice-cts-1 ice-del\" data-changedata=\"\" data-cid=\"5\" data-time=\"1414514760583\" data-userid=\"1\" data-username=\"Site Administrator\" undefined=\"Site Administrator\">\n     This content should remain, but span around it should be stripped\n</span> \n     Keep this content too\n<span>\n     <span class=\"ice-cts-1 ice-ins\" data-changedata=\"\" data-cid=\"2\" data-time=\"1414512278297\" data-userid=\"1\" data-username=\"Site Administrator\" undefined=\"Site Administrator\">\n         This whole node should be deleted\n     </span>\n</span>\n
\n\n

What I want to do is, if the span has a class like ice-del keep the inner content but remove the span tags. If it has ice-ins, remove the whole node.

\n\n

If it is just an empty span <span></span> remove it as well. This is the code I have:

\n\n
//this get the above mentioned string\n$getVal = $array['body'][0][$a];\n$dom = new DOMDocument;\n$dom->loadHTML($getVal );\n$xPath = new DOMXPath($dom);\n$delNodes = $xPath->query('//span[@class=\"ice-cts-1 ice-del\"]');\n$insNodes = $xPath->query('//span[@class=\"ice-cts-1 ice-ins\"]');\n\nforeach($insNodes as $span){\n    //reject these changes, so remove whole node\n    $span->parentNode->removeChild($span);\n}\n\nforeach($delNodes as $span){\n    //accept these changes, so just strip out the tags but keep the content\n}\n\n$newString = $dom->saveHTML();\n
\n\n

So, my code works to delete the entire span node, but how do I take a node and strip out it tags but keep its content?

\n\n

Also, how would I just delete and empty span? I'm sure I could do this using regex or replace but I kind of want to do this using the dom.

\n\n

thanks

\n"},{"tags":["java","eclipse","encryption"],"owner":{"reputation":3,"user_id":4156518,"user_type":"registered","profile_image":"http://graph.facebook.com/1388992019/picture?type=large","display_name":"Keegan Fargher","link":"http://stackoverflow.com/users/4156518/keegan-fargher"},"comment_count":0,"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1414773399,"creation_date":1414773399,"question_id":26679411,"body_markdown":"I started programming Java a few months ago, and I've recently been assigned to make my own encryption program. Obviously it's just for fun and it does not need to protect government secrets, but can someone give me some tips or ideas on how to go about making my own little encryption program? A bit advanced though. I don't want to just swap characters around using charAt or something... :P\r\n\r\nThanks in advance. :3","link":"http://stackoverflow.com/questions/26679411/encryption-program-homework","title":"Encryption Program (Homework)","body":"

I started programming Java a few months ago, and I've recently been assigned to make my own encryption program. Obviously it's just for fun and it does not need to protect government secrets, but can someone give me some tips or ideas on how to go about making my own little encryption program? A bit advanced though. I don't want to just swap characters around using charAt or something... :P

\n\n

Thanks in advance. :3

\n"},{"answers":[{"owner":{"reputation":266,"user_id":1239976,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/45dbb61d077deedaadf0a13e99d57ff7?s=128&d=identicon&r=PG","display_name":"quzary","link":"http://stackoverflow.com/users/1239976/quzary"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330935589,"creation_date":1330935589,"answer_id":9563531,"question_id":9563479,"body_markdown":"try this:\r\n\r\n $(function(){\r\n var listCells = $.makeArray($("td"));\r\n $("td").click(function(){marked($(this),listCells)}); \r\n });\r\n \r\n \r\n \r\n function marked(o,arr)\r\n {\r\n ...","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563531#9563531","body":"

try this:

\n\n
$(function(){\n    var listCells = $.makeArray($(\"td\"));\n    $(\"td\").click(function(){marked($(this),listCells)});  \n});\n\n\n\nfunction marked(o,arr)\n{\n...\n
\n"},{"owner":{"reputation":2676,"user_id":1045204,"user_type":"registered","accept_rate":40,"profile_image":"https://www.gravatar.com/avatar/f132c45bc2ea922d5a8a7e3818434e8a?s=128&d=identicon&r=PG","display_name":"Hadas","link":"http://stackoverflow.com/users/1045204/hadas"},"last_editor":{"reputation":2330,"user_id":156767,"user_type":"registered","accept_rate":73,"profile_image":"https://www.gravatar.com/avatar/d771736cfe1b549ecaf0ac00a787d8b7?s=128&d=identicon&r=PG","display_name":"Hounshell","link":"http://stackoverflow.com/users/156767/hounshell"},"comment_count":0,"is_accepted":false,"score":4,"last_activity_date":1414773395,"last_edit_date":1414773395,"creation_date":1330935629,"answer_id":9563535,"question_id":9563479,"body_markdown":"Send the element which fire the event to the function like that:\r\n\r\n $("td").click(function(){marked($(this));\r\n return false;\r\n });\r\nand in the function:\r\n \r\n function marked(td)\r\n {\r\n console.log($(td)); \r\n $(td).addClass("marked");\r\n //....\r\n }\r\n\r\nEdited","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563535#9563535","body":"

Send the element which fire the event to the function like that:

\n\n
$(\"td\").click(function(){\n        marked($(this));\n        return false;\n    });\n
\n\n

and in the function:

\n\n
function marked(td)\n{\n     console.log($(td));  \n     $(td).addClass(\"marked\");\n     //....\n}\n
\n"},{"owner":{"reputation":323856,"user_id":69083,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1db0cdfd3fe268e270ec481a73046c2f?s=128&d=identicon&r=PG","display_name":"Guffa","link":"http://stackoverflow.com/users/69083/guffa"},"comments":[{"owner":{"reputation":175763,"user_id":139459,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/4Su7A.jpg?s=128&g=1","display_name":"Sarfraz","link":"http://stackoverflow.com/users/139459/sarfraz"},"edited":false,"score":0,"creation_date":1330935880,"post_id":9563542,"comment_id":12123478}],"comment_count":1,"is_accepted":false,"score":0,"last_activity_date":1330935656,"creation_date":1330935656,"answer_id":9563542,"question_id":9563479,"body_markdown":"You can use the `call` method to specify the scope for the function:\r\n\r\n $("td").click(function(){ marked.call(this, listCells); });\r\n\r\nNow the `marked` function can access the clicked element using the `this` keyword.\r\n","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563542#9563542","body":"

You can use the call method to specify the scope for the function:

\n\n
$(\"td\").click(function(){ marked.call(this, listCells); });\n
\n\n

Now the marked function can access the clicked element using the this keyword.

\n"},{"owner":{"reputation":175763,"user_id":139459,"user_type":"registered","accept_rate":97,"profile_image":"http://i.stack.imgur.com/4Su7A.jpg?s=128&g=1","display_name":"Sarfraz","link":"http://stackoverflow.com/users/139459/sarfraz"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330935679,"creation_date":1330935679,"answer_id":9563547,"question_id":9563479,"body_markdown":"You need to pass `$(this)` to your function:\r\n\r\n $("td").click(function(){ marked(listCells, $(this))} );\r\n\r\nAnd modify your function like this:\r\n\r\n function marked(arr, that)\r\n {\r\n that.addClass("marked");\r\n \r\n if(turn == TURN_X)\r\n {\r\n that.innerHTML = "X";\r\n turn = false;\r\n }\r\n else\r\n that.innerHTML = "O";\r\n \r\n var tileNum = that.attr("id");\r\n }","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563547#9563547","body":"

You need to pass $(this) to your function:

\n\n
$(\"td\").click(function(){ marked(listCells, $(this))} );\n
\n\n

And modify your function like this:

\n\n
function marked(arr, that)\n{\n  that.addClass(\"marked\");\n\n  if(turn == TURN_X)\n  {\n    that.innerHTML = \"X\";\n    turn = false;\n  }\n  else\n    that.innerHTML = \"O\";\n\n  var tileNum = that.attr(\"id\");\n}\n
\n"},{"owner":{"reputation":2207,"user_id":1234595,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/41d913a5bc1693a51e5845ebce6b48c5?s=128&d=identicon&r=PG","display_name":"francisco.preller","link":"http://stackoverflow.com/users/1234595/francisco-preller"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330935708,"creation_date":1330935708,"answer_id":9563550,"question_id":9563479,"body_markdown":"Try:\r\n\r\n $("td").click(function(event){\r\n marked(listCells, $(this));\r\n });\r\n\r\nThen:\r\n\r\n function marked(arr, sel) {\r\n console.log($(this));\r\n sel.addClass("marked");\r\n\r\n if(turn == TURN_X) {\r\n this.innerHTML = "X";\r\n turn = false;\r\n } else {\r\n this.innerHTML = "O";\r\n }\r\n var tileNum = $(this).attr("id");\r\n }","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563550#9563550","body":"

Try:

\n\n
$(\"td\").click(function(event){\n    marked(listCells, $(this));\n});\n
\n\n

Then:

\n\n
function marked(arr, sel) {\n    console.log($(this));\n    sel.addClass(\"marked\");\n\n    if(turn == TURN_X) {\n        this.innerHTML = \"X\";\n        turn = false;\n    } else {\n        this.innerHTML = \"O\";\n    }\n    var tileNum = $(this).attr(\"id\");\n}\n
\n"},{"owner":{"reputation":155758,"user_id":18771,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/0ada184c98bf9073d15b2dc815be0170?s=128&d=identicon&r=PG","display_name":"Tomalak","link":"http://stackoverflow.com/users/18771/tomalak"},"comments":[{"owner":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"edited":false,"score":0,"creation_date":1330997955,"post_id":9563668,"comment_id":12143123},{"owner":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"edited":false,"score":0,"creation_date":1330998114,"post_id":9563668,"comment_id":12143151},{"owner":{"reputation":155758,"user_id":18771,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/0ada184c98bf9073d15b2dc815be0170?s=128&d=identicon&r=PG","display_name":"Tomalak","link":"http://stackoverflow.com/users/18771/tomalak"},"reply_to_user":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"edited":false,"score":1,"creation_date":1331013680,"post_id":9563668,"comment_id":12145902}],"last_editor":{"reputation":155758,"user_id":18771,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/0ada184c98bf9073d15b2dc815be0170?s=128&d=identicon&r=PG","display_name":"Tomalak","link":"http://stackoverflow.com/users/18771/tomalak"},"comment_count":3,"is_accepted":true,"score":6,"last_activity_date":1331013552,"last_edit_date":1331013552,"creation_date":1330936479,"answer_id":9563668,"question_id":9563479,"body_markdown":"You code does not follow the right principles.\r\n\r\n $(function(){\r\n var TURN_X = "X",\r\n TURN_O = "O", \r\n turn = TURN_O,\r\n $listCells = $("td");\r\n\r\n function marked() { // define event handler\r\n var $this = $(this),\r\n tileNum = $this.attr("id");\r\n\r\n if ( !($this.hasClass("marked") ) {\r\n $this.addClass("marked").text(turn);\r\n turn = (turn == TURN_X) ? TURN_O : TURN_X;\r\n }\r\n }\r\n\r\n $listCells.click(marked); // attach event handler\r\n });\r\n\r\n1. Wrap everything in the document.ready function. Avoid global variables wherever possible.\r\n1. Make use of the fact that jQuery manages `this` for you. `this` will always be what you expect if you pass callback functions directly instead of calling them yourself.","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9563668#9563668","body":"

You code does not follow the right principles.

\n\n
$(function(){\n    var TURN_X = \"X\",\n        TURN_O = \"O\", \n        turn   = TURN_O,\n        $listCells = $(\"td\");\n\n    function marked() {        // define event handler\n        var $this   = $(this),\n            tileNum = $this.attr(\"id\");\n\n        if ( !($this.hasClass(\"marked\") ) {\n            $this.addClass(\"marked\").text(turn);\n            turn = (turn == TURN_X) ? TURN_O : TURN_X;\n        }\n    }\n\n    $listCells.click(marked);  // attach event handler\n});\n
\n\n
    \n
  1. Wrap everything in the document.ready function. Avoid global variables wherever possible.
  2. \n
  3. Make use of the fact that jQuery manages this for you. this will always be what you expect if you pass callback functions directly instead of calling them yourself.
  4. \n
\n"},{"owner":{"reputation":135904,"user_id":965051,"user_type":"registered","profile_image":"http://i.stack.imgur.com/XgLe7.gif?s=128&g=1","display_name":"adeneo","link":"http://stackoverflow.com/users/965051/adeneo"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1330940564,"creation_date":1330940564,"answer_id":9564468,"question_id":9563479,"body_markdown":" \r\n\r\n $(document).ready(function(){\r\n var TURN_X = false,\r\n TURN_O = true,\r\n turn = false,\r\n listCells = $.makeArray($("td"));\r\n\r\n $("td").click(function() {\r\n marked(listCells, this)\r\n });\r\n\r\n function marked(arr, self) {\r\n $(self).addClass("marked");\r\n \r\n if(turn == TURN_X) {\r\n self.innerHTML = "X";\r\n turn = false;\r\n }else{\r\n self.innerHTML = "O";\r\n var tileNum = self.id;\r\n }\r\n }\r\n });\r\n\r\n \r\n","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function/9564468#9564468","body":"
$(document).ready(function(){\n    var TURN_X = false,\n        TURN_O = true,\n        turn = false,\n        listCells = $.makeArray($(\"td\"));\n\n    $(\"td\").click(function() {\n        marked(listCells, this)\n    });\n\n    function marked(arr, self) {\n        $(self).addClass(\"marked\");\n\n        if(turn == TURN_X) {\n            self.innerHTML = \"X\";\n            turn = false;\n        }else{\n            self.innerHTML = \"O\";\n            var tileNum = self.id;\n        }\n    }\n});\n
\n"}],"tags":["jquery","click","this"],"owner":{"reputation":134,"user_id":1028892,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/117b608a2bcac55e03738c83d102229f?s=128&d=identicon&r=PG","display_name":"wayfare","link":"http://stackoverflow.com/users/1028892/wayfare"},"comments":[{"owner":{"reputation":8549,"user_id":1130266,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/fa2d4040807e58ed5b06867720516e1b?s=128&d=identicon&r=PG","display_name":"Greg","link":"http://stackoverflow.com/users/1130266/greg"},"edited":false,"score":0,"creation_date":1330935845,"post_id":9563479,"comment_id":12123465}],"comment_count":1,"is_answered":true,"view_count":11657,"accepted_answer_id":9563668,"answer_count":7,"score":6,"last_activity_date":1414773395,"creation_date":1330935254,"last_edit_date":1330935600,"question_id":9563479,"body_markdown":"I am trying to make a tictactoe project in jQuery and I am having a major problem...\r\n\r\nThe tiles are in `<td>` tags and I am trying to make it so that when the user clicks the the tile, it calls the "marked" function. \r\n\r\nIf we now look into the "marked" function, `$(this)` is intended to be the `<td>` node that the function was called from. \r\n\r\nHowever, it wasn't doing anything so I checked the console and apparently `$(this)` was containing the DOM Window object. \r\n\r\nIs there anyway I can send the right kind of `$(this)` to the "marked" function?\r\n\r\nThank you!\r\n\r\n <script type="text/javascript">\r\n \r\n var TURN_X = false;\r\n var TURN_O = true;\r\n \r\n var turn = false; // this is to see whos turn it is.\r\n \r\n $(document).ready(function(){\r\n \r\n \t var listCells = $.makeArray($("td"));\r\n \t $("td").click(function(){marked(listCells)}); //THIS IS WHERE I HAVE PROBLEMS\r\n \t return false;\r\n });\r\n \r\n function marked(arr)\r\n {\r\n \t console.log($(this)); // THIS CONSOLE LOG RETURNS "DOM Window"\r\n \t $(this).addClass("marked");\r\n \r\n \t if(turn == TURN_X)\r\n \t {\r\n \t\tthis.innerHTML = "X";\r\n \t\tturn = false;\r\n \t }\r\n \t else\r\n \t\tthis.innerHTML = "O";\r\n \r\n \t var tileNum = $(this).attr("id");\r\n }","link":"http://stackoverflow.com/questions/9563479/how-to-pass-this-properly-in-click-jquery-function","title":"How to pass $(this) properly in click jQuery function","body":"

I am trying to make a tictactoe project in jQuery and I am having a major problem...

\n\n

The tiles are in <td> tags and I am trying to make it so that when the user clicks the the tile, it calls the \"marked\" function.

\n\n

If we now look into the \"marked\" function, $(this) is intended to be the <td> node that the function was called from.

\n\n

However, it wasn't doing anything so I checked the console and apparently $(this) was containing the DOM Window object.

\n\n

Is there anyway I can send the right kind of $(this) to the \"marked\" function?

\n\n

Thank you!

\n\n
<script type=\"text/javascript\">\n\n    var TURN_X = false;\n    var TURN_O = true;\n\n    var turn = false;  // this is to see whos turn it is.\n\n    $(document).ready(function(){\n\n        var listCells = $.makeArray($(\"td\"));\n        $(\"td\").click(function(){marked(listCells)});   //THIS IS WHERE I HAVE PROBLEMS\n        return false;\n    });\n\n    function marked(arr)\n    {\n        console.log($(this));  // THIS CONSOLE LOG RETURNS \"DOM Window\"\n        $(this).addClass(\"marked\");\n\n        if(turn == TURN_X)\n        {\n        this.innerHTML = \"X\";\n        turn = false;\n        }\n        else\n        this.innerHTML = \"O\";\n\n        var tileNum = $(this).attr(\"id\");\n    }\n
\n"},{"answers":[{"owner":{"reputation":11,"user_id":563002,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5ef32680f5eb641538a98e786ad6c46a?s=128&d=identicon&r=PG","display_name":"softex","link":"http://stackoverflow.com/users/563002/softex"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1294760468,"creation_date":1294760468,"answer_id":4659410,"question_id":4650831,"body_markdown":"\r\nWelll ... turns out the BluetoothChat code re-creates the byte array with *message.getBytes()* before sending to the service. (after all, being **chat** code it would normally source only regular ascii strings) As others on this site have pointed out, getBytes() can create encoding issues in some cases. So, for purposes of sending these extended-ascii commands, I don't mess with strings and just send the byte array to the service with\r\n\r\n private void sendCommand(byte[] cmd) {\r\n \tmChatService.write(cmd);\r\n }\r\n\r\nThe so-called command array is first initialized with placeholders for the hex radio address elements\r\n\r\n byte[] addrArray = {(byte) 0xCC, 16, 0, 0, 0, 13};\r\n\r\nand then filled in with the help of the conversion method\r\n\r\n radioArray = HexStringToByteArray(radioAddr1);\r\n\r\nwhich can be found here: [HexStringToByteArray@stackoverflow][1]\r\n\r\n \r\n\r\n \r\n\r\n\r\n [1]: http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java","link":"http://stackoverflow.com/questions/4650831/how-do-you-send-an-extended-ascii-at-command-cch-from-android-bluetooth-to-a-s/4659410#4659410","body":"

Welll ... turns out the BluetoothChat code re-creates the byte array with message.getBytes() before sending to the service. (after all, being chat code it would normally source only regular ascii strings) As others on this site have pointed out, getBytes() can create encoding issues in some cases. So, for purposes of sending these extended-ascii commands, I don't mess with strings and just send the byte array to the service with

\n\n
private void sendCommand(byte[] cmd) {\n    mChatService.write(cmd);\n}\n
\n\n

The so-called command array is first initialized with placeholders for the hex radio address elements

\n\n
byte[] addrArray = {(byte) 0xCC, 16, 0, 0, 0, 13};\n
\n\n

and then filled in with the help of the conversion method

\n\n
radioArray = HexStringToByteArray(radioAddr1);\n
\n\n

which can be found here: HexStringToByteArray@stackoverflow

\n"}],"tags":["android","bluetooth","serial-port","ascii","at-command"],"owner":{"reputation":11,"user_id":563002,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5ef32680f5eb641538a98e786ad6c46a?s=128&d=identicon&r=PG","display_name":"softex","link":"http://stackoverflow.com/users/563002/softex"},"comment_count":0,"is_answered":false,"view_count":1823,"answer_count":1,"score":0,"last_activity_date":1414773393,"creation_date":1294689028,"last_edit_date":1414773393,"question_id":4650831,"body_markdown":"This one really has me banging my head. I'm sending alphanumeric data from an Android app, through the BluetoothChatService, to a serial bluetooth adaptor connected to the serial input of a radio transceiver.\r\n\r\nEverything works fine except when I try to configure the radio on-the-fly with its AT-commands. The AT+++ (enter command mode) is received OK, but the problem comes with the extended-ascii characters in the next two commands: Changing the radio destination address (which is what I'm trying to do) requires CCh 10h (plus 3 hex radio address bytes), and exiting the command mode requires CCh ATO.\r\n\r\nI know the radio can be configured OK because I've done it on an earlier prototype with the serial commands from PIC basic, and it also can be configured by entering the commands directly from hyperterm. Both these methods somehow convert that pesky CCh into a form the radio understands.\r\n\r\nI've have tried just about everything an Android noob could possibly come up with to finagle the encoding such as:\r\n\r\n private void command_address() {\r\n\t\tbyte[] addrArray = {(byte) 0xCC, 16, 36, 65, 21, 13};\t\t\t\t\t\r\n\t\tCharSequence addrvalues = EncodingUtils.getString(addrArray, "UTF-8");\t\r\n\t\tsendMessage((String) addrvalues);\r\n }\r\n\r\nbut no matter what, I can't seem to get that high-order byte (CCh/204/-52) to behave as it should. All other (< 127) bytes, command or data, transmit with no problem. Any help here would be greatly appreciated.\r\n\r\n-Dave \r\n\r\n\t\t\r\n\r\n\r\n \r\n","link":"http://stackoverflow.com/questions/4650831/how-do-you-send-an-extended-ascii-at-command-cch-from-android-bluetooth-to-a-s","title":"How do you send an extended-ascii AT-command (CCh) from Android bluetooth to a serial device?","body":"

This one really has me banging my head. I'm sending alphanumeric data from an Android app, through the BluetoothChatService, to a serial bluetooth adaptor connected to the serial input of a radio transceiver.

\n\n

Everything works fine except when I try to configure the radio on-the-fly with its AT-commands. The AT+++ (enter command mode) is received OK, but the problem comes with the extended-ascii characters in the next two commands: Changing the radio destination address (which is what I'm trying to do) requires CCh 10h (plus 3 hex radio address bytes), and exiting the command mode requires CCh ATO.

\n\n

I know the radio can be configured OK because I've done it on an earlier prototype with the serial commands from PIC basic, and it also can be configured by entering the commands directly from hyperterm. Both these methods somehow convert that pesky CCh into a form the radio understands.

\n\n

I've have tried just about everything an Android noob could possibly come up with to finagle the encoding such as:

\n\n
private void command_address() {\n    byte[] addrArray = {(byte) 0xCC, 16, 36, 65, 21, 13};                   \n    CharSequence addrvalues = EncodingUtils.getString(addrArray, \"UTF-8\");  \n    sendMessage((String) addrvalues);\n}\n
\n\n

but no matter what, I can't seem to get that high-order byte (CCh/204/-52) to behave as it should. All other (< 127) bytes, command or data, transmit with no problem. Any help here would be greatly appreciated.

\n\n

-Dave

\n"},{"answers":[{"owner":{"reputation":6,"user_id":3880801,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ec8acd655122f5c9c663cd41739d9e5d?s=128&d=identicon&r=PG&f=1","display_name":"Richard Antalík","link":"http://stackoverflow.com/users/3880801/richard-antal%c3%adk"},"comment_count":0,"is_accepted":true,"score":0,"last_activity_date":1414773393,"creation_date":1414773393,"answer_id":26679410,"question_id":26607683,"body_markdown":"After switching to "Live"/production environment everything is running well.\r\n\r\nFirst transaction occured in first 30 minutes, and following ones in about an hour after next_billing_date.\r\n\r\nIn sandbox only first payment was made to this date(ref to data in Q). "Funny" thing is, that not only sandbox, but even their support seems to be broken...\r\n\r\nAlso see http://stackoverflow.com/questions/26562515/tell-paypal-to-automatically-process-the-monthly-payment?rq=1","link":"http://stackoverflow.com/questions/26607683/billing-date-in-paypal-recurrent-payments/26679410#26679410","body":"

After switching to \"Live\"/production environment everything is running well.

\n\n

First transaction occured in first 30 minutes, and following ones in about an hour after next_billing_date.

\n\n

In sandbox only first payment was made to this date(ref to data in Q). \"Funny\" thing is, that not only sandbox, but even their support seems to be broken...

\n\n

Also see Tell PayPal to automatically process the monthly payment

\n"}],"tags":["paypal"],"owner":{"reputation":6,"user_id":3880801,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ec8acd655122f5c9c663cd41739d9e5d?s=128&d=identicon&r=PG&f=1","display_name":"Richard Antalík","link":"http://stackoverflow.com/users/3880801/richard-antal%c3%adk"},"comment_count":0,"is_answered":true,"view_count":24,"accepted_answer_id":26679410,"answer_count":1,"score":1,"last_activity_date":1414773393,"creation_date":1414497174,"last_edit_date":1414771607,"question_id":26607683,"body_markdown":"I am using paypal rest API for recurrent billing.\r\n\r\nIs there any way to predict date for next payment for billing agreement?\r\n\r\nWhen I create & execute agreement, paypal will provide me this info:\r\n\r\n "start_date": "2014-10-26T07:00:00Z",\r\n "cycles_remaining": "1",\r\n "cycles_completed": "0",\r\n "next_billing_date": "2014-10-26T10:00:00Z",\r\n "final_payment_date": "1970-01-01T00:00:00Z",\r\n "failed_payment_count": "0"\r\n\r\nWhen I check transactions after next_billing_date, there is no payment. However, after a longer time a payment arrive and when I retrieve the same agreement, I get this:\r\n\r\n "start_date": "2014-10-26T07:00:00Z",\r\n "agreement_details": {\r\n "outstanding_balance": {\r\n "currency": "USD",\r\n "value": "0.00"\r\n },\r\n "cycles_remaining": "0",\r\n "cycles_completed": "0",\r\n "next_billing_date": "2014-11-26T10:00:00Z",\r\n "last_payment_date": "2014-10-28T05:00:55Z",\r\n "last_payment_amount": {\r\n "currency": "USD",\r\n "value": "0.01"\r\n },\r\n "final_payment_date": "1970-01-01T00:00:00Z",\r\n "failed_payment_count": "0"\r\n\r\nSo the payment was made 1d 19h after the date provided in agreement.\r\n\r\nIf those 'delays' will be max 3 days, it will be OK. But I need to be sure.\r\n\r\nEDIT: I should specify, that this happens in sandbox environment\r\n\r\nThank you.\r\n\r\n","link":"http://stackoverflow.com/questions/26607683/billing-date-in-paypal-recurrent-payments","title":"Billing date in PayPal recurrent payments","body":"

I am using paypal rest API for recurrent billing.

\n\n

Is there any way to predict date for next payment for billing agreement?

\n\n

When I create & execute agreement, paypal will provide me this info:

\n\n
\"start_date\": \"2014-10-26T07:00:00Z\",\n\"cycles_remaining\": \"1\",\n\"cycles_completed\": \"0\",\n\"next_billing_date\": \"2014-10-26T10:00:00Z\",\n\"final_payment_date\": \"1970-01-01T00:00:00Z\",\n\"failed_payment_count\": \"0\"\n
\n\n

When I check transactions after next_billing_date, there is no payment. However, after a longer time a payment arrive and when I retrieve the same agreement, I get this:

\n\n
\"start_date\": \"2014-10-26T07:00:00Z\",\n\"agreement_details\": {\n    \"outstanding_balance\": {\n        \"currency\": \"USD\",\n        \"value\": \"0.00\"\n    },\n    \"cycles_remaining\": \"0\",\n    \"cycles_completed\": \"0\",\n    \"next_billing_date\": \"2014-11-26T10:00:00Z\",\n    \"last_payment_date\": \"2014-10-28T05:00:55Z\",\n    \"last_payment_amount\": {\n        \"currency\": \"USD\",\n        \"value\": \"0.01\"\n    },\n    \"final_payment_date\": \"1970-01-01T00:00:00Z\",\n    \"failed_payment_count\": \"0\"\n
\n\n

So the payment was made 1d 19h after the date provided in agreement.

\n\n

If those 'delays' will be max 3 days, it will be OK. But I need to be sure.

\n\n

EDIT: I should specify, that this happens in sandbox environment

\n\n

Thank you.

\n"},{"tags":["php","laravel-4"],"owner":{"reputation":675,"user_id":446691,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/4b7953ddade6bdc06771618db0eba1af?s=128&d=identicon&r=PG","display_name":"TH1981","link":"http://stackoverflow.com/users/446691/th1981"},"comments":[{"owner":{"reputation":230,"user_id":4106168,"user_type":"registered","profile_image":"http://graph.facebook.com/100002191578411/picture?type=large","display_name":"Jelle Keizer","link":"http://stackoverflow.com/users/4106168/jelle-keizer"},"edited":false,"score":0,"creation_date":1414375483,"post_id":26579538,"comment_id":41777339},{"owner":{"reputation":230,"user_id":4106168,"user_type":"registered","profile_image":"http://graph.facebook.com/100002191578411/picture?type=large","display_name":"Jelle Keizer","link":"http://stackoverflow.com/users/4106168/jelle-keizer"},"edited":false,"score":1,"creation_date":1414375967,"post_id":26579538,"comment_id":41777401},{"owner":{"reputation":22860,"user_id":1317935,"user_type":"registered","accept_rate":98,"profile_image":"https://www.gravatar.com/avatar/e13d2feaca492372fc4e16318dc99b9e?s=128&d=identicon&r=PG","display_name":"The Shift Exchange","link":"http://stackoverflow.com/users/1317935/the-shift-exchange"},"edited":false,"score":0,"creation_date":1414382771,"post_id":26579538,"comment_id":41778724},{"owner":{"reputation":675,"user_id":446691,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/4b7953ddade6bdc06771618db0eba1af?s=128&d=identicon&r=PG","display_name":"TH1981","link":"http://stackoverflow.com/users/446691/th1981"},"reply_to_user":{"reputation":230,"user_id":4106168,"user_type":"registered","profile_image":"http://graph.facebook.com/100002191578411/picture?type=large","display_name":"Jelle Keizer","link":"http://stackoverflow.com/users/4106168/jelle-keizer"},"edited":false,"score":0,"creation_date":1414419734,"post_id":26579538,"comment_id":41794128},{"owner":{"reputation":675,"user_id":446691,"user_type":"registered","accept_rate":91,"profile_image":"https://www.gravatar.com/avatar/4b7953ddade6bdc06771618db0eba1af?s=128&d=identicon&r=PG","display_name":"TH1981","link":"http://stackoverflow.com/users/446691/th1981"},"reply_to_user":{"reputation":22860,"user_id":1317935,"user_type":"registered","accept_rate":98,"profile_image":"https://www.gravatar.com/avatar/e13d2feaca492372fc4e16318dc99b9e?s=128&d=identicon&r=PG","display_name":"The Shift Exchange","link":"http://stackoverflow.com/users/1317935/the-shift-exchange"},"edited":false,"score":0,"creation_date":1414419755,"post_id":26579538,"comment_id":41794140}],"comment_count":5,"is_answered":false,"view_count":22,"bounty_amount":150,"bounty_closes_date":1415378189,"answer_count":0,"score":0,"last_activity_date":1414773389,"creation_date":1414369244,"question_id":26579538,"body_markdown":"I'm lost on what I'm doing wrong, and I can't see anyone else with this problem, so it's gotta be me.\r\n\r\nI've just setup `Indatus\\Dispatcher\\ServiceProvider` and have everything running just fine. For testing purposes, I'm just running a single scheduled event every 5 minutes to add a log entry. \r\n\r\nFor some reason, it's duplicating the log entries. \r\n\r\nHere's what the output is looking like: \r\n\r\n\t[2014-10-26 19:00:15] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:00:15] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:05:12] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:05:13] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:10:09] local.INFO: This is a test [] []\r\n\t[2014-10-26 19:10:10] local.INFO: This is a test [] []\r\n\r\nHere's the actual scheduled `fire()` event: \r\n\r\n\tpublic function fire()\r\n\t{\r\n\t\tLog::info('This is a test');\r\n\t}\r\n\r\nThe `schedule()` :\r\n\r\n\tpublic function schedule(Schedulable $scheduler)\r\n\t{\r\n\t\treturn $scheduler->everyMinutes(5);\r\n\r\n\t}\r\n\r\nand I've checked the `scheduled:summary` and it's only showing once: \r\n\r\n\t+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\r\n\t| Environment(s) | Name | Args/Opts | Minute | Hour | Day of Month | Month | Day of Week | Run as |\r\n\t+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\r\n\t| * | schedule:test | | */5 | * | * | * | * | |\r\n\t+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\r\n\r\nAnd finally my crontab entry, which is only listed in the file once:\r\n\r\n\t* * * * * php /vagrant/myapp/artisan scheduled:run 1>> /dev/null 2>&1\r\n\r\nI can't see any duplication that would cause it to run twice. \r\n\r\nAny ideas what I've got wrong?","link":"http://stackoverflow.com/questions/26579538/dispatcher-w-laravel-duplicating-output","title":"Dispatcher w/ Laravel duplicating output","body":"

I'm lost on what I'm doing wrong, and I can't see anyone else with this problem, so it's gotta be me.

\n\n

I've just setup Indatus\\Dispatcher\\ServiceProvider and have everything running just fine. For testing purposes, I'm just running a single scheduled event every 5 minutes to add a log entry.

\n\n

For some reason, it's duplicating the log entries.

\n\n

Here's what the output is looking like:

\n\n
[2014-10-26 19:00:15] local.INFO: This is a test [] []\n[2014-10-26 19:00:15] local.INFO: This is a test [] []\n[2014-10-26 19:05:12] local.INFO: This is a test [] []\n[2014-10-26 19:05:13] local.INFO: This is a test [] []\n[2014-10-26 19:10:09] local.INFO: This is a test [] []\n[2014-10-26 19:10:10] local.INFO: This is a test [] []\n
\n\n

Here's the actual scheduled fire() event:

\n\n
public function fire()\n{\n    Log::info('This is a test');\n}\n
\n\n

The schedule() :

\n\n
public function schedule(Schedulable $scheduler)\n{\n    return $scheduler->everyMinutes(5);\n\n}\n
\n\n

and I've checked the scheduled:summary and it's only showing once:

\n\n
+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\n| Environment(s) | Name             | Args/Opts | Minute | Hour | Day of Month | Month | Day of Week | Run as |\n+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\n| *              | schedule:test    |           | */5    | *    | *            | *     | *           |        |\n+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+\n
\n\n

And finally my crontab entry, which is only listed in the file once:

\n\n
* * * * * php /vagrant/myapp/artisan scheduled:run 1>> /dev/null 2>&1\n
\n\n

I can't see any duplication that would cause it to run twice.

\n\n

Any ideas what I've got wrong?

\n"},{"tags":["java","netbeans","project"],"owner":{"reputation":1,"user_id":4165262,"user_type":"registered","profile_image":"http://graph.facebook.com/100003759045779/picture?type=large","display_name":"Prabhjot Singh","link":"http://stackoverflow.com/users/4165262/prabhjot-singh"},"comments":[{"owner":{"reputation":1150,"user_id":763029,"user_type":"registered","accept_rate":93,"profile_image":"http://i.stack.imgur.com/TVwEa.jpg?s=128&g=1","display_name":"Coffee","link":"http://stackoverflow.com/users/763029/coffee"},"edited":false,"score":1,"creation_date":1414773312,"post_id":26679347,"comment_id":41957659}],"comment_count":1,"is_answered":false,"view_count":11,"answer_count":0,"score":-3,"last_activity_date":1414773379,"creation_date":1414773165,"last_edit_date":1414773379,"question_id":26679347,"body_markdown":"I was working to make a **java** project but its difficult to program the whole code. \r\n\r\nShould I prefer GUI builder of **netbeans** for making this project","link":"http://stackoverflow.com/questions/26679347/is-it-good-to-make-project-just-with-the-help-of-gui-builder-of-netbeans","title":"Is it good to make project just with the help of GUI builder of netbeans","body":"

I was working to make a java project but its difficult to program the whole code.

\n\n

Should I prefer GUI builder of netbeans for making this project

\n"},{"answers":[{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"comments":[{"owner":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":0,"creation_date":1414772772,"post_id":26679054,"comment_id":41957377},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":1,"creation_date":1414773091,"post_id":26679054,"comment_id":41957545},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":0,"creation_date":1414773410,"post_id":26679054,"comment_id":41957706},{"owner":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"edited":false,"score":0,"creation_date":1414773424,"post_id":26679054,"comment_id":41957715}],"last_editor":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"comment_count":4,"is_accepted":false,"score":0,"last_activity_date":1414773375,"last_edit_date":1414773375,"creation_date":1414772161,"answer_id":26679054,"question_id":26678572,"body_markdown":"Basically you want to know \r\n\r\n - What the errors were and\r\n - When every ajax request is finished\r\n\r\nIf you push the errors into a list, the results will be ready at the end (order not guaranteed of course).\r\n\r\nFor the second part, if you keep an array of the ajax promises returned from each $.ajax you can use `$.when` and wait for them all to complete using `always()`.\r\n\r\nAs a basic example (other details removed):\r\n\r\n var listing = {}; // data from reddit API\r\n var promises = [];\r\n var results = [];\r\n $.each(listing, function(key, value) {\r\n // [snip]\r\n promises.push($.ajax({\r\n type: "HEAD",\r\n url: "https://gdata.youtube.com/feeds/api/videos/" + videoID,\r\n error: function() { \r\n //[snip]\r\n results.push({\r\n itemArtist: itemArtist,\r\n videoID: videoID,\r\n url: itemURL});\r\n }\r\n });\r\n );\r\n }\r\n // Wait for all promises to complete (pass or fail) \r\n $.when.apply($, promises).always(function(){\r\n // process list of failed URLs\r\n });\r\n\r\n*Apologies for any typos. This was coded straight into the answer, but you get the idea.*\r\n\r\nI note you mention 100s of requests, but the browser will only allow a handful through at a time, so no need for additional processing.\r\n\r\nIf `always` is not working you can add your own deferred objects that resolve on `success` *or* `fail`:\r\n\r\n var listing = {}; // data from reddit API\r\n var promises = [];\r\n var results = [];\r\n $.each(listing, function(key, value) {\r\n var deferred = $.Deferred();\r\n promises.push(deferred.promise());\r\n // [snip]\r\n $.ajax({\r\n type: "HEAD",\r\n url: "https://gdata.youtube.com/feeds/api/videos/" + videoID,\r\n complete: function(){\r\n // resolve on success or fail\r\n deferred.resolve();\r\n },\r\n error: function() { \r\n //[snip]\r\n results.push({\r\n itemArtist: itemArtist,\r\n videoID: videoID,\r\n url: itemURL});\r\n }\r\n });\r\n );\r\n }\r\n // Wait for all promises to complete (pass or fail) \r\n $.when.apply($, promises).always(function(){\r\n // process list of failed URLs\r\n });\r\n","link":"http://stackoverflow.com/questions/26678572/how-to-keep-ajax-async-inside-each-loop-but-react-to-result-on-each-iter/26679054#26679054","body":"

Basically you want to know

\n\n\n\n

If you push the errors into a list, the results will be ready at the end (order not guaranteed of course).

\n\n

For the second part, if you keep an array of the ajax promises returned from each $.ajax you can use $.when and wait for them all to complete using always().

\n\n

As a basic example (other details removed):

\n\n
var listing = {}; // data from reddit API\nvar promises = [];\nvar results = [];\n$.each(listing, function(key, value) {\n    // [snip]\n    promises.push($.ajax({\n            type: \"HEAD\",\n            url: \"https://gdata.youtube.com/feeds/api/videos/\" + videoID,\n            error: function() { \n                //[snip]\n                results.push({\n                   itemArtist: itemArtist,\n                   videoID: videoID,\n                   url: itemURL});\n            }\n        });\n    );\n}\n// Wait for all promises to complete (pass or fail) \n$.when.apply($, promises).always(function(){\n    // process list of failed URLs\n});\n
\n\n

Apologies for any typos. This was coded straight into the answer, but you get the idea.

\n\n

I note you mention 100s of requests, but the browser will only allow a handful through at a time, so no need for additional processing.

\n\n

If always is not working you can add your own deferred objects that resolve on success or fail:

\n\n
var listing = {}; // data from reddit API\nvar promises = [];\nvar results = [];\n$.each(listing, function(key, value) {\n    var deferred = $.Deferred();\n    promises.push(deferred.promise());\n    // [snip]\n    $.ajax({\n            type: \"HEAD\",\n            url: \"https://gdata.youtube.com/feeds/api/videos/\" + videoID,\n            complete: function(){\n                // resolve on success or fail\n                deferred.resolve();\n            },\n            error: function() { \n                //[snip]\n                results.push({\n                   itemArtist: itemArtist,\n                   videoID: videoID,\n                   url: itemURL});\n            }\n        });\n    );\n}\n// Wait for all promises to complete (pass or fail) \n$.when.apply($, promises).always(function(){\n    // process list of failed URLs\n});\n
\n"}],"tags":["javascript","jquery","ajax","youtube","bookmarklet"],"owner":{"reputation":20,"user_id":1318227,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2f243f0da6c1d00f22f32f22d4b0fa4d?s=128&d=identicon&r=PG","display_name":"SouPress","link":"http://stackoverflow.com/users/1318227/soupress"},"comments":[{"owner":{"reputation":283,"user_id":2653351,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/24755d808ec7166297fabe5d22f9f757?s=128&d=identicon&r=PG","display_name":"MightyLampshade","link":"http://stackoverflow.com/users/2653351/mightylampshade"},"edited":false,"score":0,"creation_date":1414771335,"post_id":26678572,"comment_id":41956611},{"owner":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"edited":false,"score":0,"creation_date":1414771800,"post_id":26678572,"comment_id":41956876},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"edited":false,"score":0,"creation_date":1414771894,"post_id":26678572,"comment_id":41956935},{"owner":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"reply_to_user":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"edited":false,"score":0,"creation_date":1414772003,"post_id":26678572,"comment_id":41957001},{"owner":{"reputation":33462,"user_id":201078,"user_type":"registered","accept_rate":86,"profile_image":"https://www.gravatar.com/avatar/98bc153d15df866873e678ec8dc553ac?s=128&d=identicon&r=PG","display_name":"TrueBlueAussie","link":"http://stackoverflow.com/users/201078/trueblueaussie"},"reply_to_user":{"reputation":1037,"user_id":572827,"user_type":"registered","accept_rate":62,"profile_image":"http://i.stack.imgur.com/46MgM.jpg?s=128&g=1","display_name":"LShetty","link":"http://stackoverflow.com/users/572827/lshetty"},"edited":false,"score":0,"creation_date":1414772050,"post_id":26678572,"comment_id":41957029}],"comment_count":5,"is_answered":false,"view_count":37,"answer_count":1,"score":0,"last_activity_date":1414773375,"creation_date":1414770488,"question_id":26678572,"body_markdown":"I'm having trouble with some dumb architecture because I'm dumb. I'm trying to loop over YouTube videos posted to Reddit, extract URLs and process them into an .m3u playlist.\r\n\r\nFull code at [**Subreddit to YouTube Source Bookmarklet** - Play YouTube music from subreddits in Foobar with foo_youtube](https://gist.github.com/akaleeroy/b3de63c46ee43d413913)\r\n\r\nAt some point I get the idea that I could check each URL to see if the video is dead or not, and offer an alternative if they're removed.\r\n\r\nSo I do AJAX requests to YouTube API and if there's an error I'm supposed to react to it and change that item's URL. \r\n\r\nBut the problem is it only works if the AJAX is NOT async - this takes many seconds, during which the page is jammed.\r\n\r\nI'd like to let the AJAX be async but I don't know how I should structure my code.\r\n\r\nHere is **PSEUDOCODE** of how it is now:\r\n\r\n\r\n<!-- language: lang-js -->\r\n\r\n var listing = // data from reddit API\r\n $.each(listing, function(key, value) {\r\n var url = // post URL from reddit posts listing \r\n // ( "http://youtu.be/XmQR4_hDtpY&amp;hd=1" )\r\n var aRegex = // to parse YouTube URLs \r\n // ( (?:youtube(?:-nocookie)?.com/....bla...bla )\r\n var videoID = // YouTube video ID, extracted with regex \r\n // ( "XmQR4_hDtpY" )\r\n var itemArtist = // parsed from reddit posts listing \r\n // ( "Awesome Artist" )\r\n var itemTitle = // parsed from reddit posts listing \r\n // ( "Cool Song (Original Mix)" )\r\n var itemURL = // url, further processed \r\n // ( "3dydfy://www.youtube.com/watch?v=XmQR4_hDtpY&hd=1" )\r\n\r\n $.ajax({\r\n type: "HEAD",\r\n url: "https://gdata.youtube.com/feeds/api/videos/" + videoID,\r\n error: function() { \r\n // If it's no longer available \r\n // (removed, deleted account, made private)\r\n deadVid++; // chalk up another dead one, for showing progress\r\n itemURL = // dead videos should get a different URL \r\n // ( "3dydfy-search://q=Awesome%20Artist%20Cool%20Song....." )\r\n }\r\n });\r\n\r\n // further process itemURL!\r\n // at this point I want itemURL changed by the .ajax()'s error callback\r\n // but I'm trying to keep the requests async \r\n // to not jam the page while a hundred HTTP requests happen!\r\n if (condition){\r\n itemURL += // append various strings\r\n }\r\n // Write the item to the .m3u8 playlist\r\n playlist += itemURL + '\\n';\r\n }// end .each()","link":"http://stackoverflow.com/questions/26678572/how-to-keep-ajax-async-inside-each-loop-but-react-to-result-on-each-iter","title":"How to keep $.ajax() async inside $.each() loop but react to result on each iteration","body":"

I'm having trouble with some dumb architecture because I'm dumb. I'm trying to loop over YouTube videos posted to Reddit, extract URLs and process them into an .m3u playlist.

\n\n

Full code at Subreddit to YouTube Source Bookmarklet - Play YouTube music from subreddits in Foobar with foo_youtube

\n\n

At some point I get the idea that I could check each URL to see if the video is dead or not, and offer an alternative if they're removed.

\n\n

So I do AJAX requests to YouTube API and if there's an error I'm supposed to react to it and change that item's URL.

\n\n

But the problem is it only works if the AJAX is NOT async - this takes many seconds, during which the page is jammed.

\n\n

I'd like to let the AJAX be async but I don't know how I should structure my code.

\n\n

Here is PSEUDOCODE of how it is now:

\n\n
var listing = // data from reddit API\n$.each(listing, function(key, value) {\n    var url = // post URL from reddit posts listing \n    // ( \"http://youtu.be/XmQR4_hDtpY&amp;hd=1\" )\n    var aRegex = // to parse YouTube URLs \n    // ( (?:youtube(?:-nocookie)?.com/....bla...bla )\n    var videoID = // YouTube video ID, extracted with regex \n    // ( \"XmQR4_hDtpY\" )\n    var itemArtist = // parsed from reddit posts listing \n    // ( \"Awesome Artist\" )\n    var itemTitle = // parsed from reddit posts listing \n    // ( \"Cool Song (Original Mix)\" )\n    var itemURL = // url, further processed \n    // ( \"3dydfy://www.youtube.com/watch?v=XmQR4_hDtpY&hd=1\" )\n\n    $.ajax({\n            type: \"HEAD\",\n            url: \"https://gdata.youtube.com/feeds/api/videos/\" + videoID,\n            error: function() { \n                // If it's no longer available \n                // (removed, deleted account, made private)\n                deadVid++; // chalk up another dead one, for showing progress\n                itemURL = // dead videos should get a different URL \n           // ( \"3dydfy-search://q=Awesome%20Artist%20Cool%20Song.....\" )\n            }\n        });\n\n    // further process itemURL!\n    // at this point I want itemURL changed by the .ajax()'s error callback\n    // but I'm trying to keep the requests async \n    // to not jam the page while a hundred HTTP requests happen!\n    if (condition){\n        itemURL += // append various strings\n    }\n    // Write the item to the .m3u8 playlist\n    playlist += itemURL + '\\n';\n}// end .each()\n
\n"},{"answers":[{"owner":{"reputation":42,"user_id":3766533,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/f034ad2421e09b3fa359aef7e0455a86?s=128&d=identicon&r=PG&f=1","display_name":"bandrzejczak","link":"http://stackoverflow.com/users/3766533/bandrzejczak"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773374,"creation_date":1414773374,"answer_id":26679409,"question_id":26679110,"body_markdown":"You have three options here:\r\n\r\n - Either you'll orther your parameters so that when you want to use param 5, you're sure, that previous params must also be defined\r\n - Or you can just use some character that represents null, like -, or something. Your URL would look like `/buildings/5/-/red`\r\n - Or (the best option) you *should* leave obligatory parameters in URL (like IDs) and put optional parameters in URL get parameters (like you showed in oldschool style parameters). Then your URL would look like this: `/buildings/5?color=red`. You can access those parameters from AngularJS using `$location.search().color` etc. ","link":"http://stackoverflow.com/questions/26679110/ngroute-support-for-multiple-url-parameters/26679409#26679409","body":"

You have three options here:

\n\n\n"}],"tags":["javascript","angularjs"],"owner":{"reputation":475,"user_id":619303,"user_type":"registered","accept_rate":58,"profile_image":"https://www.gravatar.com/avatar/2cac83e729b2bacee432797a5b4bfac3?s=128&d=identicon&r=PG","display_name":"omer bach","link":"http://stackoverflow.com/users/619303/omer-bach"},"comment_count":0,"is_answered":false,"view_count":10,"answer_count":1,"score":-1,"last_activity_date":1414773374,"creation_date":1414772339,"question_id":26679110,"body_markdown":"I have a major gap in operating ng routing functionalists.\r\nHere is what I want to achieve: I have a main page which directs to dashboard.html and another \r\nbuildings.html. \r\nThe buildings page could be called with many parameters, such as: id, type, color\r\nSo a traditional url would look like that: \r\n\r\n /buildings?id=110&type=special&color=red\r\n\r\nSo as far as I understand in angular ngroute I should have this structure: \r\n\r\n $routeProvider\r\n \t\t\t\r\n \t\t\t// route for the main page which will direct to the buildings page\r\n \t\t\t.when('/', {\r\n \t\t\t\ttemplateUrl : 'web/pages/dashboard.html',\r\n \t\t\t\tcontroller : 'dashboardController',\r\n \t\t\t\tcontrollerAs : 'dashboard'\r\n \t\t\t})\r\n \t\t\t\r\n \t\t\t// route for the main page which will direct to the buildings page\r\n \t\t\t.when('/buildings/:buildingId/:buildingType/:buildingColor', {\r\n \t\t\t\ttemplateUrl : 'web/pages/buildings.html',\r\n \t\t\t\tcontroller : 'mainController',\r\n \t\t\t\tcontrollerAs : 'buildings'\r\n \t\t\t})\r\n ;\r\n \t\t\t\r\n });\t\r\n\r\nAnd the url should be like:\r\n\r\n /buildings/110/special/red\r\n\r\n\r\nWhat I don't get is how to call for the buildings page with only id or with type and color?\r\nAnd if I have 7 parameters and want to trigger a call with only 3, how should I do that?\r\n\r\nI'm using $location.path to shift between pages when needed based on gui events, for example:\r\n$location.path( '/buildings/'+$scope.id);\r\n\r\nThanks.","link":"http://stackoverflow.com/questions/26679110/ngroute-support-for-multiple-url-parameters","title":"ngroute support for multiple url parameters","body":"

I have a major gap in operating ng routing functionalists.\nHere is what I want to achieve: I have a main page which directs to dashboard.html and another \nbuildings.html. \nThe buildings page could be called with many parameters, such as: id, type, color\nSo a traditional url would look like that:

\n\n
/buildings?id=110&type=special&color=red\n
\n\n

So as far as I understand in angular ngroute I should have this structure:

\n\n
$routeProvider\n\n            // route for the main page which will direct to the buildings page\n            .when('/', {\n                templateUrl : 'web/pages/dashboard.html',\n                controller  : 'dashboardController',\n                controllerAs : 'dashboard'\n            })\n\n            // route for the main page which will direct to the buildings page\n            .when('/buildings/:buildingId/:buildingType/:buildingColor', {\n                templateUrl : 'web/pages/buildings.html',\n                controller  : 'mainController',\n                controllerAs : 'buildings'\n            })\n            ;\n\n}); \n
\n\n

And the url should be like:

\n\n
/buildings/110/special/red\n
\n\n

What I don't get is how to call for the buildings page with only id or with type and color?\nAnd if I have 7 parameters and want to trigger a call with only 3, how should I do that?

\n\n

I'm using $location.path to shift between pages when needed based on gui events, for example:\n$location.path( '/buildings/'+$scope.id);

\n\n

Thanks.

\n"},{"answers":[{"owner":{"reputation":5649,"user_id":1071684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/089af77f838033f2f970a68f1598109c?s=128&d=identicon&r=PG","display_name":"Dor Shemer","link":"http://stackoverflow.com/users/1071684/dor-shemer"},"comments":[{"owner":{"reputation":1701,"user_id":473961,"user_type":"registered","accept_rate":33,"profile_image":"https://www.gravatar.com/avatar/28da63e58ce7fa428494292973747c84?s=128&d=identicon&r=PG","display_name":"Jess Telford","link":"http://stackoverflow.com/users/473961/jess-telford"},"edited":false,"score":0,"creation_date":1352431746,"post_id":9558954,"comment_id":18139984},{"owner":{"reputation":1701,"user_id":473961,"user_type":"registered","accept_rate":33,"profile_image":"https://www.gravatar.com/avatar/28da63e58ce7fa428494292973747c84?s=128&d=identicon&r=PG","display_name":"Jess Telford","link":"http://stackoverflow.com/users/473961/jess-telford"},"edited":false,"score":1,"creation_date":1352432294,"post_id":9558954,"comment_id":18140116},{"owner":{"reputation":445,"user_id":411615,"user_type":"registered","accept_rate":84,"profile_image":"http://i.stack.imgur.com/7vbPQ.jpg?s=128&g=1","display_name":"Deckard","link":"http://stackoverflow.com/users/411615/deckard"},"edited":false,"score":0,"creation_date":1400146209,"post_id":9558954,"comment_id":36369430},{"owner":{"reputation":5649,"user_id":1071684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/089af77f838033f2f970a68f1598109c?s=128&d=identicon&r=PG","display_name":"Dor Shemer","link":"http://stackoverflow.com/users/1071684/dor-shemer"},"reply_to_user":{"reputation":445,"user_id":411615,"user_type":"registered","accept_rate":84,"profile_image":"http://i.stack.imgur.com/7vbPQ.jpg?s=128&g=1","display_name":"Deckard","link":"http://stackoverflow.com/users/411615/deckard"},"edited":false,"score":0,"creation_date":1413808358,"post_id":9558954,"comment_id":41569422}],"last_editor":{"reputation":5649,"user_id":1071684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/089af77f838033f2f970a68f1598109c?s=128&d=identicon&r=PG","display_name":"Dor Shemer","link":"http://stackoverflow.com/users/1071684/dor-shemer"},"comment_count":4,"is_accepted":true,"score":31,"last_activity_date":1330896721,"last_edit_date":1330896721,"creation_date":1330896366,"answer_id":9558954,"question_id":9558867,"body_markdown":"Use `-s` and `-N`:\r\n\r\n > id=`mysql -uroot -ppwd -s -N -e "SELECT id FROM nagios.host WHERE name='$host'"`\r\n > echo $id\r\n 0\r\n\r\nFrom the manual:\r\n\r\n\r\n> --silent, -s\r\n> \r\n> Silent mode. Produce less output. This option can be given multiple\r\n> times to produce less and less output.\r\n> \r\n> This option results in nontabular output format and escaping of\r\n> special characters. Escaping may be disabled by using raw mode; see\r\n> the description for the --raw option.\r\n> \r\n> --skip-column-names, -N\r\n> \r\n> Do not write column names in results.\r\n\r\n**EDIT**\r\n\r\nLooks like `-ss` works as well and much easier to remember.","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/9558954#9558954","body":"

Use -s and -N:

\n\n
> id=`mysql -uroot -ppwd -s -N -e \"SELECT id FROM nagios.host WHERE name='$host'\"`\n> echo $id\n0\n
\n\n

From the manual:

\n\n
\n

--silent, -s

\n\n
   Silent mode. Produce less output. This option can be given multiple\n   times to produce less and less output.\n\n   This option results in nontabular output format and escaping of\n   special characters. Escaping may be disabled by using raw mode; see\n   the description for the --raw option.\n
\n \n

--skip-column-names, -N

\n\n
   Do not write column names in results.\n
\n
\n\n

EDIT

\n\n

Looks like -ss works as well and much easier to remember.

\n"},{"owner":{"reputation":197,"user_id":661440,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/bd32692c3bb8c4161d4e78c9041abb69?s=128&d=identicon&r=PG","display_name":"corgi","link":"http://stackoverflow.com/users/661440/corgi"},"comment_count":0,"is_accepted":false,"score":1,"last_activity_date":1330896439,"creation_date":1330896439,"answer_id":9558956,"question_id":9558867,"body_markdown":"Try:\r\n\r\n mysql -B --column-names=0 -uroot -ppwd -e "SELECT id FROM nagios.host WHERE name='$host'"\r\n\r\n-B will print results using tab as the column separator and \r\n\r\n--column-names=0 will disable the headers.","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/9558956#9558956","body":"

Try:

\n\n
mysql -B --column-names=0 -uroot -ppwd -e \"SELECT id FROM nagios.host WHERE name='$host'\"\n
\n\n

-B will print results using tab as the column separator and

\n\n

--column-names=0 will disable the headers.

\n"},{"owner":{"reputation":156,"user_id":1307507,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b988bb2d4741f1451444d8115ce5b3f8?s=128&d=identicon&r=PG","display_name":"Marcelo Amorim","link":"http://stackoverflow.com/users/1307507/marcelo-amorim"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1371067057,"creation_date":1371067057,"answer_id":17074180,"question_id":9558867,"body_markdown":"I tried the solutions but always received empty response.\r\n\r\nIn my case the solution was:\r\n\r\n\r\n #!/bin/sh\r\n\r\n FIELDVALUE=$(mysql -ss -N -e "SELECT field FROM db.table where fieldwhere = '$2'")\r\n\r\n echo $FIELDVALUE","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/17074180#17074180","body":"

I tried the solutions but always received empty response.

\n\n

In my case the solution was:

\n\n
#!/bin/sh\n\nFIELDVALUE=$(mysql -ss -N -e \"SELECT field FROM db.table where fieldwhere = '$2'\")\n\necho $FIELDVALUE\n
\n"},{"owner":{"reputation":1,"user_id":3944617,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/cbd42222f23b6c4d4ee1edd3e6b66826?s=128&d=identicon&r=PG","display_name":"tom","link":"http://stackoverflow.com/users/3944617/tom"},"comment_count":0,"is_accepted":false,"score":0,"last_activity_date":1414773373,"creation_date":1414773373,"answer_id":26679408,"question_id":9558867,"body_markdown":"+----+------------------+----------+--------------------------------+----------+\r\n| ID | Name | Priority | Description | Disabled |\r\n+----+------------------+----------+--------------------------------+----------+\r\n| 1 | Default | 0 | Default System Policy | 0 |\r\n| 2 | Default Outbound | 10 | Default Outbound System Policy | 0 |\r\n| 3 | Default Inbound | 10 | Default Inbound System Policy | 0 |\r\n| 4 | Default Internal | 20 | Default Internal System Policy | 0 |\r\n| 5 | Test | 50 | Test policy | 0 |\r\n| 6 | $u00492 | 100 | SMTP User Policy | 0 |\r\n+----+------------------+----------+--------------------------------+----------+\r\n\r\nThis is my table and i have to select only ID 6 u00492 this use.\r\n\r\nBut above command is not working on this.","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash/26679408#26679408","body":"

+----+------------------+----------+--------------------------------+----------+\n| ID | Name | Priority | Description | Disabled |\n+----+------------------+----------+--------------------------------+----------+\n| 1 | Default | 0 | Default System Policy | 0 |\n| 2 | Default Outbound | 10 | Default Outbound System Policy | 0 |\n| 3 | Default Inbound | 10 | Default Inbound System Policy | 0 |\n| 4 | Default Internal | 20 | Default Internal System Policy | 0 |\n| 5 | Test | 50 | Test policy | 0 |\n| 6 | $u00492 | 100 | SMTP User Policy | 0 |\n+----+------------------+----------+--------------------------------+----------+

\n\n

This is my table and i have to select only ID 6 u00492 this use.

\n\n

But above command is not working on this.

\n"}],"tags":["mysql","bash"],"owner":{"reputation":3417,"user_id":576831,"user_type":"registered","accept_rate":93,"profile_image":"https://www.gravatar.com/avatar/848e676aff5041064d576a3930ae4aab?s=128&d=identicon&r=PG","display_name":"Nayish","link":"http://stackoverflow.com/users/576831/nayish"},"comment_count":0,"is_answered":true,"view_count":21735,"accepted_answer_id":9558954,"answer_count":4,"score":19,"last_activity_date":1414773373,"creation_date":1330895621,"last_edit_date":1330896234,"question_id":9558867,"body_markdown":"I would like to get only the value of a MySQL query result in a bash script. For example the running the following command:\r\n\r\n mysql -uroot -ppwd -e "SELECT id FROM nagios.host WHERE name='$host'"\r\n\r\nreturns:\r\n\r\n +----+\r\n | id |\r\n +----+\r\n | 0 |\r\n +----+\r\nHow can I fetch the value returned in my bash script?","link":"http://stackoverflow.com/questions/9558867/how-to-fetch-field-from-mysql-query-result-in-bash","title":"How to fetch field from MySQL query result in bash","body":"

I would like to get only the value of a MySQL query result in a bash script. For example the running the following command:

\n\n
mysql -uroot -ppwd -e \"SELECT id FROM nagios.host WHERE name='$host'\"\n
\n\n

returns:

\n\n
+----+\n| id |\n+----+\n| 0  |\n+----+\n
\n\n

How can I fetch the value returned in my bash script?

\n"},{"tags":["asp.net","debugging","syntax-error"],"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"comments":[{"owner":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414728056,"post_id":26643396,"comment_id":41936049},{"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"reply_to_user":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414764977,"post_id":26643396,"comment_id":41952562},{"owner":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414768666,"post_id":26643396,"comment_id":41954898},{"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"reply_to_user":{"reputation":991,"user_id":638087,"user_type":"registered","accept_rate":72,"profile_image":"https://www.gravatar.com/avatar/c9f31759c969f675b0ab91990c009c12?s=128&d=identicon&r=PG","display_name":"trnelson","link":"http://stackoverflow.com/users/638087/trnelson"},"edited":false,"score":0,"creation_date":1414770063,"post_id":26643396,"comment_id":41955779},{"owner":{"reputation":16599,"user_id":1127114,"user_type":"registered","accept_rate":80,"profile_image":"https://www.gravatar.com/avatar/bb1b2345f4c7b696d7c0376d273d01b2?s=128&d=identicon&r=PG","display_name":"Michael Liu","link":"http://stackoverflow.com/users/1127114/michael-liu"},"edited":false,"score":0,"creation_date":1414772904,"post_id":26643396,"comment_id":41957454},{"owner":{"reputation":38,"user_id":3783852,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b157fba97ac81fac9e5a77b35cf75e49?s=128&d=identicon&r=PG&f=1","display_name":"user3783852","link":"http://stackoverflow.com/users/3783852/user3783852"},"edited":false,"score":0,"creation_date":1414773226,"post_id":26643396,"comment_id":41957614}],"comment_count":6,"is_answered":false,"view_count":41,"answer_count":0,"score":3,"last_activity_date":1414773372,"creation_date":1414631395,"last_edit_date":1414773372,"question_id":26643396,"body_markdown":"I really desperately need your help because I got very unusual problem with my programs:\r\n\r\n 1. I am receiving this error when I am trying to debug my ASP.NET or MVC Application on local IIS Server 7.5:\r\n"Unable to start debugging on the web server. The debug request could not be processed by the server due to invalid syntax. "\r\n\r\n ![enter image description here][1]\r\n\r\n 2. I tried literally every solution I could find in google until this day. I spent 12 hours trying to figure this out. Without luck.\r\n 3. Error happens only with this address: http:// localhost/AspDemo not with this one: https:// localhost/AspDemo. Basically, I can debug like always if I put https instead of http.\r\n\r\n 4. https is disabled on my local IIS server :), I mean it is set to ignore.\r\n\r\n 5. Moreover I CAN open my sites with using BOTH protocols in IIS Control Panel\r\n\r\n 6. If I disable ASP.NET Debugger in Properties of my App in Visual Studio, Application runs fine.\r\n 7. This is the error from the httperr log:\r\n\r\n **2014-10-30 00:23:46 ::1%0 2977 ::1%0 80 - - - 400 - Verb -**\r\n\r\n 8. I am not sure where exactly, but in some other log I saw reference to something like this: **Error 400 "Bad Request - Invalid Verb"**\r\n 9. A week ago ALL applications I got problems with were working perfectly with asp.net debugger from visual studio, I had no idea what happened.\r\n\r\n 10. I suspect some update. Because updates lately messed with my custom bootloader as well.\r\n\r\n 11. When I enable tracing - log is empty with http\r\n\r\n 12. Fiddler log is empty as well, maybe there is some config I can use in Fiddler to produce some more logs? (It logs of course with modified machine.config when I use https)\r\n\r\nWould be eternally grateful for your help, if you need some more logs, please don't hestitate to ask.\r\n\r\nI would like to mention as well that yes, I saw similar posts on this site, but none of them described problem this similar to mine.\r\n\r\n/edit\r\n\r\nFrom what I was able to observe, error happens BEFORE debugger access machine.config file, can you guys tell me how to catch errors in that moment?\r\n\r\n\r\n**==== /edit 2 ====**\r\n\r\n\r\nAnyone? No one knows the answer?\r\nRecently I was able to find the complete error message in: C:\\Users\\<UserName>\\AppData\\Local\\Temp\\Visual Studio Web Debugger.log\r\n\r\n http://localhost/MVCDemo/debugattach.aspx\r\n\r\n Status code=400 (Bad Request)\r\n Protocol version=1.1\r\n Cached=False\r\n Connection=close\r\n Content-Length=326\r\n Content-Type=text/html; charset=us-ascii\r\n Date=Fri, 31 Oct 2014 03:44:14 GMT\r\n Server=Microsoft-HTTPAPI/2.0\r\n\r\n <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">\r\n <HTML><HEAD><TITLE>Bad Request</TITLE>\r\n <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>\r\n <BODY><h2>Bad Request - Invalid Verb</h2>\r\n <hr><p>HTTP Error 400. The request verb is invalid.</p>\r\n </BODY></HTML>\r\n\r\nIn proccess monitor, I found this one as well:\r\n\r\n <event>\r\n <ProcessIndex>1339</ProcessIndex>\r\n <Time_of_Day>04:40:33,3661553</Time_of_Day>\r\n <Process_Name>devenv.exe</Process_Name>\r\n <PID>10768</PID>\r\n <Operation>CreateFile</Operation>\r\n <Path>C:\\Users\\<UserName>\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.ini</Path>\r\n <Result>PATH NOT FOUND</Result>\r\n <Detail>Desired Access: Read Data/List Directory, Read Attributes, Synchronize, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a</Detail>\r\n </event>\r\n\r\nI really, really need help with this.\r\n\r\n\r\n**=== /edit 3 ===**\r\n\r\nSecond error is not relevant, I just checked and it is present with https as well (C:\\Users\\<UserName>\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.in), and debugging as https localhost works perfectly.\r\n\r\n**=== /edit 4 ===**\r\n\r\nHere are Process Monitor logs captured during Visual Studio Debugging HTTP (not working) and HTTPS (working)\r\n\r\n(Test performed on random MVC Tutorial)\r\n\r\nUse CTRL+F and Look for "Visual Studio Web Debugger.log" in logs to get the idea when it is happening. In https log is good, in http log returns Invalid Verb error mentioned before.\r\n\r\n - HTTP (not working)::\r\n https://www.dropbox.com/s/7b26ybogtyqlico/LogFile%20HTTP%20NOT%20Working.CSV?dl=0\r\n - HTTPS (working):\r\n https://www.dropbox.com/s/ggsj57v97ky90e6/LogFile%20HTTPS%20Working.CSV?dl=0\r\n\r\n**I might be wrong, but I think the key here is that only HTTP doesn't work and only with VS Debugger, everything else is just fine.**\r\n\r\n [1]: http://i.stack.imgur.com/qSluD.png","link":"http://stackoverflow.com/questions/26643396/asp-net-debugger-gives-errors-with-http-while-working-with-https","title":"ASP.NET debugger gives errors with http, while working with https","body":"

I really desperately need your help because I got very unusual problem with my programs:

\n\n
    \n
  1. I am receiving this error when I am trying to debug my ASP.NET or MVC Application on local IIS Server 7.5:\n\"Unable to start debugging on the web server. The debug request could not be processed by the server due to invalid syntax. \"

    \n\n

    \"enter

  2. \n
  3. I tried literally every solution I could find in google until this day. I spent 12 hours trying to figure this out. Without luck.

  4. \n
  5. Error happens only with this address: http:// localhost/AspDemo not with this one: https:// localhost/AspDemo. Basically, I can debug like always if I put https instead of http.

  6. \n
  7. https is disabled on my local IIS server :), I mean it is set to ignore.

  8. \n
  9. Moreover I CAN open my sites with using BOTH protocols in IIS Control Panel

  10. \n
  11. If I disable ASP.NET Debugger in Properties of my App in Visual Studio, Application runs fine.

  12. \n
  13. This is the error from the httperr log:

    \n\n

    2014-10-30 00:23:46 ::1%0 2977 ::1%0 80 - - - 400 - Verb -

  14. \n
  15. I am not sure where exactly, but in some other log I saw reference to something like this: Error 400 \"Bad Request - Invalid Verb\"

  16. \n
  17. A week ago ALL applications I got problems with were working perfectly with asp.net debugger from visual studio, I had no idea what happened.

  18. \n
  19. I suspect some update. Because updates lately messed with my custom bootloader as well.

  20. \n
  21. When I enable tracing - log is empty with http

  22. \n
  23. Fiddler log is empty as well, maybe there is some config I can use in Fiddler to produce some more logs? (It logs of course with modified machine.config when I use https)

  24. \n
\n\n

Would be eternally grateful for your help, if you need some more logs, please don't hestitate to ask.

\n\n

I would like to mention as well that yes, I saw similar posts on this site, but none of them described problem this similar to mine.

\n\n

/edit

\n\n

From what I was able to observe, error happens BEFORE debugger access machine.config file, can you guys tell me how to catch errors in that moment?

\n\n

==== /edit 2 ====

\n\n

Anyone? No one knows the answer?\nRecently I was able to find the complete error message in: C:\\Users\\\\AppData\\Local\\Temp\\Visual Studio Web Debugger.log

\n\n
http://localhost/MVCDemo/debugattach.aspx\n\nStatus code=400 (Bad Request)\nProtocol version=1.1\nCached=False\nConnection=close\nContent-Length=326\nContent-Type=text/html; charset=us-ascii\nDate=Fri, 31 Oct 2014 03:44:14 GMT\nServer=Microsoft-HTTPAPI/2.0\n\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">\n<HTML><HEAD><TITLE>Bad Request</TITLE>\n<META HTTP-EQUIV=\"Content-Type\" Content=\"text/html; charset=us-ascii\"></HEAD>\n<BODY><h2>Bad Request - Invalid Verb</h2>\n<hr><p>HTTP Error 400. The request verb is invalid.</p>\n</BODY></HTML>\n
\n\n

In proccess monitor, I found this one as well:

\n\n
<event>\n<ProcessIndex>1339</ProcessIndex>\n<Time_of_Day>04:40:33,3661553</Time_of_Day>\n<Process_Name>devenv.exe</Process_Name>\n<PID>10768</PID>\n<Operation>CreateFile</Operation>\n<Path>C:\\Users\\<UserName>\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.ini</Path>\n<Result>PATH NOT FOUND</Result>\n<Detail>Desired Access: Read Data/List Directory, Read Attributes, Synchronize, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a</Detail>\n</event>\n
\n\n

I really, really need help with this.

\n\n

=== /edit 3 ===

\n\n

Second error is not relevant, I just checked and it is present with https as well (C:\\Users\\\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0\\Debugger\\StepIntoFilterData.in), and debugging as https localhost works perfectly.

\n\n

=== /edit 4 ===

\n\n

Here are Process Monitor logs captured during Visual Studio Debugging HTTP (not working) and HTTPS (working)

\n\n

(Test performed on random MVC Tutorial)

\n\n

Use CTRL+F and Look for \"Visual Studio Web Debugger.log\" in logs to get the idea when it is happening. In https log is good, in http log returns Invalid Verb error mentioned before.

\n\n\n\n

I might be wrong, but I think the key here is that only HTTP doesn't work and only with VS Debugger, everything else is just fine.

\n"}],"has_more":true,"quota_max":300,"quota_remaining":255} diff --git a/sample-question-unauthenticated.el b/sample-question-unauthenticated.el new file mode 100644 index 0000000..0e1c8c3 --- /dev/null +++ b/sample-question-unauthenticated.el @@ -0,0 +1,45 @@ + +(defvar sample-question-unauthenticated +;;; A sample of data offered by the question object, without authentication. + '((body . "

I am getting \"rgb(18, 115, 224)\" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use

+ +
\"#\" + componentToHex(r) + componentToHex(g) + componentToHex(b)
+
+ +

but, My question here's how can I get the r, g,b component values from \"rgb(18, 115, 224)\"

+") + (title . "get r, g, b component of a color in rgb() format") + (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format") + (body_markdown . "I am getting "rgb(18, 115, 224)" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use + + "#" + componentToHex(r) + componentToHex(g) + componentToHex(b) +but, My question here's how can I get the r, g,b component values from "rgb(18, 115, 224)"") + (question_id . 26679366) + (creation_date . 1414773223.0) + (last_activity_date . 1414773433.0) + (score . 0) + (answer_count . 2) + (view_count . 16) + (is_answered . :json-false) + (comment_count . 1) + (comments . [((comment_id . 41957708) (post_id . 26679366) (creation_date . 1414773413.0) (score . 0) (edited . :json-false) (owner (link . "http://stackoverflow.com/users/14104/epascarello") (display_name . "epascarello") (profile_image . "https://www.gravatar.com/avatar/760b4da77fd54d37c104029ff1f56749?s=128&d=identicon&r=PG") (user_type . "registered") (user_id . 14104) (reputation . 76145)))]) + (owner (link . "http://stackoverflow.com/users/3867678/rasmita-dash") (display_name . "Rasmita Dash") (profile_image . "http://graph.facebook.com/100001985977413/picture?type=large") (accept_rate . 45) (user_type . "registered") (user_id . 3867678) (reputation . 90)) + (tags . ["javascript" "jquery" "html" "css" "colors"]) + (answers . [((body . "
+

Now I want to assign the color(whatever i am getting from this element) to a span element.

+
+ +

No you don't, you can just use rgb(18, 115, 224) directly for a color value in CSS.

+") (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679414#26679414") (body_markdown . "> Now I want to assign the color(whatever i am getting from this element) to a span element. + +No you don't, you can just use `rgb(18, 115, 224)` directly for a color value in CSS.") (question_id . 26679366) (answer_id . 26679414) (creation_date . 1414773411.0) (last_activity_date . 1414773411.0) (score . 0) (is_accepted . :json-false) (comment_count . 0) (owner (link . "http://stackoverflow.com/users/157247/t-j-crowder") (display_name . "T.J. Crowder") (profile_image . "https://www.gravatar.com/avatar/ca3e484c121268e4c8302616b2395eb9?s=128&d=identicon&r=PG") (accept_rate . 90) (user_type . "registered") (user_id . 157247) (reputation . 307244))) ((body . "

You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:

+ +
var clr = rgb(18, 115, 224);
+$('#myspan').css('color', clr);
+
+") (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679423#26679423") (body_markdown . "You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do: + + var clr = rgb(18, 115, 224); + $('#myspan').css('color', clr);") (question_id . 26679366) (answer_id . 26679423) (creation_date . 1414773433.0) (last_activity_date . 1414773433.0) (score . 0) (is_accepted . :json-false) (comment_count . 0) (owner (link . "http://stackoverflow.com/users/717214/aleks-g") (display_name . "Aleks G") (profile_image . "https://www.gravatar.com/avatar/9075315c5f4b734a8f2567be54a4cc45?s=128&d=identicon&r=PG") (accept_rate . 92) (user_type . "registered") (user_id . 717214) (reputation . 26812)))]))) + +(provide 'sample-question-unauthenticated) -- cgit v1.2.3