range

How to create list of numbers and append its reverse to it efficiently in Ruby

Given a minimum integer and maximum integer, I want to create an array which counts from the minimum to the maximum by two, then back down (again by two, repeating the maximum number). For example, if the minimum number is 1 and the maximum is 9, I want [1, 3, 5, 7, 9, 9, 7, 5, 3, 1]. I'm trying to be as concise as possible, which is w...

Javascript: I can get the text of a selection, now how do I get the text outside the selection?

I have a bit of code that returns the text of a selection and I can assign that string to a variable, but now all I need are two variables, one for the text before the selection and one for the text after the selection. Here is the code for getting the selection: function findSelection(){ //returns the selection object. var userSele...

Range subtraction in the Excel Object Model

When using Excel Interop libraries from .NET, I can find a Range object representing the cell offset from Range X by calling something like. Range Y = X.Range[2,3]; But what should I do to perform the inverse operation, ie: I have two Range objects, A and B, and I would like to find out by how many rows/columns B is offset from A. D...

C# IndexOutOfRange issue, probably simple.

Banging my head off the wall due to this. I'm getting the error at cell[rcell] = repack[counter] even though I have 190 items in the repack array. private string csvtogrid(string input) { input = input.Replace("\r", ",").Substring(2).TrimEnd(',').Trim().Replace("\n", ",").Replace(",,,", ",").Replace(",,",","); ...

How Do I Loop Through a Date Range in Reverse?

I have a date range that I would like to be able to loop through in reverse. Give the following, how would I accomplish this, the standard Range operator doesn't seem t be working properly. >> sd = Date.parse('2010-03-01') => Mon, 01 Mar 2010 >> ed = Date.parse('2010-03-05') => Fri, 05 Mar 2010 >> (sd..ed).to_a => [Mon, 01 Mar 2010, Tu...

Python, Matplotlib, subplot: How to set the axis range?

How can I set the y axis range of the second subplot to e.g. [0,1000] ? The FFT plot of my data (a column in a text file) results in a (inf.?) spike so that the actual data is not visible. pylab.ylim([0,1000]) has no effect, unfortunately. This is the whole script: # based on http://www.swharden.com/blog/2009-01-21-signal-filtering-w...

jquery range utility for quick iteration (prototype's $R equivalent)

In prototype the cumbersome for: for (i=0; i<10; i++) { ... } can be written as $R(0, 10).each(function(i){ ... }); Is there an equivalent of range in JQuery ? ...

IIS v6.0 IP Restriction using a range of IPs

Hello all, I need to apply IP restrictions to a site in IIS v6.0 using a range of IPs. So for example i only want the below RANGE of IPs to be able to access the site: From 123.111.22.3 --> 123.111.66.234 Has anyone got any idea on how this can best be achieved? Hope this all make sense and all help is massively appreciated. Thanks...

c# Find value in a range using lambda

I'm trying to find an item in a list of values based on another value using a lambda expression using the Find method. In this example I'm expecting to get back -1000, but for the life of me, I just can't come up with the proper lamda expression. If that sounds confusing I hope the code and comments below explain it better. TIA. using S...

How Do I Find Common Dates in Two Ranges

I have 2 date ranges, start_date1..end_date1 and start_date2..end_date2, is there an easy "ruby" way to find all the dates that are in both ranges? ...

Looping differences in Ruby using Range vs. Times

I'm trying to solve a Project Euler problem using Ruby, I used 4 different looping methods, the for-loop, times, range and upto method, however the times method only produces the expected answer, while the for-loop, range and upto method does not. I'm assuming that they are somewhat the same, but I found out it's not. Can someone please ...

PHP - BUG with filter_var and FILTER_VALIDATE_FLOAT

I think there is a bug in this filter_var or maybe I'm doing something wrong: Try this: $options = array( 'options' => array( 'default' => 3, 'min_range' => 1000.0, 'max_range' => 5000.6, ) ); $VariableValue2 = 5698; $VariableValue4 = 5698.2; ...

Need to set cursor position to the end of a contentEditable div, issue with selection and range objects.

I'm forgetting about cross-browser compatibility for the moment, I just want this to work. What I'm doing is trying to modify a script (and you probably don't need to know this) located at typegreek.com The basic script is found here. Basically what it does is when you type in characters, it converts the character your are typing into gr...

html - selection range - getting the range + starting node + ending node + distance

From my previous question for selecting specific html text, I have gone through this link to understand range in html string. Actually I am confused here very much. My question is as follows. For selecting a specific text on html page. We need to follow this steps. assumed html <h4 id="entry1196"><a href="http://radar.oreilly.com...

Problem pasting HTML from selection in web browser.

I am putting together a WYSIWYG html editor using the .NET webbrowser control. I have managed to piece together the code for inserting a table at the cursor position. However I am now trying to do something a little different. What I need to do is insert a and html comment around a table row. I've managed to write the code that, fr...

Excel c# convert cell to percentage

Hello. I need to convert a cell with a double to a precentage. I used a macro in excel and it says: Range("B5").Select Selection.Style = "Percent" When I do this in c#, it doesn't work: Excel.Range procentRange = xlWorksheet.get_Range("A1","A1"); procentRange.Style = "Percent"; Anybody knows how to do this? ...

Excel c# add cells to range

Is it possible to add cells to a range? Because the cells i need, aren't next to each other. Example: I need to add the cells with x in one range x 0 x x x 0 x x x 0 x x Is this possible? and if so, how? Thanks ...

Pass a range into a custom function from within a cell

Hi I'm using VBA in Excel and need to pass in the values from two ranges into a custom function from within a cell's formula. The function looks like this: Public Function multByElement(range1 As String, range2 As String) As Variant Dim arr1() As Variant, arr2() As Variant arr1 = Range(range1).value arr2 = Range(range2).va...

Declaring an integer Range with step != 1 in Ruby

UPDATE 2: For posterity, this is how I've settled on doing it (thanks to Jorg's input): 100.step(2, -2) do |x| # my code end (Obviously there are plenty of ways to do this; but it sounds like this is the most "Ruby" way to do it; and that's exactly what I was after.) UPDATE: OK, so what I was looking for was step: (2..100).ste...

Math Looping Between Min and Max Using Mod?

i'm attempting to build a tiny (or perhaps not so tiny) formula that will contain numbers between a set min and max, but also loop these numbers so they are not clipped if they are outside of the range. so far, this is what i have. min1 = 10 max1 = 90 val1 = 92 //will make 11, which is what i want since it loops formula: min(max(min...