range

Mysql: Optimizing Selecting rows from multiple ranges (using indexes?)

My table (projects): id, lft, rgt 1, 1, 6 2, 2, 3 3, 4, 5 4, 7, 10 5, 8, 9 6, 11, 12 7, 13, 14 As you may have noticed, this is hierarchical data using the nested set model http://tr.im/EO3G. Tree pretty-printed: 1 2 3 4 5 6 7 I want to select all sub projects under project 1 and 4. I can do this with: SELECT p.id FROM projects...

ruby: what does the asterisk in "p *1..10" mean

the line p *1..10 does exactly the same thing as (1..10).each { |x| puts x } which gives you the following output: $ ruby -e "p *1..10" 1 2 3 4 5 6 7 8 9 10 it's a great shortcut when working with textmate for example, but what does the asterisk do? how does that work? couldn't find anything on the net... ...

C#: Range intersection when endpoints are null (infinity)

Ok, I have these intersection methods to work with ranges, and they work well as long as the range endpoints are not null: public static bool Intersects<T>(this Range<T> first, Range<T> second, IComparer<T> comparer) { return comparer.Compare(first.Start, second.End) <= 0 && comparer.Compare(first.End, second.Start) >= 0; }...

How does the Python's range function work?

Hi,all,I am not really understand for loop in the following,can anyone give some tips?thanks in advance for i in range(5): print i then it gives 0,1,2,3,4 is that python assign 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 gives 5 only, but if i add ''print a'' it gives ...

Iterating over binary tree w/o control of stack or dynamic allocation

Is there an efficient, practical way to iterate over a binary tree given the following constraints: You do not have control of the call stack, and thus may not use recursion. All state must live inside the iterator/range object, not on the stack. No heap allocations may be used anywhere in the algorithm. The tree may be immutable, and...

C#: How to split this string

I have some strings, entered by users, that may look like this: ++7 7++ 1++7 1+7 1++7+10++15+20+30++ Those are to mean: Anything up to and including 7 Anything from 7 and up 1 and 7 and anything inbetween 1 and 7 only 1 to 7, 10 to 15, 20 and 30 and above I need to parse those strings into actual ranges. That is I need to create ...

Stuck on a loop!

I am creating an app which will be used to upload images to a specified server. I have created my GUI in Qt Designer, everything works fine I just am stuck on something that I know is simple. Cant seem to wrap my head around it. The idea is for the script to go through and see how many text fields are filed in with paths of images - fr...

Distribute range in array

I need to create one array of numbers inside one range, like: [1..5] in 10 times = [1,1,2,2,3,3,4,4,5,5] [1..5] in 5 times = [1,2,3,4,5] [1..5] in 3 times = [1,3,5] def distribute(start_value, end_value, times, is_integer) array = Array.new(times-1) min_value = [end_value,start_value].min max_value = [end_value,start_...

How to group items by date range in XSLT?

I have a bunch of data that looks a little like this: <item> <colour>Red</colour> <date_created>2009-10-10 12:01:55</date_created> <date_sold>2009-10-20 22:32:12</date_sold> </item> <item> <colour>Blue</colour> <date_created>2009-11-01 13:21:00</date_created> <date_sold>2009-11-21 12:32:12</date_sold> </item> <item> <colou...

How do I fix the 'Out of range value adjusted for column' error?

Hello, I went into phpMyAdmin and changed the value for an integer(15)field to a 10-digit number, so everything should work fine. I entered the value '4085628851' and I am receiving the following error: Warning: #1264 Out of range value adjusted for column 'phone' at row 1 It then changes the value to '2147483647'. After some g...

Is there something like for i in range(length) in PHP?

In python we have: for i in range(length) What about in PHP? ...

Where does C++ standard define the value range of float types?

As far as I know floating point values are of the form n * 2^e, with float range being n = -(2^23-1) - (2^23-1), and e = -126 - 127, double range being n = -(2^52-1) - (2^52-1), and e = -1022 - 1023 I was looking through the C++ standard, but failed to find the place where the standard specifies this, or mandates the association of t...

Calculations of ranges of numbers in PHP

Hi, and first of all, thank you for taking the time to read my question. I am trying to write a script, and I've come across an issue which I am finding hard to solve. I am working with a pair of numbers (for example, 1000 and 2000), and I have an array of pairs of numbers: $pairs = array( array(800, 1100), array(1500, 1600), ...

MDX Replace Range With Filter

While looking at the following answer I wanted to replace the range with a filter. http://stackoverflow.com/questions/1361039/mdx-concurrent-calculations-based-on-a-record-time-range/1391009#1391009 The MDX is: with member [Measures].[TotalUsed] as sum({[Date].[YQM].&[20090501]:[Date].[YQM].&[20090907]}, [Measures].[Used]) select {...

How to use regEx to return false when data not in range?

Sample data: Hello I'm 301 I need a regex to allow A-Z a-z 0-9 and space(s) only. All other characters are not allowed. If detected, return false to javascript. Based on the sample data above, it should return false because got a character which is not accetable===> ' How to write this in js. ...

VBA Columns Automatically Merge?

I am writing a program in VBA that first compiles a Range from a series of cells and then later loops through the range to collect the data in the cells. The problem is that I need the range to maintain the order in which I add the cells so that I can then collect the data in the correct order when I go back through. If the data are in...

Excel validation range limits

When Excel saves a file, it attempts to combine identical Validation settings into a single rule with multiple ranges. This creates one of three issues, depending on the file type you choose to save: When saving as a standard Excel file (Office 2000 BIFF), a maximum of 1024 non-contiguous ranges that can have the same validation setti...

How to write this meaning in a MySQL query?

How to write this meaning in a MySQL query? where ((location/'$location'<2) and (location/'$location'>=1)) ...

XSD and Date Range Validation

How would I write the XSD to validate the StartDate element and EndDate element are within the Quarter element and Year element? Thanks. <OrganizationName>Chevron</OrganizationName> <Quarter>4</Quarter> <Year>2010</Year> <Fuel> <FuelPathwayCode>CARBOBCB001</FuelPathwayCode> <PhysicalPathwayCode>PP001</PhysicalPathwayCode> <transacti...

Merge and Left Justify a Range of Rows in Excel

I have a macro to select a range of cells on the same row and then merge & left justify that selection. I would like to enhance it to allow me to select a range or block of rows and perform the same action on each row in the range. Does anyone have some sample code to do something like that? Thanks! Craig ...