range

Determining if a variable is within range? (Ruby)

I need to write a loop that does something like: if i (1..10) do thing 1 elsif i (11..20) do thing 2 elsif i (21..30) do thing 3 etc... But so far have gone down the wrong paths in terms of syntax. Any help would be much appreciated. ...

PHP value won't exceed 127

Here's part of the code on my form: <br><input type="checkbox" checked="yes" name="country[]" value="1" />Asia/Pacific Region <br><input type="checkbox" checked="yes" name="country[]" value="2" />Europe <br><input type="checkbox" checked="yes" name="country[]" value="3" />Andorra ... <br><input type="checkbox" checked="yes" name="countr...

Point on non-linear range to linear and back?

Greeting, I'm trying to solve the following puzzle: I have a list of linear ranges which represent one big range. X' 100 200 300 400 500 600 700 | 900 (X) |----------|----------|----------|--------+----------| 0 | 100 (Y) ...

Serialize internal Javascript objects (like Range)

Hi. I'd like to store some internal Javascript object like Range but I haven't found a way to save it. What's the best way to save it ? I thought to serialize it but I haven't found anything on the net. Is there a library that helps doing that? jquery? ...

How to produce range with step n in bash?

The way to iterate over a range in bash is for i in {0..10}; do echo $i; done What would be the syntax for iterating over the sequence with a step? Say, I would like to get only even number in the above example. ...

Max length for a dynamic array in Delphi?

I was curious how long a dynamic array could be so I tried SetLength(dynArray, High(Int64)); That has a value of 9,223,372,036,854,775,807 and I figure that would be the largest number of indexes I could reference anyway. It gave me a: ERangeError with message 'Range check error'. So I tried: SetLength(dynArray, MaxInt); and...

Can't assign range using .End(xlDown) in Excel VBA?

Hi, I've inherited some VBA code (non-.NET, Excel 2003) I have to modify. I want to obtain a handle on a cell range but VBA doesn't like my syntax, saying 'Run-time error 424: Object required'. When running this code it highlights the line assigning streamsTotal. Private Sub totalStreams() Dim streams, streamsTotal As Range ...

How to use IPAddress and IPv4Mask to obtain IP address range?

I'm trying to accomplish the following in C#/.NET 2.0: Given an IPAddress object (say, 192.168.127.100) and another IPAddress object containing the IPv4Mask / subnet mask (say, 255.255.248.0), I should be able calculate the start and end of the IP Address range. (Yes, I'm trying to do a for-loop thru a range of addresses on a subnet.) ...

Is a bitmap index the best choice for a range query?

I'm trying to choose between these query plans for a range query: Sequential table scan Bitmap index B+ tree index Hash index My instinct is that a bitmap index would work here based on what I've read. Does that sound right? ...

Adding a second thumb to the slider control in WPF

Hello Everyone, I am trying to make a range control which is basically a slider control with an extra thumb. The only code I found for one already built is here. http://www.codeplex.com/AvalonControlsLib For the life of me I cannot get a tooltip to show up above each thumb (with the current value) while it is being moved. It will sh...

Working with date ranges in PHP/Oracle

Hi guys, I need to work out how many different instances occur on a different day, from many different ranges. Probably best to explain it with an example. 18-JAN-09 to 21-JAN-09 19-JAN09 to 20-JAN-09 20-JAN-09 to 20-JAN-09 Using the three examples above, I need it to collect this information and display something a little like... 1...

How can I expand a string like "1..15,16" into a list of numbers?

I have a Perl application that takes from command line an input as: application --fields 1-6,8 I am required to display the fields as requested by the user on command line. I thought of substituting '-' with '..' so that I can store them in array e.g. $str = "1..15,16" ; @arr2 = ( $str ) ; @arr = ( 1..15,16 ) ; print "@arr\n" ; pri...

Rhino Mocks - Mocking a factory

I have a factory that creates job objects in the form of IJob Public Interface IJobFactory Function CreateJobs(ByVal cacheTypes As CacheTypes) As IEnumerable(Of IJob) End Interface The interface IJob defines three things Public Interface IJob Sub Execute() ReadOnly Property Id() As Integer ReadOnly Property JobType() ...

Does CouchDB support multiple range queries?

How are multiple range queries implemented in CouchDB? For a single range condition, startkey and endkey combination works fine, but the same thing is not working with a multiple range condition. My View function is like this: "function(doc){ if ((doc['couchrest-type'] == 'Item') && doc['loan_name']&& doc['loan_period']&& ...

Not able to compare range.length to an integer

I am developing an app in iPhone I am using an NSRange object in my code. if (range.length == 0) { do something } When I print the the value of range.length on the console it writes 0. Which means my if condition holds valid. But it never enter inside the loop to do something. Any clue what I might be doing wrong? Thanks...

How to select values within a provided index range from a List using LINQ

I am a LINQ newbie trying to use it to acheive the following: I have a list of ints:- List intList = new List(new int[]{1,2,3,3,2,1}); Now, I want to compare the sum of the first three elements [index range 0-2] with the last three [index range 3-5] using LINQ. I tried the LINQ Select and Take extension methods as well as the SelectMa...

Copy header and range from one sheet to another

I am trying to copy a header and a set of data to a new worksheet for printing. While I can copy the data fine the column widths are lost and running autofit on it again breaks the page. The column widths were set by hand manually when the page was originally designed. Currently I have: Dim tmp As Worksheet Set tmp = Sheets.Add(after:...

Is there a better way to search over a range of values in Oracle than testing against a subquery?

given this table: x y -- - 10 a 20 b 30 c I want the best way to to map values [10,20) -> a [20,30) -> b [30,inf) -> c Right now I'm using a query like: select y from foo where x=(select max(x) from foo where x<=21); Is there a better way to do this? Is there an analytic function that might help? Here's my te...

C++ STL Range Container

I'm looking for a container that maps from a double to object pointers. However, each key is simply a range of doubles that would correspond to that object. For example, there could be a key/value pair that's <(0.0 3.0), ptr>, or <(3.5 10.0), ptr2> container[1.0] should return ptr, container[3.0] should also return ptr, and container[-...

comparing time ranges

hi! I'm trying to write an sql statement which compares time ranges. I got some excellent ideas from this question: http://stackoverflow.com/questions/143552/comparing-date-ranges the problem however is times that span midnight e.g. given the following start and end times: 19:00 - 20:00 21:00 - 21:30 23:00 - 01:00 01:00 - 03:00 I w...