range

Changing the number of iterations in a for loop

回眸只為那壹抹淺笑 提交于 2019-11-28 11:57:29
I have code like this: loopcount = 3 for i in range(1, loopcount) somestring = '7' newcount = int(somestring) loopcount = newcount so what I want is to modify the range of the for 'inside' the loop. I wrote this code expecting the range of the for loop would change to (1,7) during the first loop, but it didn't happen. Instead, no matter what number I put in, it only runs 2 times. (I want 6 times.. in this case) I checked the value using print like this: loopcount = 3 for i in range(1, loopcount) print loopcount somestring = '7' newcount = int(somestring) loopcount = newcount print loopcount

Processing the input file based on range overlap

天大地大妈咪最大 提交于 2019-11-28 11:51:11
I have a huge input file (a representative sample of which is shown below as input ): > input CT1 CT2 CT3 1 chr1:200-400 chr1:250-450 chr1:400-800 2 chr1:800-970 chr2:200-500 chr1:700-870 3 chr2:300-700 chr2:600-1000 chr2:700-1400 I want to process it by following some rules (described below) so that I get an output like: > output CT1 CT2 CT3 chr1:200-400 1 1 0 chr1:800-970 1 0 0 chr2:300-700 1 1 0 chr1:250-450 1 1 0 chr2:200-500 1 1 0 chr2:600-1000 0 1 1 chr1:400-800 0 0 1 chr1:700-870 0 1 1 chr2:700-1400 0 1 1 Rules: Take every index (the first in this case is chr1:200-400 ), see if it

How can fill I cells A1:A5 with a color using C#?

拜拜、爱过 提交于 2019-11-28 11:41:41
问题 I have the following code: Excel.Range chartRange; chartRange = xlWorkSheet.get_Range("A3", "R3"); I want to fill this range of cells with a color. I have already tried with: System.Drawing.Color = "yellow" but it is throwing an exception that an object reference is required. How can I fix my code to fill these cells with a color? 回答1: Try this: chartRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Yellow); 回答2: The problem with your code shown above is that

Keep text selection when focus changes

旧巷老猫 提交于 2019-11-28 11:35:51
I have a normal textbox, and a lightbox with a text input. I want to keep the user's selection in the textbox, even when the user focuses on the lightbox's text input. Select text in normal textbox Toggle lightbox Focus on lightbox input At step 3., the user's text selection is discarded. How can this be prevented? See Google docs link insertion lightbox for example. Thanks :) Update Ok, so Google docs uses an iframe for the blank page section, which is how they are handling the multiple selections. Something like this (excuse the disgusting HTML): // test.html <html><body> <h1 onclick=

How to set caret/cursor position in a contenteditable div between two divs.

荒凉一梦 提交于 2019-11-28 11:28:30
Consider the following contenteditable div. <div contenteditable="true"> <div>bold text</div><div>bold text</div> </div> If I position the cursor between the two divs and start typing the text comes out bold instead of inserting a new text node between the two divs. The same happens if you hit home and try to type something in front of the first div. It becomes part of the first div. If I inspect the startContainer of the range that's returned from the selection, I get the content for one of the div's instead of an empty text node as I would expect. See this http://jsfiddle.net/9ZZpX/3/ The

Regular expression for a date range

南楼画角 提交于 2019-11-28 11:13:39
If I have a directory structure like this yyyy/dd/mm/<files> Is there a way to grep for a string in all files in a given time frame using a regex? For example, I have a time frame: 2010/12/25 - 2011/01/01, I need to grep all files in directories corresponding to dates from 25th december to jan 1st If I am doing this programmatically, is it better to iterate over the date range and grep files in each yyyy/dd/mm directory than to use a regex to do this? Or would it not make a difference? In your case, it's simple enough: \b(?:2010/12/(?:3[01]|2[5-9])|2011/01/01)\b will match a string that

the strange arguments of range

百般思念 提交于 2019-11-28 11:02:49
The range function in python3 takes three arguments two of them are optional. So the argumentlist looks like: [start], stop, [step] so this means (correct me if i'm wrong) there is a optional argument before an not-optional argument. But if i try to define a function like this i get this: >>> def foo(a = 1, b, c = 2): print(a, b, c) SyntaxError: non-default argument follows default argument is this something i can't do as a 'normal' python user, or can i somehow define such a function? Of course i could do something like def foo(a, b = None, c = 2): if not b: b = a a = 1 but for example the

Use jQuery select() to select contents of a div

僤鯓⒐⒋嵵緔 提交于 2019-11-28 10:25:15
Is it possible to use or adapt jQuery's .select() to set a selection range on the entire contents of a div? I have a div which has a series of labels, inputs, select objects and a couple of other UI elements. I have found code on a separate StackOverflow post with some code hosted on jsFiddle: http://jsfiddle.net/KcX6A/570/ Can this be adapted to select the value of inputs also? Or how would you suggest I go about this? Thanks, Conor Edit: More info I know how to get the value of inputs using jQuery, that is easy, I also know how to select he values of independent elements using .select(). In

Ruby: intersection between two ranges

好久不见. 提交于 2019-11-28 10:05:13
In ruby, given two date ranges, I want the range that represents the intersection of the two date ranges, or nil if no intersection. For example: (Date.new(2011,1,1)..Date.new(2011,1,15)) & (Date.new(2011,1,10)..Date.new(2011,2,15)) => Mon, 10 Jan 2011..Sat, 15 Jan 2011 Edit: Should have said that I want it to work for DateTime as well, so interval can be down to mins and secs: (DateTime.new(2011,1,1,22,45)..Date.new(2011,2,15)) & (Date.new(2011,1,1)..Date.new(2011,2,15)) => Sat, 01 Jan 2011 22:45:00 +0000..Tue, 15 Feb 2011 require 'date' class Range def intersection(other) return nil if (self

Detect if range is empty

血红的双手。 提交于 2019-11-28 09:38:14
I want to check if a range in Excel is empty. How do I write in VBA code: If Range("A38":"P38") is empty Kano Found a solution from the comments I got. Sub Empty() If WorksheetFunction.CountA(Range("A38:P38")) = 0 Then MsgBox "Empty" Else MsgBox "Not Empty" End If End Sub IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty; otherwise, it returns False. False is always returned if expression contains more than one variable. IsEmpty only returns meaningful information for variants. ( https://msdn.microsoft.com/en-us/library/office/gg264227.aspx ) . So you must