I have a variable that reads as _123456 and I need to delete the underscore prefix on this variable before storing it to a field. How do I do this?
var value = "_123456"
I have my views render to route requests like /controller/action (for instance, /Page/Create), so pretty classic.
I am creating a form where view will be loaded through AJAX request with jQuery get(), so essentially I need my Views or to be precise, my controller actions, to return plain HTML string when an AJAX request is made to the route that renders the View. I want to use the same views as for normal requests, so I cannot afford to create any new views.
It is something like calling RenderPartial("MyViewUserControl") but from inside the JS code.
Hey.
My code crashes at this function (at the stringByAppendingFormat: with error objc_msgSend() selector name: stringByAppendingFormat).
This is that line:
// imagesPath = ...iPhone Simulator/4.0/Applications/NUMBERS/Documents/images
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingFormat:@"/%d.png", [[self.postsArrayID objectAtIndex:row] intValue]]];
Could it have something to do with the retaining of objects?
Thanks :)
I'm using the Twitter API streaming to collect thousand of tweets every minute.
They need to be matched to a list of keywords (can contain spaces).
This is my current method:
$text = preg_replace( '/[^a-z0-9]+/i', ' ', strtolower( $data['text'] ) );
$breakout = explode( " ", $text );
$result = array_intersect( $this->_currentTracks, $breakout );
I chop the tweet into words, and the matches them against my current keywords.
This works well for all the keywords without a space ofc.
If I wanted to find for example "Den Haag", It won't show up, because the string is exploded into words (based on the spaces).
Any ideas about how I can do this in a quick way?
Kind regards,
Tim
I am trying to format currency that will always contain 2 decimal digits, but if there are extra digits of accuracy to display up to five. As an example:
for value = 5.0
display: $5.00
for value = 5.023
display: $5.023
for value = 5.333333333333333
display: $5.33333
I have been playing with the .ToString() formatting, but I can't seem to find the right match of options.
Clarification:
I want to show from 2-5 decimals, truncating zeros after the second digit.
for value = 5.000000000000000
display: $5.00
for value = 5.333333333333333
display: $5.33333
I have the following code:
LPCTSTR strPermission = Method();
if (strPermission == L"0")
{
return true;
}
else
{
return false;
}
While debugging I can see that strPermission does equal "0", yet when I compare it like in the if statement it always returns false.
The only thing I can think of is that it is comparing the memory address of the variable rather than the variable value.
How do I compare strPermission to L"0" so that it would return true if strPermission equals "0".
Thank you!
i have a username= LICTowner.
i need to get the prefix from the word LICTowner i.e LICT.
how to split the word and get the 4 letter prefix.
in asp.net using C#
I open a website with urlopen. I then put the website sourcecode into a variable like so
source = website.read()
When I just print the source it comes out formatted correctly, however when I try to iterate through each line each character is it's own line.
for example
when I just print it looks like this
<HTML> title</html>
When I do this
for line in source:
print line
it looks like this
<
H
T
M
L
... etc
I need to find a string that starts with "var" and then print that entire line.
Hi all, I have been trying to create an iphone app sending telnet command. However what puzzling me is that the sizes of certain strings are so much different, particularly when they include \n or \r. I listed out a few examples. Please assist.
const char *a = "play 25\n";
int sizeBitA1 = sizeof(a); // 8 units
int sizeBitA2 = sizeof("play 25\n"); // 9 units
const char *b = "\r\n";
int sizeBitB1 = sizeof(b); // 8 units
int sizeBitB2 = sizeof("\r\n"); // 3 units
I am currently working on an android project and I want to be able to startActivityForResult so that I can return an array of.
The array is an ArrayList<Spanned> lets say its called myArray.
From what I've read I can't return an array directly from the activty using the set result so I was thinking that once the array has added all the data to the array, I can then call the toString function on it, i.e. myArray.toString().
If I do this, I have no idea how I can then convert this back into the original ArrayList<Spanned>.
Thanks for any help you can provide.
Hi all.
Problem:
I am using Java Tutorials™ sourcecode for this. This is the source code.
I tried this:
--following with another section of sorted words--
words.add("count");
words.add("cvs");
words.add("dce");
words.add("depth");
--following with another section of sorted words--
and it works perfectly. However when I use this:
--just a section of sorted words--
words.add("count");
words.add("cvs");
words.add("dce_iface");
words.add("dce_opnum");
words.add("dce_stub_data");
words.add("depth");
--following with another section of sorted words--
It does show dce_iface when I type dce, but when I type _ then following with o or s it shows me something else like dce_offset where the offset comes from words.add("fragoffset"); somewhere in the list.
What can I do to solve this problem? Thank you in advance.
How to get the keyword match number for many categories?
The scenario is that when I type a product keyword, I want to get the match item number in many categories.
For example, when I type the keyword "iphone" , the page will show the match item number in many categories:
Mobile(5)
battery(2)
app(6)
typeA(2)
typeB(9)
typeC(15)
typeC(1)
typeD(9)
typeE(7)
typeF(8)
......
......
typeZ(5)
How to implement this for a better performance?
I use C# ASP.NET.
I need to output a cell to an excel file. Before this I need to convert a date column of integers to datestrings. I know how to do this, but I am not able to put this new string array back into the cell -
mycell = { 'AIR' [780] [1] [734472] [0.01] ; ...
'ABC' [780] [1] [734472] [0.02]}
I did this --
dates = datestr(cell2mat(mycell(:,4))) ;
What I need as an answer is:
{'AIR' [780] [1] '14-Dec-2010' [0.01] ;
'ABC' [780] [1] '23-Dec-2010' [0.03] ; }
so that I can now send it to an excel file using xlswrite.m
hi eveybody
i want to look how much an array comes in a database. Its pretty slow and i want to know if there's a way of searching like multiple words or an whole array without a for loop.. i'm struggeling for a while now.
here's my code
$dateBegin = "2010-12-07 15:54:24.0";
$dateEnd = "2010-12-30 18:19:52.0";
$textPerson = " text text text text text text text text text text text text text text ";
$textPersonExplode = explode(" ", $textPerson );
$db = dbConnect();
for ( $counter = 0;$counter <= sizeof($textPersonExplode)-1 ; $counter++) {
$query = "SELECT count(word) FROM `news_google_split` WHERE `word` LIKE '$textPersonExplode[$counter]' AND `date` >= '$dateBegin' AND `date` <= '$dateEnd'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$word[] = $textPersonExplode[$counter];
$count[] = $row[0];
}
if (!$result) {
die('Invalid query: ' . mysql_error());
}
}
thanks for the help.
I am trying to write a recursive method to print n number of asteriks in a line and create a new line at the end.
So, TriangleOps.line(5);
would print
*****
This is the code I wrote:
public static void line (int n){
if(n>0){
System.out.println("*");
line(n-1);
}}
instead it prints
*
*
*
*
*
with a lot of space at the end. Can anyone tell me how to remove the line breaks?
Righto, firstly magic quotes & runtime are disabled correctly in php.ini, and confirmed by phpinfo().
PHP version: 5.3.4
MySQL version: 5.1.52
I'm only use mysql_real_escape_string on the data, after htmlspecialchars and a trim, that's all the data cleaning on the variable.
Yet, when I submit a single quote, the slash remains in the database.
When running mysql_query I'm using "' . $var . '", although in the past this hasn't changed anything (could be due to the double quotes?).
Any ideas? and please don't tell me about PDO/prepared statements, I'm aware of them and I have my reasons for doing it this way.
Thanks!
I'm trying to use the google_search ruby library (code follows) but it complains that 'cattr_accessor is an undefined method' - any ideas why this might be or how I could fix it?
require 'rubygems'
require 'google_search'
GoogleSearch.web :q => "pink floyd"
Hi!
I'm writing a small C application that launchs a Matlab script (.m file).
I need to exchange some variables and I don't know how to get an array of chars that exists in Matlab.
I'm doing something like this:
enter code here
result = engGetVariable(ep,"X");
if (!result)
{
printf ("Error...");
exit -1;
}
int n = mxGetN(result);
char *varx = NULL;
memcpy(varx, mxGetData(result),n*sizeof(char));
It doesn't work. Does someone know how to get a Matlab string in C?
I've read Matlab documentation about engGetVariable() and the provided example but any of this things clarify me.
I am aware there is a function strcasecmp() that compares cstrings ignoring case, but I was wondering if there is a function that does the same thing except with strings? I am working with a bunch of strings, and feel like it would be terribly inefficient to have to use c_str() each time I want to compare them with strcasecmp(). Should I just use cstrings instead of strings...?
I am trying to build a search functionality which at a high level works like this.
1 - I have a Search model, controller with a search_set action and search views/partial to render the search.
2 - At the home page a serach form is loaded with an empty search object or a search object initialized with session[:search] (which contains user search preferences, zip code, proximity, sort order, per page etc). This form has a post(:put) action to search_set.
3 - When a registered user performs a set the params of the search form are collected and a search record is saved against that user. If a unregistered user performs a search then the search set action simply stores the params in the session[:search]. In either case, the search is executed with the given params and the results are displayed. At this point the url of in the location bar is something like..
http://localhost:3000/searches/search_set?stype=1
At this point if the user simply hits enter on the location bar, I get an error that says "No action responded to show" I am guessing because the URL contains search_set which uses a put method and even though I have a search_show (:get) action (which simply reruns the search in the session or saved in the database) does not get called.
How can I handle this situation where I can route a user hitting enter into the location bar to a get method?
If this does not explain the problem , please let me know I can share more details/code etc.
Thanks!
Hello,
typedef enum testCaseId
{
"TC-HIW-0019" = 0,
"TC-HIW-0020",
"TC-HIW-0021"
} testCaseId;
I need my test cases to be represented in enum. In my test function, I need to switch between the test cases like:
void testfunc(uint8_t no)
{
switch(no)
{
case 0:
case 1:
default:
}
}
So can anyone help on how to use enum to declare strings.
Hi,
I have a mySql database i want to display only 10 words from its body field which contain html codes, How i can do that, is there any php function to do that.
I have inherited the following line of code:
TCHAR temp[300];
GetModuleFileName(NULL, temp, 300);
However, this fails as the first 3 bytes are filled with garbage values (always the same ones though, -128, -13, 23, in that order). I said, well fine and changed it to:
TCHAR temp[300];
ZeroMemory(temp, 300);
GetModuleFileName(NULL, temp, 300);
but the garbage values persisted! Can someone explain what is going on and how to fix it?
I am using a tableview with a search function and is populated by a plist. I want to pass 2 strings through to a DetailView. But I can only get the sting used to populate the cell to pass over. I have tried many variations but can't figure it out. Any help would be greatly appreciated.
DetailView *nextLevel = [DetailView alloc];
NSString *valueString;
NSString *selectedTitle;
if (arraySearch == nil) {
NSString *key = [arrayDataKeys objectAtIndex:indexPath.section];
NSArray *nameSection = [dictAllData objectForKey:key];
NSDictionary *dict = [nameSection objectAtIndex:indexPath.row];
valueString = [dict objectForKey:@"name"];
selectedTitle = [dict objectForKey:@"word"];
} else {
valueString = [arraySearch objectAtIndex:indexPath.row];
**selectedTitle = [arraySearch objectAtIndex:indexPath.row];** //Obviously this is wrong but this is the line I need help with
}
nextLevel.title = valueString;
nextLevel.itemname = valueString;
nextLevel.itemWord = selectedTitle;