Is there a way to write this but using question mark not hash
/#varb,Varc
/?varb,Varc
window.location.hash.substring(1);
This does not work:
window.location.questionmark.substring(1);
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
As far I as my experience tells me, boolean variables usually named in format - is/has+noun/adj/verb, e.g isValid, isButton, hasClickedLink
But say there is the case where we have some flag which straightly tells whether to do something, like for example, clean to indicate that cleanup function should be automatically called in the end.
How to name such a booleans? Same clean - is ambiguous, looks like a method name more, but naming it toClean is, I don't know, too weird. Or should I name it like callCleanup?
Thanks in advance!
In this case i usually append the word wanted, which makes cleanWanted. In general, for boolean variables I also prefer to always let the last word be an adjective. This makes it very clear that it represents a truth value. The is/has prefix is often superfluous, as in hasClickedLink which is more concisely communicated with linkClicked.
methods are usually one word adjectives with a capitol at the start
maybe create a method that sets the flag
for example
void Clean(){
clean = True;
}
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
Improve this question
[disclosure: I asked about this earlier on the NixOS channel but didn't get an answer after 30 minutes and it's a busy channel. If I get one there, I'll replicate it here]
I'm trying to add some lines to a configuration file in NixOS (for example /etc/pam.d/sudo). The configuration options available in pam.nix do not include the line I want to add (in this case, account requisite pam_time.so), and it does not include an extraConfig option either.
I know I can create new configuration files using environement.etc.filename.text so I went with that, but sudo nixos-rebuild switch then complains that it has two sources for the configuration file, the official one and mine (mismatched duplicate entry /nix/… <-> /nix/…):
environment.etc."pam.d/sudo".text = ''blah'';
Is there a general way to append to a /etc/ configuration file (or to patch it) in NixOS?
Or is the only way to modify the system .nix files (e.g. modifying pam.nix, which I'm reluctant to do as it will collide with future updates)?
You can add lines to the default value of security.pam.services.sudo.text using mkOverride or the shortcut mkDefault to give your value the same priority as the default. You can control the order with mkOrder or the shortcuts mkBefore and mkAfter. So to append, you could do:
security.pam.services.sudo.text = pkgs.lib.mkDefault( pkgs.lib.mkAfter "# hi" );
When there are multiple values for an option, only the values with the lowest priority are kept. If there are still multiple values, they are sorted and merged. mkOverride and mkOrder create special values that the code in modules.nix recognizes when it is doing this. Ordinary values have the default priority (100) and sort order (1000). pam.nix uses mkDefault for the value it creates for the text option, which makes the priority 1000, thus ordinary values will replace it instead of being merged.
The NixOS manual section on Modularity explains a bit more.
I don't think you can do this generically for environment.etc because the target file doesn't have to match the attribute name, and pam.nix in particular does not name any of its entries in environment.etc. It is more like a list of instructions that are processed in sequence. See etc.nix and
make-etc.sh
For the files of /etc/pam.d/sudo and other files in the same directory, a simple solution is to use security.pam.services.sudo.text, but my current best attempt requires hardcoding the original contents of the file.
security.pam.services.sudo.text = ''
existing contents of /etc/pam.d/sudo …
extra lines …
'';
Hopefully other answers will come up with a more general-purpose way of altering configuration files (and keeping their original contents).
I tried to append two hash tables in velocity.
#foreach($dun1 in $dotcontent.pull("+structureName:Checnas +(conhost:fe1d98e8-9699-4f3f-abf5-a6c0afc8ab47 conhost:SYSTEM_HOST)",10,"modDate desc"))
#set($foo={
$!{dun1.mname}:$!{dun1.subname}
})
#end
In the above for each loop I am pulling content from structure "Checnas".
But at the end we can get only the last value in the content.To solve that we need to append for every iteration.I need syntax for appending hash tables.
Please help me to solve this.
Your code currently is over writing $foo each time and hence you are just getting the last value. You can use lists in velocity to achieve this.
This might work:
#set($listOfMnames=[])
#set($listOfSubNames=[])
#foreach($dun1 in $dotcontent.pull("+structureName:Checnas +(conhost:fe1d98e8-9699-4f3f-abf5-a6c0afc8ab47 conhost:SYSTEM_HOST)",10,"modDate desc"))
#set($foo=$listOfMnames.add($!{dun1.mname}))
#set($foo=$listOfSubNames.add($!{dun1.subname}))
#end
This way, you will end up with two lists 'listOfMnames' and 'listOfSubNames', both fully populated. You can later iterate through them to print/utilise their values.
This link will be helpful and tell you the purpose of using $foo which is not being used and just being assigned.
Alternatively, you can also use velocity maps with proper key/val pairs but be sure to declare it before the loop begins.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
String comparison in Objective-C
I realize that the question is not very specific. I am working on a simple trivia game to test a couple of things, right now it has 5 arrays, one for the questions, one for the first answer option, one for the second answer option, one for the third, and one that says which one is correct.
I have an if statement in that checks wether the button pressed matches the correct answer.
Answer2 is connected to the button that would select option b in my trivia app, strCorrect is the string array that holds the single character that says which option out of the three is right, intCurrentQuestion is just an integer I use to reference the index of the arrays.
-(IBAction)Answer2{
if ([strCorrect objectAtIndex:intCurrentQuestion] == [NSString stringWithFormat:#"B"]){
//do these things blah blah
}
}
The problem is that there are no errors when it is compiled but it doesn't work either. How do I go about making this work?
For testing purpose I am cheating and passing the strCorrect to a hidden label in the nib and then comparing the label text to #"B" and it works but its...well its just awful.
What you're doing in your code above is comparing the memory address of two strings, not their value. Do compare two NSStrings you have to do this:
[[strCorrect objectAtIndex:intCurrentQuestion] isEqualToString:#"B"];
[[strCorrect objectAtIndex:intCurrentQuestion] isEqualToString:#"B"]
This question already has answers here:
Custom tags with Doxygen
(3 answers)
Closed 5 years ago.
I'd like to add a custom command to my doxygen documentation. Basically for each C function I'm writing doc for, I need to write which global variables are "touched" in read mode or write mode. It's like the "See also" list, just with a different caption.
In my file I'd like to write something like this:
/*
* \read-globals #var1, #var2
*
* \write-globals #var3
*/
I tried with an alias like this:
read-globals = \par <b>Globals read</b>\n
It works but I fear that it's style sheet independent: If tomorrow I'll want to change css, then this custom command will generate output which looks different from seealso, author and all other sections.
Basically I just want to copy the format from other standard commands.
Another option is to use to the \xrefitem command, which works too, but it requires to introduce a section as second parameter which is totally useless in my case (maybe it can be hidden somehow?).
Is there a "right way" to achieve my goal?
You can combine \xrefitem and ALIASES if you want to hide the second parameter. Here is an example I use for requirements:
ALIASES += "req=\xrefitem req \"Requirement\" \"Requirements\" "
Then in documented code:
/// \req #42 The system shall work in any situation
(from my answer to that question: Custom tags with Doxygen)