length

If element exists, do X (jQuery)

I currently do this to check if an elements exists: if ($(".element1").length > 0 || $(".element2").length > 0 { ...stuff... } Is there a better way to rewrite the same? I mean, ".length" the same as ".length > 0" ? Thanks ...

length of array in c++

I read to get the length of array in C++, you do this: int arr[17]; int arrSize = sizeof(arr) / sizeof(int); I tried to do the same for a string: where I have string * arr; arr = new (nothrow) string [213561]; And then I do arr[k] = "stuff"; where I loop through each index and put "stuff" in it. Now I want the size of the array...

What's the best encryption algorithm for the iPhone in terms of speed and security?

The iPhone supports the following encryption algorithms enum { kCCAlgorithmAES128 = 0, kCCAlgorithmDES, kCCAlgorithm3DES, kCCAlgorithmCAST, kCCAlgorithmRC4, kCCAlgorithmRC2 }; I want to use only symmetric algorithm since asymmetric encryptions requires more computation overhea...

get length of data sent over network to TCPlistener/networkstream vb.net

It seems the most obvious thing, but I just can't work out how to get the length of bytes sent over a network using a TCPClient and TCPListener? This is my code so far: 'Must listen on correct port- must be same as port client wants to connect on. Const portNumber As Integer = 9999 Dim tcpListener As New TcpListener(IPAddress...

Python find list lengths in a sublist

I am trying to find out how to get the length of every list that is held within a particular list. For example: a = [] a.append([]) a[0].append([1,2,3,4,5]) a[0].append([1,2,3,4]) a[0].append([1,2,3]) I'd like to run a command like: len(a[0][:]) which would output the answer I want which is a list of the lengths [5,4,3]. That com...

System.Array GetLength and Length

How do you use the Array.GetLength function in C#? What is the difference between the Length property and the GetLength function? ...

Determining the pixel length of a string in Cocoa (MAC OSX)

I need to figure out the pixel length of an NSString in Cocoa on OSX and I have found a couple of links that describe how to do this using the IPhone sdk but I didn't see anything about how to do this when not targeting the IPhone. Can anyone link me to some docs that would be relevant. I did find anything in the NSString docs. ...

How to calculate the length of a string in C efficiently?

How to calculate the length of a string in C efficiently (in time)? Right now I'm doing: int calculate_length(char *string) { int length = 0; while (string[length] != '\0') { length++; } return length; } But it's very slow compared to strlen() for example, is there any other way to do it? Thanks. EDIT: I'm w...

Python, len, and size of ints

So, cPython (2.4) has some interesting behaviour when the length of something gets near to 1<<32 (the size of an int). r = xrange(1<<30) assert len(r) == 1<<30 is fine, but: r = xrange(1<<32) assert len(r) == 1<<32 ValueError: xrange object size cannot be reported`__len__() should return 0 <= outcome Alex's wowrange has this beha...

toString() of int e = 0000007 omits all zeros. How can I preserve them?

I'm trying to write a program in C# that takes in an int x and decides if it has exactly 7 digits. Right now I'm using x.toString().Length == 7 to check, but I noticed that if the number starts with 0, it automatically gets omitted and I get an incorrect answer (ie the program thinks the input length is less than 7) Is there a way to fi...

ASP Question - How to count # of characters?

Today is the very first day I've ever even seen aspx, so, please bear with me... Basically, I want to determine if a string is empty. If it is empty, then I don't want anything to output, if it's not, then I want to output the string itself. <%= o_handler.renderDDesc()%> //This is the string itself... If this is empty, then I want ...

Ignoring case, punctuation, and whitespace in Strings

What is the most efficient way of ignoring case, punctuation, and whitespace in strings? These strings should be divided into words instead of characters should ignore the aforementioned details on comparisons, and slices of these word-strings should be as efficient as possible with speed in mind. I was going to use case and punctuation...

Length of an integer in python

In python, is there a command similar to len() which works on integers? Thanks ...

Determine length of audio file using DirectShow

Hi guys, I am just starting with DirectShow.NET, and I am trying to get the length (in seconds) of an audio file. The audio may be .mp3, .wav, .aac, or .m4a. Can I get this information using DirectShow, or do I need some other APIs? ...

PHP: Simple regular expressions to match length?

I'm creating a registration system that needs to check the name/pass etc. with REGEX (and prefer to), what I've got so far is: //Check so numbers aren't first, such as 00foobar preg_match('/^(?!\d)[a-z0-9]+$/iD',$usrname); //Just simple check preg_match('/^[a-zA-Z0-9]+$/',$psword); But I have to do stupid things in IF statements like:...

Can an Android Toast be longer than "Toast.LENGTH_LONG"?

When using setDuration for a Toast is it possible to set a custom length or at least something longer than Toast.LENGTH_LONG? ...

facebook connect uid mysql storage problem

I'm doing a facebook connect integration. I use the facebook php library to get the uid,like $facebook = new Facebook($api_key, $secret); $fb_user = $facebook->require_login(); $fbuser is a 16-character long bigint, such as 1000002949493949 However, when I insert this value into mysql it only inserts 2949493949 So later when I try to...

ASP.NET MVC - Model Validation regarding its dataType Length

Hello there, I'm using ASP.NET MVC 1 on a project where I would like to validate my form submission with the ModelBinding helpers, actually I am validating it with ModelState.IsValid but it doesn't seem to consider the dataType length when validating it. For example: I have a field nvarchar(70) called Name , but when in my form I submi...

Received UDP packet length

How to get the length of received UDP packet? Using wireshark I could see the correct length of datagram. How can I print this value in my simple udp server program? I am receiving binary data (Non printable ascii characters as a data) So I can not use strlen(buf) which throws incorrect length. if (ret=recvfrom(s, buf, BUFLEN, 0, ...

How to retrieve all email messages over *** characters long?

I always had trouble updating blogs i wrote, but it occured to me that whenever people ask me something I can give really long replies that could easily become articles. However there`s not a feature in GMail or any other mail app for that matter, that enables me to search by message length. Will I have to write a script to retrieve a...