length

Convert arbitrary length to a value between -1.0 a 1.0?

How can I convert a length into a value in the range -1.0 to 1.0? Example: my stage is 440px in length and accepts mouse events. I would like to click in the middle of the stage, and rather than an output of X = 220, I'd like it to be X = 0. Similarly, I'd like the real X = 0 to become X = -1.0 and the real X = 440 to become X = 1.0....

finding the length of a form select element using javascript

i've tried several different variations of finding the length of a select element and nothing's working! i can't figure out why, since several websites list this is as the correct code. here's the javascript: <script type="text/javascript"> alert(document.getElementById("opentimes").options.length); </script> and here's the form...

Response Length in PostRequestHandlerExecute

I want to find out exactly how long the Response sent to the user was, after the fact, for logging purposes. Is there any way to do this from an HttpModule in asp.net (in the PostRequestHandlerExecute event). ...

Difference between MATLAB's numel and length functions

I know that length(x) returns max(size(x)) and numel(x) returns the total number of elements of x, but which is better for a 1 by n array? Does it matter, or are they interchangeable in this case? EDIT: Just for kicks: Looks like they're the same performance-wise until you get to 100k elements. ...

How can I truncate data to fit into a field using SQL*Loader? (ORA-12899)

Using Oracle SQL*Loader, I am trying to load a column that was a variable length string (lob) in another database into a varchar2(4000) column in Oracle. We have strings much longer than 4000 characters, but everyone has agreed that these strings can and should be truncated in the migration (we've looked at the data that goes beyond 400...

Determine the content length of an Intent.STREAM_EXTRA (Android)

Suppose an app gets a content stream by being called with the android.intent.action.SEND filter. Also suppose the Uri and the stream is received like this: Uri contentUri = (Uri) extras.get(Intent.EXTRA_STREAM); InputStream in = getContentResolver().openInputStream(contentUri); Now, how can I determine the total length of the content ...

Improving pure Python prime sieve by recurrence formula

I am trying to optimize further the champion solution in prime number thread by taking out the complex formula for sub-list length. len() of the same subsequence is too slow as len is expensive and generating the subsequence is expensive. This looks to slightly speed up the function but I could not yet take away the division, though I do...

Getting a line count woes UITextView

Hi, am being driven crazy trying to obtain how many lines a string will require as entered in a UITextView. The code below for some reason does not split the string supplied over lines and returns a stringSize = (o, 32) WTF? I enter a crazy long string that is way past 320 but still no expected result? NSString *t = @"in my app this s...

Know the length of an input in Javascript

Hello, how to know the length of an input in Javascript alert("Size: "+document.getElementById('champ').length) not work undefined ...

SQL Compact 3.5 Ed, max length of SQL statement

Hi All, I'm developing a C++ application using OLEDB to communicate to SQL Server Compact Ed. 3.5. One feature of my application is a filter that helps the user narrow down data. Unfortunately, the selection criteria for the filter may become quite complex as the user may select data associated with various countries, keywords, categor...

Stream.Length throws NotSupportedException

I am getting a error when attempting stream.Length on a Stream object sent into my WCF method. Unhandled Exception! Error ID: 0 Error Code: Unknown Is Warning: False Type: System.NotSupportedException Stack: at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.get_Length() How do you get the length of the stream...

How to determine the length of an array at compile time?

Are there macros or builtins that can return the length of arrays at compile time in GCC? For example: int array[10]; For which: sizeof(array) == 40 ???(array) == 10 Update0 I might just point out that doing this in C++ is trivial. One can build a template that returns the number inside []. I was certain that I'd once found a len...

jQuery strange behaviour on click() from a click()

Hi, I am facing a strange behaviour in jQuery 1.4 with the click event. The idea is to click on a drop-down list (change()), which then invert twice a collection of checkboxes by using the click() function of them. If I have to do so it is because the click on checkboxes update other fields, so I thought instead of inverting the checkbox...

How to reduce the length of very long strings?

I have some text which occasionally contains very long strings of characters, which is breaking my CSS. This is an example: http://iapps.smartphonesoft.com/php/software_details.php?id=358281487 whereas this one is fine http://iapps.smartphonesoft.com/php/software_details.php?id=380894729 Is it possible to strip the very long line...

using length in jquery in IExplorer 8 doesnt work to check if div exists

I have this code, window.onload = function(){ if($('div.colorPicker').length){ $("div.colorPicker").click(function(){ if($('.field_sku').length){ code = $(this).children('.tmpSKU').html(); if(!code || code==null){ code = "Item Code not set yet"; ...

Variable length encoding of an integer

Whats the best way of doing variable length encoding of an unsigned integer value in C# ? "The actual intent is to append a variable length encoded integer (bytes) to a file header." For ex: "Content-Length" - Http Header public string somefunction(int data) { //returns the binary format of the data byte as a string string data_...

Index for a VARCHAR field with a 384 length in a MySQL database

I have a varchar(384) to store emails in a MyISAM table and I want check when the email exists but the index length limit is 333 bytes (because I'm using utf8 (1000 bytes/3 bytes)). Then what's the best way to search if a specified email exists, using a FULLTEXT index or creating another field with the email md5-hash in a BINARY(16) (wi...

Repeat array to a certain length?

I'm having an array for example with 4 elements array("a", "b", "c", d"); what is the fastest way to repeat this array to create a new array with a certain length, e.g 71 elements? ...

Is there a way to find the second longest word in a sentence in Python ?

Hello everyone, I got stuck on this idea: how do I get the second longest word in a sentence ? I'm going to use it for an exit route in my code where the longest word might fail a test. Any ideas ? Thanks in advance. ...

How to validate length of received byte array, which is not null terminated?

Hi all, I have a C\C++ code that receives a structure over the network, from this form: struct DataStruct { int DataLen; BYTE* Data; } The code I have runs over Data in a loop of DataLen times and processes the data. ...The problem: After the code came to security experts for penetration tests, they prepared a fake application whic...