Remove XML nodes in PHP
Remove a child with a specific attribute, in SimpleXML for PHP
In Google Sheets how do I duplicate a sheet along with its permission In a Google Spreadsheet called Attendance there is a sheet called Template. The user duplicates this sheet, renames the sheet with current date and uses this sheet to mark attendance for students. The Template sheet contains protected cells and the attendance is marked by entering Student's ID number in the space given (unprotected cells). I use the following script to duplicate multiple sheets and rename them everyday:  function createDailyAttendance() {   var ss = SpreadsheetApp.getActiveSpreadsheet();   var refss = ss.getSheetByName("DataPointers");      // Get the range Row and Column information.   var dataRangeRow = refss.getRange("K2").getValue();   //var dataRangeCol = ss.getRangeByName(ColName).getValue();      // Get the range of cells that store Duplicate sheet name.   var AttendanceDataRange = refss.getRange(dataRangeRow);    var AttendanceObjects = AttendanceDataRange.getValues();    var template = ss.getSheetByName('Template');    for (var i=0; i &lt; AttendanceObjects.length; i++) {       // Put the sheet you want to create in a variable      var sheet = ss.getSheetByName(AttendanceObjects[i]);        // Check if the sheet you want to create already exists. If so,       // log this and loop back. If not, create the new sheet.         if (sheet) {            Logger.log("Sheet " + AttendanceObjects[i] + "already exists");         } else {            template.copyTo(ss).setName(AttendanceObjects[i]);            }         }   return; }   This script helps me create multiple copies of sheets from Template but the duplicate copies do not retain the Cell/Range permissions. Is there a way to add a loop function which extracts permission from Template and applies it every time the loop template.copyTo creates a sheet? How to prompt for user input and read command-line arguments I did setup an easy scene with an area light behind a window. In the glass (simple plane) which is in front the area light is visible - how can I turn this off so that the background is shining throgh? Genetic linkage greater than 50 centimorgans Classically, the linkage between two loci can be measured in centimorgans (cM), which represents the percent chance that these two loci will recombine an odd number of times (generating a recombinant genotype).  Due to independent assortment, markers on different chromosomes are expected to recombine 50% of the time. As I understand, if one conducts a classic experiment and counts various progeny, then deduces the apparent linkage, values of 50 cM or more are interpreted as "impossible to determine whether on separate chromosomes or just recombines very often". See (), with grammar corrected:     The final point that we need to make regards the maximum distance that we can measure. Because of the way in which the calculations are performed, we can never have more (than) 50% recombinant gametes. Therefore the (maximum) distance that two genes can be apart and still measure that distance is just less (than) 50 cM. If two genes are greater than 50 cM apart, then we can not determine if they reside on the same chromosome or are on different chromosomes.   Wikipedia gives an  and also remarks that (d is physical distance):     The probability of recombination is approximately d/100 for small values of d and approaches 50% as d goes to infinity.   However, what happens if the linkage is greater than 50 cM? It seems like classical experiments aside, such a situation is possible in reality.  For instance, , and . Let's take two genes on Chr.IV:    is at about +631 kb.  is at about +1370 kb.   The physical distance between these is about 734 kb. According to the cM/kbp value, the centimorgan distance is $734\text{ kb} \cdot 0.31\text{ cM}/\text{kb} = 228 \text{ cM}$ . How to interpret this 228?  If I mate a haploid yeast which is DNF2 TOM1 with another which is dnf2 tom1 (lowercase indicating minor allele rather than deletion), then sporulate them, what is the chance of getting spores with DNF2 tom1 or dnf2 TOM1 genotypes?  I realize that the cM/kbp value is only a simplification and that in practice linkage is a more complex phenomenon. Nevertheless, it seems plausible that several crossover events can happen on Chr.IV since it is so big. This includes the possibility of 1, 3, 5 and more crossovers which would create a hybrid (assuming they all happen between these two loci), as well as the possibility of 2, 4, etc crossovers which would create a non-hybrid spore (at least as far as our chosen markers are concerned). The children are eager to start the novel.   or     The children are eager to begin the novel. NULL in MySQL (Performance & Storage) What exactly does null do performance and storage (space) wise in MySQL?  For example:  TINYINT: 1 Byte TINYINT w/NULL 1 byte + somehow stores NULL? Turning separate lines into a comma separated list with quoted entries I have the following data (a list of R packages parsed from a Rmarkdown file), that I want to turn into a list I can pass to R to install:  d3heatmap data.table ggplot2 htmltools htmlwidgets metricsgraphics networkD3 plotly reshape2 scales stringr   I want to turn the list into a list of the form:  'd3heatmap', 'data.table', 'ggplot2', 'htmltools', 'htmlwidgets', 'metricsgraphics', 'networkD3', 'plotly', 'reshape2', 'scales', 'stringr'   I currently have a bash pipeline that goes from the raw file to the list above:  grep 'library(' Presentation.Rmd \ | grep -v '#' \ | cut -f2 -d\( \ | tr -d ')'  \ | sort | uniq   I want to add a step on to turn the new lines into the comma separated list. I've tried adding tr '\n' '","', which fails. I've also tried a number of the following Stack Overflow answers, which also fail:      This produces library(stringr)))phics) as the result.      This produces ,% as the result.      This answer (with the -i flag removed), produces output identical to the input. How do I programmatically update the allowed values of a list field? I have created a field_time_zone field for the Article content type. I want to set the allowed values for that field to the values returned from system_time_zones(). For this, I implemented hook_form_alter() using the following code. $zones = system_time_zones(); $entityManager = \Drupal::service('entity_field.manager'); $fields = $entityManager-&gt;getFieldStorageDefinitions('node', 'local_market'); $options = options_allowed_values($fields['field_time_zone']);  if(empty($options)) { $options =  $zones; $form['field_time_zone']['widget']['#options'] = $options; }  The code adds the desired values, but the node cannot be saved, as it throws the following error.  The value you selected is not a valid choice.  How can I set the allowed values for a text (list) field? Resolve the error "An illegal choice has been detected..." How do I get the distinct/unique values in a column in Excel? If I have a column with values, and I want to find out what distinct values are in there (not how many - but the actual distinct values), how can I do that?  In SQL Server I would do something like   SELECT Distinct(MyColumn) FROM MyTable How to delay or slowly loop commands? I found 11 questions like this on gamingSE already, but none of them have proper and up-to-date answers. So I'm creating this Q&amp;A:  How do you either activate a command x seconds/minutes/hours/… in the future or every x seconds/minutes/… in a loop?  Repeating command blocks and ticking functions execute 20 times per second, redstone is  in many situations and most of the extremely fancy solutions, like falling blocks in cobwebs, have broken over time or are needlessly complicated. Splitting a string into words and punctuation I'm trying to split a string up into words and punctuation, adding the punctuation to the list produced by the split.  For instance:  &gt;&gt;&gt; c = "help, me" &gt;&gt;&gt; print c.split() ['help,', 'me']   What I really want the list to look like is:  ['help', ',', 'me']   So, I want the string split at whitespace with the punctuation split from the words.  I've tried to parse the string first and then run the split:  &gt;&gt;&gt; for character in c: ...     if character in ".,;!?": ...             outputCharacter = " %s" % character ...     else: ...             outputCharacter = character ...     separatedPunctuation += outputCharacter &gt;&gt;&gt; print separatedPunctuation help , me &gt;&gt;&gt; print separatedPunctuation.split() ['help', ',', 'me']   This produces the result I want, but is painfully slow on large files.  Is there a way to do this more efficiently? Are there tips and tricks for people with fear of flying that can makes them have a more pleasant experience when flying? I know drugs can do magic, and . I'm ideally after official advice and recommendations, but other tips and tricks would be nice as well. How should we handle downvote retaliation? Baking lots of bread - keeping a yeast starter Like many people sheltering-at-home, I'm baking . My yeast supply is running low, and I'm not sure I'll be able to get more on demand. I'd like a simple way to make sure I have yeast on hand for my next batch. Could you all recommend a method for storing a starter culture?  Specifically:   How should I store it (how much? where? I have a fridge ~4C and a wine cooler ~13C)  How often should I feed it? With what? Should I divide the culture when feeding?  How much should I use when baking? Can I treat it like dry active yeast, or does it need more/less time?   For some other context, I'm a novice at making bread (I've made it a few times, and others in my family make it more often). I see lots of advice on sourdough starters, but am interested in something that's a replacement for dry active yeast (unless sourdough starters are actually easier to maintain). I found a  that was similar, but it focused on long-term storage of yeast and the answers did not describe how to use the starter.  Your advice is appreciated. I would love to identify a sci-fi novel I read in the late 60s or 70s.  It followed a group of young space cadets through their training in the Space Academy.  The training culminated in small groups of cadets being sent through a gateway in the space station, into different worlds where they had to survive whatever conditions they met beyond the gateway, as part of their training.  One such trip went wrong and the group ended up stranded in a hostile world for days, hoping to be rescued by their trainers.  I can't remember much about the story or protagonists so this may be too vague, but I remember descriptions of a vast space station hall and these young cadets bringing whatever kit they hoped they might need - some brought breathing apparatus and full survival gear, but others came with very little as they believed they would not be sent into conditions where they could die without the right equipment.  They hadn't bargained for the power surge or whatever it was that misdirected them as they passed through the gateway!  I also remember rivalry between the cadets - I think the hero was male and quietly heading for top cadet of the year award... and I think at least one of the group died in the unknown planet before they were rescued.  Does this ring a bell with anyone?  I remember the mood and tension more than the details but it was a long time ago!  I have a 10-year old son who I think would love this kind of story.  If anyone can help you have my thanks! Core Data NSPredicate with to-Many Relationship I wonder which of the two is correct:        I have a red and a blue car.   I have a red and a blue cars.      or        Everyone has a left and a right arms.   Everyone has a left and a right arm.      My (non-native) inclination would be for option 1, as it sounds better.  On the other hand, in the following examples, the plural sounds better to me.    Everyone has left and right arms. I have old and new cars. (when I only have only one old car and one new car) The left and the right arms are...   But are they correct? By default, all browser instances use the same cookie for the same site. Is there a browser that doesn't follow this?  Or is there a Firefox plugin that can "wear" different cookies for a specific site? Selecting text in profile activity comments causes unexpected clipping This is a very minor bug I know, but in anyone's profile page, on the Activity or Responses tab, text highlighting is messed up for the Comment and All subcategories. This only seems to happen only in Chrome. I am on Version 31.0.1650.63 (Win 7). It is visibly worse on multiple lines of text.     Steps to repro:   Go to any profile on any Stack Exchange site, and click on Activity tab. Go to All or Comment subcategories. Highlight text.   As a side effect, you can even temporarily dismember the head of all those poor characters. To do this, start from any line, drag mouse left or right, drag up and then back down.    I've bumped into bugs before that turned out to be Chrome problems, so maybe this is just Chrome doing its magic.