range

Clear a selection in Firefox

霸气de小男生 提交于 2019-11-26 18:31:36
问题 I have this function function smth() { var container = null; var newContainer = null; if (window.getSelection) { // all browsers, except IE before version 9 alert("first if"); var selectionRange = window.getSelection(); if (selectionRange.rangeCount > 0) { var range = selectionRange.getRangeAt(0); container = range.commonAncestorContainer; newContainer = container; } } else { if (document.selection) { // Internet Explorer alert("second if"); var textRange = document.selection.createRange();

Range-for-loops and std::vector<bool>

无人久伴 提交于 2019-11-26 18:23:07
问题 Why does this code work std::vector<int> intVector(10); for(auto& i : intVector) std::cout << i; And this doesn't? std::vector<bool> boolVector(10); for(auto& i : boolVector) std::cout << i; In the latter case, I get an error error: invalid initialization of non-const reference of type ‘std::_Bit_reference&’ from an rvalue of type ‘std::_Bit_iterator::reference {aka std::_Bit_reference}’ for(auto& i : boolVector) 回答1: Because std::vector<bool> is not a container ! std::vector<T> 's iterators

Javascript Array: get 'range' of items

喜你入骨 提交于 2019-11-26 18:19:43
问题 Is there an equivalent for ruby's array[n..m] in Javascript ? For example: >> a = ['a','b','c','d','e','f','g'] >> a[0..2] => ['a','b','c'] Thanks 回答1: Use the array.slice(begin [, end]) function. var a = ['a','b','c','d','e','f','g']; var sliced = a.slice(0, 3); //will contain ['a', 'b', 'c'] The last index is non-inclusive; to mimic ruby's behavior you have to increment the end value. So I guess slice behaves more like a[m...n] in ruby. 回答2: a.slice(0, 3) Would be the equivalent of your

PHP range() from A to ZZ?

最后都变了- 提交于 2019-11-26 18:15:35
问题 Is it possible to get a range with PHP from A to ZZ*? a b c ... aa ... zx zy zz For me this didn't work: range('A', 'ZZ'); It's for PHPExcel, when it gives BE as highest field i'd run through all colums. In this case i only get A, B: range ('A', 'BE') 回答1: Just Try this- (tested working fine) function createColumnsArray($end_column, $first_letters = '') { $columns = array(); $length = strlen($end_column); $letters = range('A', 'Z'); // Iterate over 26 letters. foreach ($letters as $letter) {

SQL query, select nearest places by a given coordinates [duplicate]

旧巷老猫 提交于 2019-11-26 17:35:30
问题 This question already has an answer here: Fastest Way to Find Distance Between Two Lat/Long Points 15 answers I have $latitude = 29.6815400 and $longitude = 64.3647100 , now in MySQL I would like to take the 15 nearest places to these coordinates and I'm planning to do this query: SELECT * FROM places WHERE latitude BETWEEN($latitude - 1, $latitude + 1) AND longitude BETWEEN($longitude - 1, $logintude + 1) LIMIT 15; Do you think it's correct or do you suggest something else? How to do the

python time range validator

我的未来我决定 提交于 2019-11-26 17:25:10
问题 I have 2 parameters in DB: start and stop. value for them can be eg 07:00-23:00 or 23:00-07:00 (start after 07, stop after 23 or start after 23, stop after 07) In that time, a status must be 0 or 1, let's say it's LED How to create unified logic controller that won't mess up after/before midnight? My poor implementation (wont work) is below. Actually, I've tried many-many variations and still ended up where I currently am.. if curtime >= vv_time_trig1 and curtime <= vv_time_trig2: logger.info

Limit the value of a MySQL datatype to a specific range (preferably not ENUM)

◇◆丶佛笑我妖孽 提交于 2019-11-26 17:15:59
问题 I want to limit the datatype value that can be stored within a field to a specific range of integer values: [0,10]. On user input within a PHP script I validate and sanitise the data to make sure it is within the range 0 to 10. However, is there a way to ensure this remains true within the votes table itself via some sort of datatype or constraint? At the moment I store the int value within an UNSIGNED TINYINT which of course has the range of 0-255. I am aware of ENUM as an option. However, I

Revert a range of commits in git

拥有回忆 提交于 2019-11-26 17:11:56
How can I revert a range of commits in git? From looking at the gitrevisions documentation, I cannot see how to specify the range I need. For example: A -> B -> C -> D -> E -> HEAD I want to do the equivalent of: git revert B-D where the result would be: A -> B -> C -> D -> E -> F -> HEAD where F contains the reverse of B-D inclusive. What version of Git are you using? Reverting multiple commits in only supported in Git1.7.2+: see " Rollback to an old commit using revert multiple times. " for more details. The current git revert man page is only for the current Git version (1.7.4+). As the OP

Java the range of int?

家住魔仙堡 提交于 2019-11-26 17:08:57
问题 I understand that int range in Java should be -2^31 to 2^31-1. But when I run this code snippet with 20: public class Factorial { public int factorial(int n) { int fac=1; for (int i=1; i<=n; i++) { fac *= i; System.out.println("Factorial of " + i + " is: " + fac); } return fac; } } The output: Factorial of 1 is: 1 Factorial of 2 is: 2 Factorial of 3 is: 6 Factorial of 4 is: 24 Factorial of 5 is: 120 Factorial of 6 is: 720 Factorial of 7 is: 5040 Factorial of 8 is: 40320 Factorial of 9 is:

Javascript Highlight Selected Range Button

◇◆丶佛笑我妖孽 提交于 2019-11-26 16:47:43
问题 I'm attempting to create a study tool for a page that allows a user to select any text on the page and click a button. This click then formats the selected text with a yellow background. I can make this work inside of a single tag, but if the range of selection is across multiple tags (for instance, the first LI in an unordered list along with half of the second), I have difficulty applying the style. I can't just wrap the selection with a span here unfortunately. Basically, I want the