string

How to determine size of string, and compress it

I'm currently developing an application in C# that uses Amazon SQS The size limit for a message is 8kb. I have a method that is something like: public void QueueMessage(string message) Within this method, I'd like to first of all, compress the message (most messages are passed in as json, so are already fairly small) If the compress...

Text-correlation in MySQL

Hi guys, I have three coloumns in my table, all containing text. I want to calculate a correlation between coloumn A and B, and A and C. How can I do this, and can I do it within MySQL? For example, I can have the values ('Hello world', 'ello world', 'Good bye'), ('Hello world', 'H e l l o', 'Bye world') Cheers Nik ...

Syntax error, need help with this 'string'

I have this piece of code here below: $fq.=" + (fritidsboende_uth_from:[$fritids_uth_from TO *] AND fritidsboende_uth_to:[* TO $fritids_uth_to]) OR (fritidsboende_uth_from:'1972-01-01T01:01:00Z' AND fritidsboende_uth_to:'2019-01-01T01:01:00Z')"; I have noticed my app doesn't get anything behind the colon, in this part of the code: ...

String formatting help

I have this: 2010-04-08T01:01:00Z I want to remove the 'T' and everything behind it as well. Also I would like to rewrite the date into this format: 08-04-2010 How can I do this the easiest way? Thanks ...

Objective C: Create arrays from first array based on value

I have an array of strings that are comma separated such as: Steve Jobs,12,CA Fake Name,21,CA Test Name,22,CA Bill Gates,44,WA Bill Nye,21,OR I have those values in an NSScanner object so that I can loop through the values and get each comma seperated value using objectAtIndex. So, what I would like to do, is group the array items in...

C++ - repeatedly using istringstream

I have a code for reading files with float numbers on line stored like this: "3.34|2.3409|1.0001|...|1.1|". I would like to read them using istringstream, but it doesn't work as I would expect: string row; string strNum; istringstream separate; // textovy stream pro konverzi while ( getline(file,row) ) { separate.str(r...

PHP string comparison with no quotes

From what I know about PHP, the following syntax is not legal: if ($s == Yes) It should instead be written as: if ($s == 'Yes') However, the first example is working just fine. Anyone know why? ...

String Occurance Counting Algorithm

Hello, I am curious what is the most efficient algorithm (or commonly used) to count the number of occurances of a string in a chunck of text. From what I read, Boyer–Moore string search algorithm is the standard for string search but I am not sure if counting occurance in an efficient way would be same as searching a string. In python...

Hash of unique value = unique hash?

Theoretically does hashing a unique value yield a unique value? Let's say I have a DB table with 2 columns: id and code. id is an auto-incrementing int and code is a varchar. If I do ... $code = sha1($id); ... and then store $code into the same row as $id. Will my code column be unique as well? What about if I append the current ...

Convert a String into an Array of Characters

In PHP, how do i convert: $result = abdcef; into an array that's: $result[0] = a; $result[1] = b; $result[2] = c; $result[3] = d; ...

Convert array to CSV/TSV-formated string in Python.

Python provides csv.DictWriter for outputting CSV to a file. What is the simplest way to output CSV to a string or to stdout? For example, given a 2D array like this: [["a b c", "1,2,3"], ["i \"comma-heart\" you", "i \",heart\" u, too"]] return the following string: "a b c, \"1, 2, 3\"\n\"i \"\"comma-heart\"\" you\", \"i \"\",heart...

Last substring of string

In java we have indexOf and lastIndexOf. Is there anythink like lastSubstring? It should work like : "aaple".lastSubstring(0, 1) = "e"; ...

How can I set the minDate/maxDate for jQueryUI Datepicker using a string?

jQueryUI Datepicker documentation states that the minDate option can be set using "a string in the current dateFormat". So I've tried the following to initialize datepickers: $("input.date").datepicker({ minDate: "01/01/2010", maxDate: "12/31/2010" }); However, this results in my datepicker having a selectable date range that goes fro...

Transmogrify into date from multiple columns

What is a better way to program the following SQL: str_to_date( concat(convert(D.DAY, CHAR(2)), '-', convert(M.MONTH, CHAR(2)), '-', convert(M.YEAR, CHAR(4))), '%e-%m-%Y' ) as AMOUNT_DATE I want to convert the columns D.DAY, M.MONTH, and M.YEAR to a date field using MySQL. The above works, but seems much more complicated t...

How to turn a string into a date in Javascript.

How could I turn this string Sun Apr 25, 2010 3:30pm Into a valid Date in JavaScript (Minimal code is what I'm aiming for here)? ...

How do I create English-language list (name1, name2, AND name3) in Ruby on Rails?

Quite possibly there could be a rails magic I've missed, but I'm guessing it will be in Ruby. I have a model called Company which has_many Contacts. Suppose Company has Contact 1, Contact 2, Contact 3, and Contact 4. When I create a textblog for each Contact, I want to output the following (where Contact = Contact 1) "Hi, Contact 1, ...

A Tkinter StringVar() Question

I would like to create a StringVar() that looks something like this: someText = "The Spanish Inquisition" #Here's a normal variable whose value I will change eventually TkEquivalent = StringVar() #and here's the StringVar() TkEquivalent.set(string(someText)) #and here I set it equal to the normal variable. When someText changes, t...

Data Validation for Random varying Phone Numbers

I am storing phone numbers of varying lengths in my WPF (C#, VS 08) App. I store them as strings. My question is about my method AddNewPhoneNo(string phoneNo). In this method, I use Int.TryParse to validate the incoming number (i.e. not null, is numeric...). I've since realized this is probably not the best way to do this, because then...

Why doesn't the String class in Java implement Iterable?

Many Java framework classes implement Iterable, however String does not. It makes sense to iterate over characters in a String, just as one can iterate over items in a regular array. Is there a reason why String does not implement Iterable? ...

add html to div with jQuery

Hi. I am trying to add some additional html to a div with id slideshow using jQuery. My code: $("#slideshow").append("<a id="prev" title="Previous Slide">Previous Slide</a><a id="next" title="Next Slide">Next Slide</a>"); This isn't working, can anyone tell me what I am doing wrong? ...