You can declare and initialize an array with integers in one line as following:
int[] myArray = new int[{...}];
How can I do this with an ArrayList, if possible?
I have lines of data which I want to parse.
The data looks like this:
a score=216 expect=1.05e-06
a score=180 expect=0.0394
What I want to do is to have a subroutine
that parse them and return 2 values (score and expect) for
each line.
However this function of mine doesn't seem to work:
def scoreEvalFromMaf(mafLines):
for word in mafLines[0]:
if word.startswith("score="):
theScore = word.split('=')[1]
theEval = word.split('=')[2]
return [theScore, theEval]
raise Exception("encountered an alignment without a score")
Please advice what's the right way to do it?
I would like to perform checking on the following:
VALID LINES;
/**/ some code
*/ some code /** dsfsdkf sd**/
NOT VALID LINES;
/**/ //some code
*/ /***/ //somecode
So basically if there is a line of code outside a comment it is valid, otherwise not.
What would be the best way to tackle this kind of validation?
Note:
For */ I assume that the /* has been opened some lines before.
I use the command line sqlite3 executable to check queries I make from my code.
Is there a way to read in pragma statements or other session setup (".mode csv" for example) when the executable starts up?
I know I can do a ".read " once I'm in, but that's tedious.
I am pulling data into my iphone application using xml. The xml value is then placed in a variable.
example variable:
123 London road \n London \n England
The variable is then set as a label.
I want the line breaks to appear in the label, instead it is printing \n.
If i manually set the label value
locationLabel.text = @"123 London road \n London \n England"
It works as i want it to.
Can anyone explain this?
This is the code I have so far
d = {}
counter = 0
for lines in words:
counter += 1
for word in text1:
if word not in words:
d[word] = [counter]
else:
d[word].append(counter)
print(word, d[counter])
words = my text file
text1 is my misspelled words
But this gives me an error. What I want to do is print the word and the line number e.g.
togeher 5 7
Hello All,
This is my first thread iam developing an application in which i have to convert the HTML contents to pdf file.
I had generate the PDF File but don't know how to create a pdf file from HTML format.
Anyone can suggest the solution?
Thank You.
Is there a way to get DVD region code from command line (linux/ubuntu 9.10)?
I want to script this action and store the region code (and other data about DVD) in a log.
Hi, I am wondering what this line of code mean?
b = (gen_rand_uniform()>0.5)?1:0;
The gren_rand_uniform() is a function to generate random 0 and 1 numbers. However I don't get the meaning for >0.5 and 1:0.
I know this is supposed to be a basic question, please bear with me.
Thanks!
How can I achieve a result like somebody would expect it according to the following code example:
// assuming: void myFunction( int* arr );
myFunction( [ 123, 456, 789 ] );
// as syntactical sugar for...
int values[] = { 123, 456, 789 };
myFunction( values );
The syntax I thought would work spit out a compile error.
How can I define an argument array directly in the line where the function is called?
I need to find basic WYSIWYG HTML editor component for C++Builder 5 to let users to create some simple text that I will paste into existing HTML page template.
Just a simple support to create links, add images, use headers/bold/italic.
I need to make a SOAP webservice call to https://sandbox.mediamind.com/Eyeblaster.MediaMind.API/V2/AuthenticationService.svc?wsdl and to use the operation ClientLogin while passing through the parameters: ApplicationKey, Password, and UserName. The response is UserSecurityToken. They are all strings.
Here is the link fully explaining what I am trying to do:
https://sandbox.mediamind.com/Eyeblaster.MediaMind.API.Doc/?v=3
How can I do this on the command line? (Windows and/or Linux would be helpful)
Thanks!
Hello:
How can I break long lines when writing c++ code in vim? For example, if I have something like
56 fprintf(stderr, "Syntax error reading recursion value on
57 line %d in file %s\n", line_count, filename);
I get the following compile errors:
:56:25: warning: missing terminating " character
:56: error: missing terminating " character
:57: error: stray ‘\’ in program
:57:37: warning: missing terminating " character
:57: error: missing terminating " character
I'm a vim newbie.
Thanks!
Hi,
I am using the code from this tutorial to parse a CSV file and add the contents to a database table. How would I ignore the first line of the CSV file? The controller code is below:
def csv_import
@parsed_file=CSV::Reader.parse(params[:dump][:file])
n = 0
@parsed_file.each do |row|
s = Student.new
s.name = row[0]
s.cid = row[1]
s.year_id = find_year_id_from_year_title(row[2])
if s.save
n = n+1
GC.start if n%50==0
end
flash.now[:message] = "CSV Import Successful, #{n} new students added to the database."
end
redirect_to(students_url)
end
So I was working on a toy website (http://nirmalpatel.com/yeah/index.html). If you check the source, you can see that I have linked a m4v and ogg version. When I load this page from my own computer using a url that starts with file:// the page works fine in Safari, Chrome and Firefox. However, after I upload all of the videos and the HTML to my server Firefox stops working. I don't think it's a permissions issue as both videos have the same permission.
I'm trying to read a comment that is stored in a mysql table. For some reason I always get a parse error on the last line of the file even if the last line is blank. I'm not sure if it's relevant but the connect.php works for putting the comment into the database. I'm using wampserver to host it and coding it by hand.
I think that's it's something to do with the while loop, when I comment out the while(){ and the } near the end I just get a few missing variable errors as you would expect. I'm quite new to php coding so I'm pretty sure the problem will be something simple that I've either missed or not understood properly.
Anyway, here's my code:
<?php
include "connect.php";
?>
<?php
$sql = "SELECT * FROM main";
$result = mysql_query($sql) or die("Could not get posts from table");
while($rows=mysql_fetch_array($result)){
?>
<table bgcolor="green" align="center">
<tr>
<td></td>
</tr>
<tr>
<td><strong> <? echo $rows['name']; ?> </strong></td>
</tr>
<tr>
<td> <? echo $rows['email']; ?> </td>
</tr>
<tr>
<td> <? echo $rows['comment']; ?> </td>
</tr>
</table>
<?
}
?>
Thanks for the help. :)
to read a child node content i use :
MYDATA = xhr.responseXML.getElementsByTagName("MenuItem")
[INDEX].getElementsByTagName("PageContent")[0].childNodes[0].nodeValue;
sometimes when the childnode data contains an HTML tag (eg b or br tags, because they have the <), i have problems since they are counted like xml tags (like childnodes).
my question is how to get the entire data from a child node even if it contains other html tags
exp :
MenuItem
MenuText menu b text b MenuText
MenuItem
would return "menu" !!! but i want it to return :"menu text"
thank you guys, and happy new year
Hey,
I'm using the code below to highlight some keywords in a text:
$message = str_ireplace($words,'<span class="hightlighted_text">'.$words.'</span>',$message);
The text may contain some html tags, for example , etc..
How can I highlight "normal" text, except the text between the html tags? Because when users search for "img" the text will be highlighted and the image doesn't work anymore.
Hey,
I'm looking for a way to get the content of my div in my Rails view. I would like the literal HTML content, so only HTML and no Rails
I thought inner_html would work, but I get a RJS exception (TypeError: $("content").innerHtml is not a function)
Does anyone know how I can get the content?
Thanks!
Is there any function in Objective-C to print a list of elements as unordered HTML elements. For ex - [@"a--b-c---d" htmlList: @"--"] returns @ "ab-c-d"
the "--" is the delimiter to seperate the string of elements. I have used NSSArray to store the input string and function componentsSeperatedByString:@"--" to get the elements. How do I go ahead in adding the HTML tags li and /li between elements and ul and /ul at the end of the entire list?
Please help, Im a beginner in objective -C
I am trying to create a Exception class to get and send errors from client to server. I want to catch exception in javascript function and push the details to the web service to write to database.
But i couldn't get how to get which function/line throwed this exception. Is there any way to solve this?
Lets us consider the following program :
#include <stdlib.h>
int main(int argc, char **argv){
int a,b;
if (argc != 3)
return -1;
a = atoi(argv[1]);
b = atoi(argv[2]);
a = b ? a/b : 0;
return a;
}
The task is to crash the program by providing arguments in command-line.