can i create a case insensitive string column in sqlalchemy? im using sqlite, and theres probaby a way to do it through DB by changing collation, but i want to keep it in sqlalchemy/python.
I need a bash command that will convert a string to something that is escaped. Here's an example:
echo "hello\world"|escape|someprog
Where the escape command makes "hello\world" into "hello\\world". Then, someprog can use "hello\world" as it expects. Of course, this is a simplified example of what I will really be doing.
Hi all,
I would like to know, is there a conversion library for converting string patterns to PCRE regular Expression patterns.
Sample Patterns:
application/ms-tnef ARKADMIN_GET_ 34 ^MAIL FROM|3a| ?
2|
Thanks in advance.
I'm creating an email using String Template but when I print out a date, it prints out the full date (eg. Wed Apr 28 10:51:37 BST 2010). I'd like to print it out in the format dd/mm/yyyy but don't know how to format this in the .st file.
I can't modify the date individually (using java's simpleDateFormatter) because I iterate over a collection of objects with dates.
Is there a way to format the date in the .st email template?
Hello,
gcc 4.4.2 c89
I have the following enum:
enum drop_options_e
{
drop_ssm,
drop_snm,
drop_ssb
};
I am just wondering that is the best way to get the string representation value from the enum.
So basically, instead of returning the value of 0 for drop_ssm, I could get the 'drop_ssm' instead.
Many thanks for any advice,
I download one program that read file and then parse double values from String to Double. But I get an exception because this file contains numbers with '.' separator, but there is ',' in my culture. How can I set culture explicitly?
I need start off with code because I am not sure what terminology to use. Lets say I have the following code:
class Node
{
public:
void Parse(rapidxml::xml_node<> *node)
{
for (rapidxml::xml_attribute<> *attr = node->first_attribute();
attr;
attr = attr->next_attribute())
{
std::stringstream converter;
converter << attr->value();
if( !strcmp(attr->name(), "x") ) converter >> x;
else if( !strcmp(attr->name(),"y") ) converter >> y;
else if( !strcmp(attr->name(), "z") ) converter >> z;
}
}
private:
float x;
float y;
float z;
};
What I can't stand is the repetition of if( !strcmp(attr-name(), "x") ) converter x; I feel that this is error prone and monotonous, but I cannot think of another way to map a string value to a member assignment. What are some other approaches one can take to avoid code such as this? The only other possible alternative I could think of was to use a hashmap, but that runs into problems with callbacks
This is the best I could up with but it's not as flexible as I'd like:
class Node
{
Node() : x(0.0f), y(0.0f), z(0.0f)
{
assignmentMap["x"] = &x;
assignmentMap["y"] = &y;
assignmentMap["z"] = &z;
}
public:
void Parse(rapidxml::xml_node<> *node)
{
for (rapidxml::xml_attribute<> *attr = node->first_attribute();
attr;
attr = attr->next_attribute())
{
if( !attr->name() ) continue;
std::stringstream converter;
converter << attr->value();
converter >> *assignmentMap[attr->name()];
}
}
private:
float x;
float y;
float z;
std::map<std::string, float*> assignmentMap;
};
I want to convert a string such as 'a=b,a=c,a=d,b=e' into a dict of lists {'a': ['b', 'c', 'd'], 'b': ['e']} in Python 2.6.
My current solution is this:
def merge(d1, d2):
for k, v in d2.items():
if k in d1:
if type(d1[k]) != type(list()):
d1[k] = list(d1[k])
d1[k].append(v)
else:
d1[k] = list(v)
return d1
record = 'a=b,a=c,a=d,b=e'
print reduce(merge, map(dict,[[x.split('=')] for x in record.split(',')]))
which I'm sure is unnecessarily complicated.
Any better solutions?
I have been working with Coldfusion 9 lately (background in PHP primarily) and I am scratching my head trying to figure out how to 'clean/sanitize' input / string that is user submitted.
I want to make it HTMLSAFE, eliminate any javascript, or SQL query injection, the usual.
I am hoping I've overlooked some kind of function that already comes with CF9.
Can someone point me in the proper direction?
Hi,
Please share some good websites where I can learn more on String Processing Techniques and could grill myself more into different kinds of algorithm available in this field..
Thanks..
A<<B would mean circling the characters of A towards left by the length of the data in B . So I am using split not the loop . But I am not able to figure out how to split a string according to the length of B.
I have a string something like this:
"2014-01-23 09:13:45|\"10002112|TR0859657|25-DEC-2013>0000000000000001\"|10002112"
I would like to split by pipe apart from anything wrapped in double quotes so I have something like (similar to how csv is done):
[0] => 2014-01-23 09:13:45
[1] => 10002112|TR0859657|25-DEC-2013>0000000000000001
[2] => 10002112
I would like to know if there is a regular expression that can do this?
Hi,
is there a way to convert a javascript HTML object to a string?
i.e.
var someElement = document.getElementById("id");
var someElementToString = someElement.toString();
thanks a lot in advance
Hi, just going through the registry retrieving values and binary is making my file outputer fall.
I was wondering how could i convert Subkey.getValue(value[i]) into a String if the Value type is binary?
Thank you in advance
Hello !
When I try to cast
$value = floatval('14,5833');
to a float type I expect a value with dot like 14.5833 but it returns me 14,5833.
How should I do this ?
I wouldn't like to use any string replace functions.
Is there any way to create a hash of string at compile time using the C/C++ preprocessor (or even template-metaprogramming)?
e.g. UNIQUE_SALT("HelloWord", 3DES);
The idea is that HelloWorld will not be present in the compiled binary, just a hash.
Trying to find emails from an inbox using exchange webservices (against exchange 2007). the subject of which should not be empty.
Tried the following:
searchFilterCollection.Add(new SearchFilter.IsNotEqualTo(EmailMessageSchema.Subject, string.Empty));
and
searchFilterCollection.Add(new SearchFilter.IsNotEqualTo(EmailMessageSchema.Subject, null));
but no luck. What do I need to do to get those messages that have a subject?
I'm creating a simple Ruby on Rails survey application for a friend's psychological survey project.
So we have surveys, each survey has a bunch of questions, and each question has one of the options participants can choose from. Nothing exciting.
One of the interesting aspects is that each answer option has a score value associated with it.
And so for each survey a total score needs to be calculated based on these values.
Now my idea is instead of hard-coding calculations is to allow user add a formula by which the total survey score will be calculated. Example formulas:
"Q1 + Q2 + Q3"
"(Q1 + Q2 + Q3) / 3"
"(10 - Q1) + Q2 + (Q3 * 2)"
So just basic math (with some extra parenthesis for clarity). The idea is to keep the formulas very simple such that anyone with basic math can enter them without resolving to some fancy syntax.
My idea is to take any given formula and replace placeholders such as Q1, Q2, etc with the score values based on what the participant chooses. And then eval() the newly formed string. Something like this:
f = "(Q1 + Q2 + Q3) / 2" # some crazy formula for this survey
values = {:Q1 => 1, :Q2 => 2, :Q3 => 2} # values for substitution
result = f.gsub(/(Q\d+)/) {|m| values[$1.to_sym] } # string to be eval()-ed
eval(result)
So my questions are:
Is there a better way to do this?
I'm open to any suggestions.
How to handle formulas where not all
placeholders were successfully replaced (e.g. one
question wasn't answered)? Ex: {:Q3 = 2} wasn't
in values hash? My idea is to rescue eval()... any thoughts?
How to get proper result? Should be 2.5, but due to integer arithmetic, it will truncate to 2. I can't expect people who provide the correct formula (e.g. / 2.0 ) to understand this nuance.
I do not expect this, but how to
best protect eval() from abuse (e.g.
bad formula, manipulated values
coming in)?
Thank you!
Hello,
I want to know how to echo a string that have a $ sign from a database. At this time, the value on database 'Buy one for $5.00' converts to 'Buy one for .00'.
Ex:- Field: title | Value: Buy one for $5.00
<?php
$row = mysql_fetch_array.....
$title = $row['title'];
echo $title;
?>
Thank you, pnm123
UPDATE CustomerPhone
SET PhoneTypeID = 7, PhoneNumber = 999-444
WHERE CustomerID = 500 AND PhoneNumber = 9-1-1;
PhoneNumber is of type varchar(20) whereas PhoneTypeID and CustomerID are of type int. I'm running the above statement in SQL Server, it works fine.
I wonder how come it works? I thought any string value has to be put between '...'
How to Assign an Array with literal string index to an array with numeric index.
[IN PHP]
Both have the same length...for example
Literal array(HELL0=somevalue1,BYE=somevalue2)
Numeric index array(1=somevalue1,2=somevalue2) [Expected result in second array]
Both have same length / count of values 2.
Pls help ASAP
Anita
Hello,
In my table I have a serial number field, which is represneted by string.. It has a prefix and some numbers follow. Eg: ABC1234, ABC2345 etc. How to retrieve the largest value (max equivalent of int type) from this column. In my case it would be ABC2345. I probably could retrieve all the data,, sort it and get the same, but that would be slow.
thanks in advance..
I am using spring mvc in which i convert the arraylist into json string. I have one object 1) results.
My output from spring looks like this:
{
"data":"[{\"userName\":\"test1\",\"firstName\":\"test\",\"lastName\":\"user\"}, {\"userName\":\"test2\",\"firstName\":\"test1\",\"lastName\":\"user1\"}]",
}
I get output as null when i do '$.parseJSON' with this output. When i tried testing only with data object it works fine
Any help would be great.
How can i pass a string delimited by space or comma to stored procedure and filter result?
I'm trying to do something like -
Parameter Value
--------------------------
@keywords key1 key2 key3
Then is stored procedure i want to first
find all records with first or last
name like key1
filter step 1 with first or last
name like key2
filter step 2 with first or last name like key 3
Hey.
I'm trying to format a date from a string into another format.
For example: 2012-05-29 23:55:52 into 29/05 *newline* 2010.
I just don't get the logics behind NSDate and NSDateFormatter, I think..
Any help will be appreciated. Thanks :)