Hi,
do you know any good algorithms that match two strings and then return a percentage in how many percent those two strings match?
And are there some, that work with databases too?
Is there any way to evaluate a string expression in XSL?
example:
<myItem id="1">
<validator expression="$someVariable = '3'" />
</myItem>
...
<xsl:variable name="someVariable" select="3" />
<xsl:if test="@expression"> ...
I realize this syntax does not work the way I want it to, but is there any way to store the test expression in a variable and then evaluate the expression?
Hi,
i have declared an entity the following way:
public class MyEntity {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String text;
//getters and setters
}
Now I want to retrieve the objects using the id. I tried to manage it from the Google Appengine Data Viewer with "SELECT * FROM MyEntity Where id = 382005" or via a query in a servlet. I get no results returned. But i know for sure that the object with the id exists (i made a jsp which queries all objects in the db and displays them in the db).
So what is wrong in my query? Am I querying the wrong field? The Google Appengine Data Viewer names the field "ID/name" and it has the value "id=382005". Do I have to query with this names? I've tried but it didn't work out :(
I am parsing xml from server. One of its node contains data like
<distance>16.3432434324354324km</distance>
I am putting it into hashmap like
for (int i = 0; i < nl.getLength(); i++) {
map.put(KEY_DISTANCE, parser.getValue(e, KEY_DISTANCE));
// adding HashList to ArrayList
menuItems.add(map);
}
Everything is nice. But i want it two decimal places for example i want its value should be
16.34km rather then 16.343234324342342km
I tried with
DecimalFormat twoDForm=new DecimalFormat("##.00");
try{
Double StartVTwo=Double.valueOf(KEY_DISTANCE);
Double resultDouble1 = Double.valueOf(twoDForm.format(StartVTwo));
Log.e("check", String.valueOf(resultDouble1));
}catch (NumberFormatException e){
Log.e("error"," This is error ");
}
But it shows exception and prints this message.
Any help would be appreciated!!
I would like to kill a quoted string in a source file
without having to mark the beginning of the string and kill-region,
but just by placing the point anywhere inside the quoted string and pressing a shortcut.
I tried to write a function in elisp for this, but I figured out that the file
would need to be parsed from the beginning up to point to determine whether the point is inside quoted string, and to find the bounds of the quoted string(also handle the \")...
But the file is already parsed by font-lock.
So now I can find out if I'm inside quoted string:
(defun inside-quoted-string? ()
(interactive)
(print (find 'font-lock-doc-face (text-properties-at (point)))))
But how do I get the bounds of the string?
font-lock knows it, since it nicely highlights it in blue, but how do I get it?
What is the best way to achieve sscanf-like functionality in perl?
I am looking now looking at the sscanf module,
Which is better,
Option-1: Going sscanf way?
Option-2: Regex way? [I am a beginner when it comes to Regex]
I have a ListView control set up in details mode, and on a button press I would like to retrieve all column values from that row in the ListView.
This is my code so far:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim items As ListView.SelectedListViewItemCollection = _
Me.ManageList.SelectedItems
Dim item As ListViewItem
Dim values(0 To 4) As String
Dim i As Integer = 0
For Each item In items
values(i) = item.SubItems(1).Text
i = i + 1
Next
End Sub
But values just comes out as an empty array. Any ideas? I just want the values array to be filled with the data of that ListView row.
Cheers.
Hello,
i'm building a template engine for my next project, which is going great. It replaces {tag} with a corresponding value. But, i want {tag[0][key]} to be replaced as well. All i need to know is how to get the value, if i have the string representation of the array and key, like this:
$arr = array(
0=>array(
'key'=>'value'
),
1=>array(
'key'=>'value2'
)
);
$tag = 'arr[0][key]';
echo($$tag);
This is a very simple version of the problem, i hope you understand it. Or else i would be happy to anwser any questions about it :)
Thanks for any help in advantage
i need to parse through a text file and process the data. the valid data is usually denoted by either a timestamp with TS followed by 10 numbers (TS1040501134) or values with a alpabet followed by nine numbers (A098098098)...so it will be like TS1040501134A111111111B222222222...........TS1020304050A000000000........
However, there are cases when there will be filler 0s when there is no data. So, such a case might be
00000000000000000000TS1040501134A111111111B2222222220000000000TS1020304050A000000000........`
Now as we can see I need to ignore these zeros. how might i do this? I am using gnu C.
In my specific case, I need the value in propertyPriceTextBox to be numeric only, and a whole number. A value also has to be entered, and I can just Messagebox.Show() a warning and that's all I'd need to do.
This is what I have so far.
private void computeButton_Click(object sender, EventArgs e)
{
decimal propertyPrice;
if ((decimal.TryParse(propertyPriceTextBox.Text, out propertyPrice)))
decimal.Parse(propertyPriceTextBox.Text);
{
if (residentialRadioButton.Checked == true)
commisionLabel.Text = (residentialCom * propertyPrice).ToString("c");
if (commercialRadioButton.Checked == true)
commisionLabel.Text = (commercialCom * propertyPrice).ToString("c");
if (hillsRadioButton.Checked == true)
countySalesTaxTextBox.Text = ( hilssTax * propertyPrice).ToString("c");
if (pascoRadioButton.Checked == true)
countySalesTaxTextBox.Text = (pascoTax * propertyPrice).ToString("c");
if (polkRadioButton.Checked == true)
countySalesTaxTextBox.Text = (polkTax * propertyPrice).ToString("c");
decimal result;
result = (countySalesTaxTextBox.Text + stateSalesTaxTextBox.Text + propertyPriceTextBox.Text + comissionTextBox.Text).ToString("c");
}
else (.)
MessageBox.Show("Property Price must be a whole number.");
}
How can I remove first two elements of a string array?
I have a code which is something like this.
char *x[10];
..............
..............
..............
char *event[20];
event[0]=strtok(x[i]," ");
event[1]=strtok(NULL," ");
event[2]=strtok(NULL," ");
event[3]=strtok(NULL," ");
event[4]=strtok(NULL," ");
event[5]=strtok(NULL," ");
for(i=2;i<length;i++)
{
strcpy(event[i-2],event[i]);
}
I observed that only event[0] has proper values. I printed the contents of event[][] before for loop and it displays correctly. Could you please tell me why this is wrong? and a possible solution?
Hi,
I'm looking at some external code and saw a line of Ruby code that looks like this
string_name = string_name[3..-1]
what does the [n..-x] do or mean?
Thanks.
I want to replace the inner_text in all paragraphs in my XHTML document.
I know I can get all text with Nokogiri like this
doc.xpath("//text()")
But I want only operate on text in paragraphs, how I can select all text in paragraphs without affecting eventually existent anchor texts in links ?
#For example : <p>some text <a href="/">This should not be changed</a> another one</a>
Right now I am seeing if a sentence contains a specific word by splitting the sentence into an array and then doing an include to see if it contains the word. Something like:
"This is my awesome sentence.".split(" ").include?('awesome')
But I'm wondering what the fastest way to do this with a phrase is. Like if I wanted to see if the sentence "This is my awesome sentence." contains the phrase "my awesome sentence". I am scraping sentences and comparing a very large number of phrases, so speed is somewhat important.
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 than it needs to be. (If there's an ANSI SQL way to do it, that would be even better.)
Thank you!
Data in the file_name field of the generation table should be an assigned number, then _01, _02, or _03, etc. and then .ldf (example 82617_01.pdf).
Somewhere, the program is putting a state name and sometimes a date/time stamp, between the assigned number and the 01, 02, etc. (82617_ALABAMA_01.pdf or 19998_MAINE_07-31-2010_11-05-59_AM.pdf or 5485325_OREGON_01.pdf for example).
We would like to develop an SQL statement to find the bad file names and fix them. In theory it seems rather simple to find file_names that include a varchar2 data type and remove it, but putting the statement together is beyond me.
Any help or suggestions apprecuiated.
Something like ...........
UPDATE GENERATION
SET FILE_NAME (?)
WHERE FILE_NAME (?...LIKE '%STRING%');?
I am trying to remove a trailing - (dash) at the end of the string. Here is my code:
<?php
$str = 'SAVE $45! - Wed. Beach Co-ed 6s (Jul-Aug)';
echo ereg_replace('([^a-z0-9]+)','-',strtolower($str));
?>
produces this:
save-45-wed-beach-co-ed-6s-jul-aug-
How can I remove a specific trailing character only if its there, in this case the dash?
Thanks in advance.
I am currently trying to sanitize some log files so they are in an easier format to read, and have been trying to use the gnu cut command, which works fairly well, although I cannot really think of a good way to remove the [INFO] part of the string
logs/logs/server_1283258036.log:2010-08-31 23:06:51 [INFO] <NateMar> where?!
logs/logs/server_1281904775.log:2010-08-15 22:59:53 [INFO] <BoonTheMoon> §b<BoonTheMoon>§ohhhhhh
I would ultimately want to get the strings down to something that resembles the following
2010-08-31 23:06:51 <NateMar> where?!
2010-08-15 22:59:53 <BoonTheMoon> ohhhhhh
how should I go about doing this? Have thought about using awk, although Im having a difficult time getting a grip on how that would work, so not sure how to set up something to do that, any help would be greatly appreciated, thanks!
Is it possible to multiply a char by an int?
For example, I am trying to make a graph, with *'s for each time a number occurs.
So something like, but this doesn't work
char star = "*";
int num = 7;
cout << star * num //to output 7 stars
Hi;
I have n documents and want to find common words that are included in these documents.
For example I want to say (n-3) documents include the word "web".
Certainly I can do this by basic data structures but there maybe efficient algorithm or a way to handle same words with different suffix.
Is there any algorithm for such purposes?
I am unfamiliar with datamining world. In general manner is there a term used for efforts of finding similarities between different documents? If there is then I will make my research easily.
Thanks.
Is there a way to show subnode if the parent node is hidden in the Virtual String Tree ?
I have some tasks in the tree structure and I wish to display only tasks which belongs to the current user as the list, but from all levels.
What I've done is the function to display a list, which hides tree buttons, tree lines, sets the fixed indent and enable toShowHiddenNodes option. Then in this function I iterate through the whole tree (all levels) and hide nodes which doesn't belong to the current user IsVisible[Node] := False and show those which belongs him IsVisible[Node] := True, but the subnodes which should be displayed are invisible when their parent is hidden.
VT.TreeOptions.PaintOptions
- toShowButtons
- toShowTreeLines
+ toFixedIndent
+ toShowHiddenNodes
Comparing version numbers as strings is not so easy...
"1.0.0.9" "1.0.0.10", but it's not correct.
Obvious way to do it properly is parse these strings, convert to numbers and compare as numbers.
Is it other way to do it more "elegant"? For example, boost::string_algo...
I want to replace a url querystring parameter with a new value if it already exists or add it on if not.
e.g.
The current url could be:
a. www.mysite.com/whatever.asp?page=5&version=1 OR
b. www.mysite.com/whatever.asp?version=1
I need the resulting url to be www.mysite.com/whatever.asp?page=1&version=1
I suspect I can use string.replace with a regex to do this the most intelligent way but am hoping for a little help with it from someone more experienced with regexs :) Thanks!
I haveasp:GridView displaying client requests using asp:SqlDataSource. I want to limit displayed information by client:
View.aspx has to display everything, View.aspx?client=1 has to display only requests from client ID #1.
So I'm using <asp:QueryStringParameter Name="client" QueryStringField="client" /> for query "EXEC getRequests @client".
Everything works properly when some client is specified. But don't - if not.
I tested my SP using SSMS - it works properly in both cases - when parameter is specified and when it isn't (NULL passed explicitly).
What have I do?