This question already has answers here:
How to check if a POST submitted field exists in VBScript?
(4 answers)
Closed 5 years ago.
Is there a way to check if a variable exists on the current page in asp? i.e.
For the url: https://stackoverflow.com/?question=something
I'd like to check if the ?question variable exists.
<%Request.ServerVariables("Query_String")%> would give question=something but I just want to know if the current url contains ?question. I don't care what the actual value is as long as it exists.
Ask the Request collection:
HasParam = Request("question").Count > 0
Related
This question already has answers here:
Calling a Method From a String With the Method's Name in Ruby
(4 answers)
Closed 3 years ago.
I have a table of scores that need processing at certain points. I am trying to avoid having walls of repetitive code so I am trying to get the values dynamically just by sending in the metric value but I cannot seem to get the syntax right and wasn't even sure how to properly search for this.
A typical value I need is something like this
s = score.total_weighted_strategic_values_score
All of these have the same structure to the name but one part changes based on the metric, so I have been trying something like this
s = score.total_weighted_"#{metric}"_score
Where metric is equal to a string strategic_values or whatever the metric is named.
This throws a syntax error, however, and I cannot find anything else to try. any help would be greatly appreciated, thanks!
You need to use public_send:
s = score.public_send("total_weighted_#{metric}_score")
Some more reading on it:
http://vaidehijoshi.github.io/blog/2015/05/05/metaprogramming-dynamic-methods-using-public-send/
This question already has answers here:
How to get text response in survey monkey via API
(2 answers)
Closed 7 months ago.
I'm grabbing survey responses using "/surveys/" . $id . "/responses/bulk". For multiple choice questions, how do I include the label text for a response? Only choice_id is given. I've looked in the document and can't seem to find a clue.
Thanks!
Dylan
Use the following API endpoint pattern to fetch all the information on the question, including the selects:
https://api.surveymonkey.com/v3/surveys/{survey_id}/pages/{page_id}/questions/{question_id}
This question already has answers here:
How to validate text isn't blank in Rails
(3 answers)
Closed 6 years ago.
I'm trying to find a way to reject creation of a message if the form filled out is empty (including spaces and new lines). Currently I have the form set to required: true but that doesn't stop a user from hitting the spacebar and sending the message. I don't know if Rails has a built in validation or if there is some regex I would have to use.
You're after a presence validator in your model. It will explicitly require that your field's present? be true, which it won't be if the column contains only whitespace.
This question already has answers here:
What does map(&:name) mean in Ruby?
(17 answers)
Closed 9 years ago.
In another answer, I saw an interesting syntax for calling a method on each object in a collection in Rails (or is this really just Ruby?) I tried searching for it but I couldnt find any documentation on it.
reports.map(&:reload)
Is &: an operator? If not, what is it? What is it called? What else can be done with the &: operator?
&: is called symbol_to_proc
And it is ruby not rails specific
Relevant link
http://pragdave.pragprog.com/pragdave/2005/11/symbolto_proc.html
This question already has answers here:
Closed 12 years ago.
How can i get an unique id from one of installed hardwares? Something like h.d.d serial or motherboard, ....?
Thanks
Check this URL : http://www.diskserialnumber.com/
http://www.diskserialnumber.com/get-disk-serial
Better one:
http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx
We use http://www.magsys.co.uk/delphi/magwmi.asp and are very happy with it.