range

SQL: Merge Date Ranges

天涯浪子 提交于 2019-11-27 04:38:17
问题 I've a table, which describes work slices of a business working calendar: (date format is 24 hours format) PK | STARTDATE | ENDDATE __________________________________________ 1 | 2012/07/21 02:00 | 2012/07/21 04:00 2 | 2012/07/21 03:00 | 2012/07/21 10:00 3 | 2012/07/21 06:00 | 2012/07/21 17:00 4 | 2012/07/21 18:00 | 2012/07/21 19:00 Now, I like to merge the date ranges (within a given start and end date) like this: PK | STARTDATE | ENDDATE __________________________________________ 1 | 2012

Is there a way to instantly generate an array filled with a range of values in Swift?

六月ゝ 毕业季﹏ 提交于 2019-11-27 04:35:59
For example, in python I could say something along the lines of arr = range(0,30) and get an array with said elements. I suspect that something similar might be possible with a subscript in Swift, but after scouring the documentation and Apple's iBook I can't find a "batteries-included" solution for generating said array. Is this something I'd have to write the code manually for, or is there a pre-written method for it? You can create an array with a range like this: var values = Array(0...100) This give you an array of [0, ..., 100] You can create a range and map it into an array: var array =

What is the difference between `Range#include?` and `Range#cover?`?

徘徊边缘 提交于 2019-11-27 04:35:40
问题 Edit Fixed following toro2k's comment. Range#include? and Range#cover? seem to be different as seen in the source code 1, 2, and they are different in efficiency. t = Time.now 500000.times do ("a".."z").include?("g") end puts Time.now - t # => 0.504382493 t = Time.now 500000.times do ("a".."z").cover?("g") end puts Time.now - t # => 0.454867868 Looking at the source code, Range#include? seems to be more complex than Range#cover? . Why can't Range#include? be simply an alias of Range#cover?

VBA Dialog box to select range in different workbook

纵然是瞬间 提交于 2019-11-27 04:33:56
I want to allow a user to select a range that is likely to be in a different workbook. I have attempted to do this with inputbox("",type:=8) which works to select data in the workbook but refuses to allow me to select a range in a different workbook. Hence I would like a dialog box that allows me to perform this task. Since I was free, I created an example for you Create a Userform and place a ComboBox , A RefEdit Control and a Label Next paste this code in the Userform Private Sub UserForm_Initialize() Dim wb As Workbook '~~> Get the name of all the workbooks in the combobox For Each wb In

How does the Python's range function work?

一个人想着一个人 提交于 2019-11-27 04:23:24
If I write for i in range(5): print i Then it gives 0, 1, 2, 3, 4 Does that mean Python assigned 0, 1, 2, 3, 4 to i at the same time? However if I wrote: for i in range(5): a=i+1 Then I call a, it only gives 5 But if I add ''print a'' it gives 1, 2, 3, 4, 5 So my question is what is the difference here? Is i a string or a list or something else? Or maybe can anyone help me to sort out: for l in range(5): #vs,fs,rs are all m*n matrixs,got initial values in,i.e vs[0],fs[0],rs[0] are known #want use this foor loop to update them vs[l+1]=vs[l]+fs[l] fs[l+1]=((rs[l]-re[l]) rs[l+1]=rs[l]+vs[l] #then

Get all DOM block elements for selected texts

旧巷老猫 提交于 2019-11-27 04:22:59
问题 When selecting texts in HTML documents, one can start from within one DOM element to another element, possibly passing over several other elements on the way. Using DOM API, it is possible to get the range of the selection, the selected texts, and even the parent element of all those selected DOM elements (using commonAncestorContainer or parentElement() based on the used browser). However, there is no way I am aware of that can list all those containing elements of the selected texts other

Python range() and zip() object type

北城余情 提交于 2019-11-27 04:21:42
问题 I understand how functions like range() and zip() can be used in a for loop. However I expected range() to output a list - much like seq in the unix shell. If I run the following code: a=range(10) print(a) The output is range(10) , suggesting it's not a list but a different type of object. zip() has a similar behaviour when printed, outputting something like <zip object at "hexadecimal number"> So my question is what are they, what advantages are there to making them this, and how can I get

Select range in contenteditable div

大憨熊 提交于 2019-11-27 04:19:17
问题 I've got a contenteditable div and a few paragraphs in it. Here's my code: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <div id="main" contenteditable="true" style="border:solid 1px black; width:300px; height:300px"> <div>Hello world!</div> <div> <br> </div> <div>This is a paragraph</div> </div> </body> </html> Assuming, I want to make a range selection which will contain the string "world! This is" How to do that? 回答1: Once

Creating a collapsed range from a pixel position in FF/Webkit

老子叫甜甜 提交于 2019-11-27 04:17:30
Using JavaScript, I would like to create a collapsed range from a pixel position, in order to insert new nodes in the flow of the document, after the range identified by this position. This can be done with the TextRange object in Internet Exporer ( moveToPoint(x, y) method). How can I do this in FireFox & Webkit? I can get the container element from the position with document.elementFromPoint(x, y) . But when the position happens to be inside a text node, how do I get more information about the text offset required to build a range? Here is my implementation of caretRangeFromPoint for old

How to get nodes lying inside a range with javascript?

我与影子孤独终老i 提交于 2019-11-27 04:00:40
I'm trying to get all the DOM nodes that are within a range object, what's the best way to do this? var selection = window.getSelection(); //what the user has selected var range = selection.getRangeAt(0); //the first range of the selection var startNode = range.startContainer; var endNode = range.endContainer; var allNodes = /*insert magic*/; I've been been thinking of a way for the last few hours and came up with this: var getNextNode = function(node, skipChildren){ //if there are child nodes and we didn't come from a child node if (node.firstChild && !skipChildren) { return node.firstChild;