Having a sorted list and some random value, I would like to find in which range the value is.
List goes like this: [0, 5, 10, 15, 20]
And value is, say 8.
The standard way would be to either go from start until we hit value that is bigger than ours (like in the example below), or to perform binary search.
grid = [0, 5, 10, 15, 20]
va...
I'm trying to construct an algorithm that validates that a double value is a member of a range defined with min, max and step values. The problem is checking that the value obeys the step rule. For integers this can be easily done:
boolean validate(int value, int min, int step, int max){
return value >= min &&
value ...
Hi, I know I can do this easily by converting the IP addresses to decimal notation first using PHP built in functions like up2long and long2ip. I just want to be able to do the same using the standard IP address notation as an exercise.
The problem I am thinking goes like this: Given an starting IP address, say 192.168.1.100, and an end...
I'm looking for a way to set a selection in a textarea in Internet Explorer. In other browsers, this works just fine:
textarea.selectionStart = start;
textarea.selectionEnd = end;
In IE, I assume I have to use createRange and adjust the selection somehow, but I cannot figure out how.
Extra bonus points for a link to a proper document...
Hello Everyone!
This is my first post on stack, so please bear with me.
I'm a C# developer who has just recently decided to expand my knowledge of the tools available to me. The first tool I've decided to learn is Vi/Vim. Everything has been going well so far, but there are a couple of questions I can't seem to find the answer to:
1...
I'm running the following code and I'm attempting to print the first element in the @rainbow array through the fifth-from-last element in the @rainbow array. This code works for any positive indices within the bounds of the array, but not for negative ones:
@rainbow = ("a".."z");
@slice = @rainbow[1..-5];
print "@slice\n";
...
Hi,
I'm using the jQuery Validator Plugin. My code is like this:
<input name="username" type="text" class="newtextbox required" rangelength="(4,16)">
The error message is "Please enter a value between NaN and 4 characters long". The actual error message that has to be is "Please enter a value between 4 and 16 characters long".
I thi...
hi ,
I am developing a ASP.NET by using c#.net and have many WMV files and have to watch the range of the file which I gave.The size of files are too big also the users shouldn't download the all of the file , should download between the range which I give . Is there anybody to help me ?
...
I tried to iterate backwards with ruby using a Range and each. This way:
(4..0).each do |i|
puts i
end
==> 4..0
Iteration through 0..4 writes the numbers. On the other Range r = 4..0 seems to be ok, r.first == 4, r.last == 0. Seems to be strange to me that the construct above does not produce the expected result. What is the a reaso...
I am trying to dynamically get the range of cells in Excel using VS 2005 vb.net. This works oRange = oSheet.Range(oSheet.Cells("A1"), ("U281")).Select, but "U281" will not always be the last cell in the range. So how would I dynamically get the last cell with data in it with the same format as U281.
Thanks,
Lora
...
Hi,
I have a contentEditable iframe with line numbers and text. The line numbers are contained in a div and all text is in a <pre>-element.
It looks like this:
<body>
<div id="line_numbers">
<div>1</div><div>2</div><div>3</div>
</div>
<pre>
Text
</pre>
</body>
Now, when someone presses Ctrl+A everything is selecte...
I've been working with selection/range objects, and because to the incredible amount of inconsistencies between browsers for specific selection/range stuff (even more than the DOM) I was wondering if there was a framework that would help me get through them.
...
What is the scalar ".." operator typical usage? Is it only selecting blocks of text?
Interesting example by myself:
sub get_next {
print scalar($$..!$$), "\n";
}
get_next for 1 .. 5; # prints numbers from 1 to 5
get_next for 1 .. 5; # prints numbers from 6 to 10
...
Using comtypes to drive Python, it seems some magic is happening behind the scenes that is not converting tuples and lists to VARIANT types:
# RANGE(“C14:D21”) has values
# Setting the Value on the Range with a Variant should work, but
# list or tuple is not getting converted properly it seems
>>>from comtypes.client import CreateObjec...
I'm currently dealing with a lot of possibly indefinite date spans, ie.
StartDate EndDate
--------- ---------
01JAN1921 31DEC2009
10OCT1955 null
...
where the other end of the interval might be unknown or not defined. I've been working on little functions for detecting overlap, whether an interval is a subinterval of a...
I'd like to identify groups of continuous numbers in a list, so that:
myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20])
returns:
[(2,5), (12,17), 20]
And was wondering what the best way to do this was (particularly if there's something inbuilt into Python).
Edit: Note I originally forgot to mention that individual numbers should be...
I'm trying to build a query that will search for recent entries based on column 'last_login_at'. This is a datetime field with time zone (i.e. Time.zone.now)
When I execute
User.find(:all, :conditions => ["last_login_at < ?", 24.hours.ago])
I get nothing.
Alternatively I can define today as Time.zone.today and yesterday as Time.zone...
Is there any possibility to overwrite the dots in a ruby range?. My aim is, to manipulate the given objects before the range is created.
I thought of something like this
require 'rubygems'
require 'active_support'
#actual i have to call explicitly .to_date
Date.today.to_date..1.month.since.to_date
#this should give me a range with Da...
Hi There
The question I have is a quick one to do with the VBA object model. I have created a defined name/range on a worksheet called "bob", pointing to a single cell. I have a bunch of other name/ranges set up on this worksheet, which I didn't create. All the other ones work perfectly. The new one created by me does not work perfectly...
Hello,
Does anyone know if Python has an in-built function to work to print out even values. Like range() for example.
Thanks
...