range

Cross Browser Selection Range Library?

时光怂恿深爱的人放手 提交于 2019-11-26 16:26:06
问题 Does anyone know of any cross-browser user selection range libraries written in javascript? I found a few jQuery plugins, (which quite frankly are too limiting and very buggy). I would just like to know what you have found out there. Don't send me googling this again, (I've spent days working on all this). Hopefully, this can be where future programmers can find the answer. 回答1: I've developed a cross-browser Range and selection library called Rangy. Its core is not dissimilar in concept to

Does range() really create lists?

坚强是说给别人听的谎言 提交于 2019-11-26 16:23:37
问题 Both my professor and this guy claim that range creates a list of values. "Note: The range function simply returns a list containing the numbers from x to y-1. For example, range(5, 10) returns the list [5, 6, 7, 8, 9]." I believe this is to be inaccurate because: type(range(5, 10)) <class 'range'> Furthermore, the only apparent way to access the integers created by range is to iterate through them, which leads me to believe that labeling range as a lists is incorrect. 回答1: In Python 2.x,

replace innerHTML in contenteditable div

陌路散爱 提交于 2019-11-26 16:21:29
i need to implement highlight for numbers( in future im add more complex rules ) in the contenteditable div. The problem is When im insert new content with javascript replace, DOM changes and contenteditable div lost focus. What i need is keep focus on div with caret on the current position, so users can just type without any issues and my function simple highlighting numbers. Googling around i decide that Rangy library is the best solution. I have following code: function formatText() { var savedSel = rangy.saveSelection(); el = document.getElementById('pad'); el.innerHTML = el.innerHTML

php switch case statement to handle ranges

拟墨画扇 提交于 2019-11-26 16:12:33
问题 I'm parsing some text and calculating the weight based on some rules. All the characters have the same weight. This would make the switch statement really long can I use ranges in the case statement. I saw one of the answers advocating associative arrays. $weights = array( [a-z][A-Z] => 10, [0-9] => 100, ['+','-','/','*'] => 250 ); //there are more rules which have been left out for the sake of clarity and brevity $total_weight = 0; foreach ($text as $character) { $total_weight += $weight[

Generate colors between red and green for an input range [duplicate]

只谈情不闲聊 提交于 2019-11-26 15:48:20
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Color coding based on number I want for a user to be able to select from a range from 1-100, where as the numbers become less than 50, the color of the area becomes darker green, and as the color becomes closer to 100, the color becomes more red. I am trying to make it so that as the range in more towards the center, the color should be close to white (where 50 = full white). I tried the answer from here:

Why was pair range access removed from C++11?

放肆的年华 提交于 2019-11-26 15:31:00
问题 I just discovered that at one point, the C++11 draft had std::begin / std::end overloads for std::pair that allowed treating a pair of iterators as a range suitable for use in a range-based for loop (N3126, section 20.3.5.5), but this has since been removed. Does anyone know why it was removed? I find the removal very unfortunate, because it seems there is no other way to treat a pair of iterators as a range. Indeed: The lookup rules for begin/end in a range-based for loop say that begin/end

Convert an entire range to uppercase without looping through all the cells

依然范特西╮ 提交于 2019-11-26 15:29:53
right now I'm using the following code to convert a list of ticker symbols from lowercase to upper case letters: Dim Tickers As String Dim n As Integer For n = 2 To Last Tickers = UCase(W.Cells(n, 1).Value) W.Cells(n, 1).Value = Tickers Next n Is there a method I can use to convert the whole range in one line? something like: Range("A1:A20").convertouppercasesomehow Siddharth Rout Is there a method I can use to convert the whole range in one line? Yes you can convert without looping. Try this Sub Sample() [A1:A20] = [INDEX(UPPER(A1:A20),)] End Sub Alternatively, using a variable range, try

`xrange(2**100)` -> OverflowError: long int too large to convert to int

安稳与你 提交于 2019-11-26 15:28:29
xrange function doesn't work for large integers: >>> N = 10**100 >>> xrange(N) Traceback (most recent call last): ... OverflowError: long int too large to convert to int >>> xrange(N, N+10) Traceback (most recent call last): ... OverflowError: long int too large to convert to int Python 3.x: >>> N = 10**100 >>> r = range(N) >>> r = range(N, N+10) >>> len(r) 10 Is there a backport of py3k builtin range() function for Python 2.x? Edit I'm looking for a complete implementation of "lazy" range() , not just a partial implementation of some of its functionality. Okay, here's a go at a fuller

How to generate a random number in a range (10…20) using Swift [duplicate]

别来无恙 提交于 2019-11-26 14:46:49
This question already has an answer here: How does one generate a random number in Apple's Swift language? 25 answers I'm able to pick a random number for my items in my game but is it possible to pick a random number between 2 numbers? so instead of let number = (arc4random_uniform(100)) I would like something like this: let number = (arc4random_uniform(10...20)) or something like that? Now if I get a weapon drop it can be everything in my list. This way I could make it so that only the first few would have a drop for a specific monster or at higher level they would drop better weapons and

Python 3 turn range to a list

帅比萌擦擦* 提交于 2019-11-26 14:30:52
I'm trying to make a list with numbers 1-1000 in it. Obviously this would be annoying to write/read, so I'm attempting to make a list with a range in it. In Python 2 it seems that: some_list = range(1,1000) would have worked, but in Python 3 the range is similar to the xrange of Python 2? Can anyone provide some insight into this? You can just construct a list from the range object: my_list = list(range(1, 1001)) This is how you do it with generators in python2.x as well. Typically speaking, you probably don't need a list though since you can come by the value of my_list[i] more efficiently (