range

window.getSelection().getRangeAt() not working properly

元气小坏坏 提交于 2019-12-11 04:48:16
问题 I am trying to get the text selection within a an html element and then insert span tags around it. So far, I am having problems with the correct indices. If I highlight text inside a <p> block, the index goes to 0 after a <br> tag. I want to be able to slice() the text out and then recombine it with span tags after highlighting the text as well as grabbing the selected text and sending it to server via Ajax. Here is some sample HTML and code: <html><body><p>This is some sample text.<br

Insert text before a list using Word Interop

纵然是瞬间 提交于 2019-12-11 04:18:45
问题 I'm trying to insert text before a list. I have the Microsoft.Office.Interop.Word.Range of the list, and get the previous Range before the list. I then try to add my paragraph text to the previous range, however, the paragraph is added as the first item in the list instead of before the list. // rangeObj is the Range object for the list var previousRange = rangeObj.Previous(MSWord.WdUnits.wdCharacter, 1); Paragraph paragraph; if (previousRange == null) { var rangeCopy = rangeObj.Duplicate;

How to get rows of a dataframe that contain values between two other values?

大兔子大兔子 提交于 2019-12-11 04:04:02
问题 So I want to find values in a column of a data.frame, which are in range of defined values: example [1] 6 2 4 3 5 1 pos [1] 1 3 2 I now want to get the values of example for which BOTH of the following statements are TRUE, so that I got only values that lie between pos - 1 and pos +1 : if(example < pos - 1) if(example > pos + 1) And now the real values for my task are within a data.frame. How do I extract the complete rows, which contain these values and build a new pos data.frame . The

how to make union range faster for large loops

瘦欲@ 提交于 2019-12-11 03:42:05
问题 I have a sub that becomes very slow after about 5000 iterations in a loop. It's quick otherwise. Windows 8.1 Pro 64 bit Excel 2013 (15.0.4701.1001) MSO (15.0.4701.1000) 64-bit Sub UnionSlow() Dim ColArray() As Variant Dim NumLastRow, NumRow, Cnt As Long Dim CurCell As String Dim rngPRC As Range 'Set an arbitrary row so range is not empty Set rngPRC = Rows(1) 'Get the total number of rows in the sheet TotalRows = Rows(Rows.Count).End(xlUp).Row 'Load the first column into an array (v quick)

C - Find all amicable numbers between limits

半城伤御伤魂 提交于 2019-12-11 02:58:15
问题 First a definition: An amicable pair of numbers consists of two different integers where the sum of the divisors of the first integer is equal to the second integer, and the sum of the divisors of the second integer is equal to the first integer. A perfect number is a number that equals the sum of its own divisors. What I want to do is make a program that asks the user for a lower limit, and an upper limit and then presents him/her with all the amicable pairs (one per line) between those two

Excel/VBA - Loop through range

被刻印的时光 ゝ 提交于 2019-12-11 02:43:01
问题 I have the following code: TotalCount = Application.Sum(Worksheets("Data").Range("B14:G14")) Sheets("Data").Range("H14") = TotalCount TotalCount = Application.Sum(Worksheets("Data").Range("B13:G13")) Sheets("Data").Range("H13") = TotalCount TotalCount = Application.Sum(Worksheets("Data").Range("B12:G12")) Sheets("Data").Range("H12") = TotalCount TotalCount = Application.Sum(Worksheets("Data").Range("B11:G11")) Sheets("Data").Range("H11") = TotalCount As you can see... it's not very efficient.

Comparative genomics: how to compare ranges of sequences

ぃ、小莉子 提交于 2019-12-11 02:16:31
问题 I did a genome comparison between two bacteria with VISTA. This tools gave me the regions of DNA sequence that are common between two bacteria, but I am most interested in knowing which CDS's are present in one bacteria that is lacking in the second one By using R, I managed to use the VISTA information to generate a data.frame which includes the region (range) of bases that are exclusive to the FIRST bacteria. These regions must presumibly containing genes (CDS's) that are lacking in the

SQL count date range

给你一囗甜甜゛ 提交于 2019-12-11 02:07:33
问题 I'm trying to query my SQL database to get the number of orders made by each client within a certain date range. I have a list of orders as follows CustomerName ClientID DateOrdered Customer No.2 10 2011-11-25 Customer No.3 11 2011-10-15 Customer No.3 11 2011-11-25 and I want to be able to find out how many orders have been made by a specific client for example between 2011-11-1 and 2011-11-30, this should result in : CustomerName ClientID Number Customer No.3 11 1 Customer No.2 10 1 So far I

Check if string in list, depending on last two characters

*爱你&永不变心* 提交于 2019-12-11 01:18:58
问题 Set-up I am using Scrapy to scrape housing ads. Per ad I retrieve a postal code which consists of four numbers followed by 2 letters, e.g. 1053ZM . I have a excel sheet linking districts to postal codes in the following way, district postcode_min postcode_max A 1011AB 1011BD A 1011BG 1011CE A 1011CH 1011CZ So, the second row states that postcodes ranging from 1011AB, 1011AC,..., 1011AZ, 1011BA,...,1011BD belong to district A . The actual list contains 1214 rows. Problem I'd like to match each

Replace last character while user typing in contenteditable div

末鹿安然 提交于 2019-12-11 00:42:33
问题 I found, somewhere in SE, a code to insert text in contenteditable by Tim Down. The code looks like the following and is working perfect. But I want to add a condition that is based on my requirement and wanted to modify the code somehow but failed to do it after so many trials. function insertTextAtCursor(value, stepback) { var sel, range, textNode; if (window.getSelection) { sel = window.getSelection(); if (sel.getRangeAt && sel.rangeCount) { range = sel.getRangeAt(0); textNode = document