NodeJS spawned docker process hangs
I have the following code, that spawns a docker process upon entering a
path. However, the docker does not close, the callback is never called. I
write the exact result onto a shell and it works perfectly. It doesn't
matter if I use exec or spawn, the behavior is same.
app.get("/path", function(req,res){
// docker run -v $1/:folder mustafa/java /bin/bash folder/execute.sh
var args = ["run","-v " + submission.path + ":/folder",
"mustafa/java", "/bin/bash folder/execute.sh"];
console.log(args.join(" "));
exec('docker ' + args.join(" "), function (error, stdout, stderr) {
console.log("here");
console.log(stdout);
console.log(stderr);
res.send("something");
res.end();
});
});
Thursday, 3 October 2013
Wednesday, 2 October 2013
Zebra Database...Insert Query Escape?
Zebra Database...Insert Query Escape?
I have two questions regarding mySQLi and hoping somebody can answer them!
1) Do you need to escape a query based on INSERT? E.g.
$query = "INSERT INTO users (username) VALUES (?)";
//Add to DB
if($stmt = $this->conn->prepare($query)) {
//Sanitize
$user = $this->conn->real_escape_string($username);
Where $this->conn->real_escape_string($username) is basically to a class
mySQLi's escape function.
2) In the event that you need to, how do you test that it successfully
escapes it, e.g. in Zebra Database?
http://stefangabos.ro/wp-content/docs/Zebra_Database/Zebra_Database/Zebra_Database.html#methodinsert
Because i don't seem to see the INSERT method on Zebra Database being
escaped when you insert using the query..
$db->insert('users', array('username' => $username, 'md5user' =>
$md5user, 'affiliate' => $affiliate, 'full_name' => $) );
It seems to only escape it if you have
array('username' => ?)
Any advise/thoughts?
Thanks!
I have two questions regarding mySQLi and hoping somebody can answer them!
1) Do you need to escape a query based on INSERT? E.g.
$query = "INSERT INTO users (username) VALUES (?)";
//Add to DB
if($stmt = $this->conn->prepare($query)) {
//Sanitize
$user = $this->conn->real_escape_string($username);
Where $this->conn->real_escape_string($username) is basically to a class
mySQLi's escape function.
2) In the event that you need to, how do you test that it successfully
escapes it, e.g. in Zebra Database?
http://stefangabos.ro/wp-content/docs/Zebra_Database/Zebra_Database/Zebra_Database.html#methodinsert
Because i don't seem to see the INSERT method on Zebra Database being
escaped when you insert using the query..
$db->insert('users', array('username' => $username, 'md5user' =>
$md5user, 'affiliate' => $affiliate, 'full_name' => $) );
It seems to only escape it if you have
array('username' => ?)
Any advise/thoughts?
Thanks!
Database won't delete
Database won't delete
A database appeared in Sql Server that I can't seem to get rid of. It is
empty, and I am not sure how it got there, but it may be because I have
been playing around with Sql Server Projects in VS, including publishing
them to Sql Server.
When I try to delete, it just hangs in SSMS, until I force the window to
close by closing SSMS.
Have tried taking it offline, and then backonline again, but still refuses
to delete.
Also tried restarting Sql Server but still won't delete.
It started out in Single User mode, so I switched it to multi-user mode,
but no luck.
Any suggestions?
Greg
A database appeared in Sql Server that I can't seem to get rid of. It is
empty, and I am not sure how it got there, but it may be because I have
been playing around with Sql Server Projects in VS, including publishing
them to Sql Server.
When I try to delete, it just hangs in SSMS, until I force the window to
close by closing SSMS.
Have tried taking it offline, and then backonline again, but still refuses
to delete.
Also tried restarting Sql Server but still won't delete.
It started out in Single User mode, so I switched it to multi-user mode,
but no luck.
Any suggestions?
Greg
How to efficiently network an application in Java
How to efficiently network an application in Java
I was wondering if someone could give me a clue. The situation is we have
one computer that has a server application, the rest have a client
application. Now my question is how would i keep track of the server ip
address? What I want is have the clients automatically hunt the server
application, regardless of the ip address and find it, because using a
wireless network computers are using DHCP. So I was wondering is there
anything that can be buried in a computer using Java with which other
computers can identify the application. Thanks.
I was wondering if someone could give me a clue. The situation is we have
one computer that has a server application, the rest have a client
application. Now my question is how would i keep track of the server ip
address? What I want is have the clients automatically hunt the server
application, regardless of the ip address and find it, because using a
wireless network computers are using DHCP. So I was wondering is there
anything that can be buried in a computer using Java with which other
computers can identify the application. Thanks.
change all synonyms to another database
change all synonyms to another database
I have production database (for example, PROD1). It has a lot of synonyms
to another databae (for example, PROD2).
I have created PROD2_TEST (as fully copy of PROD2) and also PROD1_TEST (as
full copy of PROD1). But as a result I have PROD1_TEST synonyms to PROD2,
instead of PROD2_TEST.
How, can I automatically recreate all synonyms to the test database?
(SQL SERVER 2008)
I have production database (for example, PROD1). It has a lot of synonyms
to another databae (for example, PROD2).
I have created PROD2_TEST (as fully copy of PROD2) and also PROD1_TEST (as
full copy of PROD1). But as a result I have PROD1_TEST synonyms to PROD2,
instead of PROD2_TEST.
How, can I automatically recreate all synonyms to the test database?
(SQL SERVER 2008)
Tuesday, 1 October 2013
What value to pass in ajaxFileUpload plugin?
What value to pass in ajaxFileUpload plugin?
I am using this plugin for my file upload:
http://www.phpletter.com/our-projects/ajaxfileupload/
and it says there that :
fileElementId: the file type of input element id and it will be the index
of $_FILES Array()
You have to pass the id of the element.
I have several input type file elements and their ids are unique, i do
this to get their ids:
var input_files = [];
$('.file_upload').each(function () {
if ($(this).val()) {
input_files.push($(this).attr('id'));
}
});
And shift the ids one by one to pass it to the ajaxFileUpload. But i get
an error saying:
Malformed multipart POST: data truncated
Can someone point me to what ive done wrong?
I am using this plugin for my file upload:
http://www.phpletter.com/our-projects/ajaxfileupload/
and it says there that :
fileElementId: the file type of input element id and it will be the index
of $_FILES Array()
You have to pass the id of the element.
I have several input type file elements and their ids are unique, i do
this to get their ids:
var input_files = [];
$('.file_upload').each(function () {
if ($(this).val()) {
input_files.push($(this).attr('id'));
}
});
And shift the ids one by one to pass it to the ajaxFileUpload. But i get
an error saying:
Malformed multipart POST: data truncated
Can someone point me to what ive done wrong?
How to add multiple Checkbox value to database
How to add multiple Checkbox value to database
I have a database named "student1905" where there is a table named
"programmata" where there is a column named "Periorismoi".
I have a page where there are some checkboxes. All i want to do is add the
value of the TICKED (selected) checkboxes into the column "Periorismoi"
with a "," between them. I am thinking of a function where variable named
"ids" will take all the values. And then ids will be added in the column.
But something is wrong and I cannot find it although I am googling like
hell. Here is a part of the code from the page with the checkboxes :
<form action="Insert4.php" method="POST" periorismoi="periorismoi">
<p>
<input type="checkbox" name="periorismoi[]" value="TRALALALA">ÐñïâëÞìáôá
¼ñáóçò<br>
<input type="checkbox" name="periorismoi[]" value="2">ÐñïâëÞìáôá ÁêïÞò<br>
<input type="checkbox" name="periorismoi[]" value="3">ÊéíçôéêÜ ÐñïâëÞìáôá
<br>
<input type="checkbox" name="periorismoi[]" value="4">ÓïâáñÝò êéíçôéêÝò
äéáôáñá÷Ýò (óå áíáðçñéêü êáñïôóÜêé)<br>
<input type="checkbox" name="periorismoi[]" value="5">ÊáôÜèëéøç<br>
<input type="checkbox" name="periorismoi[]" value="6">¢ã÷ïò<br>
<input type="checkbox" name="periorismoi[]" value="7">Äåí ìðïñåß íá ãñÜöåé
êáé íá äéáâÜæåé
</p>
<p align="center"><input type="submit" name="Submit" value="ÐÑÏÓÈÇÊÇ"></p>
<p align="left"> <br></p>
</form>
</body>
and here is the code from the Insert (to database) page I had at the
beginning which is wrong because it is putting at the database the
checkbox number:
$link = mysql_connect('localhost', 'student1905','123456');
mysql_select_db('student1905');
if(!$link)
{
die('Could not connect: ' . mysql_error());
}
else {
$periorismoi = $_POST['periorismoi'];
for($i=0; $i<sizeof($periorismoi);$i++){
$sql="INSERT INTO programmata (Auxon,Title,Periorismoi)
VALUES ('','$title','$periorismoi[$i]')";
mysql_query($sql);
}
header("Location:dokimastiko.php"); ;
}
?>
I tried to do that but it didnt work:
$i = 0;
$ids = "";
$first = true;
while(isset($_POST['periorismos[$i]']))
{
if($first) {
$first = false;
} else {
$ids += ","
}
$ids += $_POST['periorismos[$i]'];
$i++;
}
$link = mysql_connect('localhost', 'student1905','123456');
mysql_select_db('student1905');
if(!$link)
{
die('Could not connect: ' . mysql_error());
}
else {
mysql_query("SET NAMES utf8");
$sql = "INSERT INTO programmata (Auxon, Title, Periorismoi) VALUE
('','$title','$ids')";
mysql_query($sql);
header("Location:dokimastiko.php"); ;
}
I have a database named "student1905" where there is a table named
"programmata" where there is a column named "Periorismoi".
I have a page where there are some checkboxes. All i want to do is add the
value of the TICKED (selected) checkboxes into the column "Periorismoi"
with a "," between them. I am thinking of a function where variable named
"ids" will take all the values. And then ids will be added in the column.
But something is wrong and I cannot find it although I am googling like
hell. Here is a part of the code from the page with the checkboxes :
<form action="Insert4.php" method="POST" periorismoi="periorismoi">
<p>
<input type="checkbox" name="periorismoi[]" value="TRALALALA">ÐñïâëÞìáôá
¼ñáóçò<br>
<input type="checkbox" name="periorismoi[]" value="2">ÐñïâëÞìáôá ÁêïÞò<br>
<input type="checkbox" name="periorismoi[]" value="3">ÊéíçôéêÜ ÐñïâëÞìáôá
<br>
<input type="checkbox" name="periorismoi[]" value="4">ÓïâáñÝò êéíçôéêÝò
äéáôáñá÷Ýò (óå áíáðçñéêü êáñïôóÜêé)<br>
<input type="checkbox" name="periorismoi[]" value="5">ÊáôÜèëéøç<br>
<input type="checkbox" name="periorismoi[]" value="6">¢ã÷ïò<br>
<input type="checkbox" name="periorismoi[]" value="7">Äåí ìðïñåß íá ãñÜöåé
êáé íá äéáâÜæåé
</p>
<p align="center"><input type="submit" name="Submit" value="ÐÑÏÓÈÇÊÇ"></p>
<p align="left"> <br></p>
</form>
</body>
and here is the code from the Insert (to database) page I had at the
beginning which is wrong because it is putting at the database the
checkbox number:
$link = mysql_connect('localhost', 'student1905','123456');
mysql_select_db('student1905');
if(!$link)
{
die('Could not connect: ' . mysql_error());
}
else {
$periorismoi = $_POST['periorismoi'];
for($i=0; $i<sizeof($periorismoi);$i++){
$sql="INSERT INTO programmata (Auxon,Title,Periorismoi)
VALUES ('','$title','$periorismoi[$i]')";
mysql_query($sql);
}
header("Location:dokimastiko.php"); ;
}
?>
I tried to do that but it didnt work:
$i = 0;
$ids = "";
$first = true;
while(isset($_POST['periorismos[$i]']))
{
if($first) {
$first = false;
} else {
$ids += ","
}
$ids += $_POST['periorismos[$i]'];
$i++;
}
$link = mysql_connect('localhost', 'student1905','123456');
mysql_select_db('student1905');
if(!$link)
{
die('Could not connect: ' . mysql_error());
}
else {
mysql_query("SET NAMES utf8");
$sql = "INSERT INTO programmata (Auxon, Title, Periorismoi) VALUE
('','$title','$ids')";
mysql_query($sql);
header("Location:dokimastiko.php"); ;
}
Prime trios of the form $p$,$p+2$,$p+4$
Prime trios of the form $p$,$p+2$,$p+4$
My question is about number theory about the prime numbers.
Here is the question:
Prove that there is only one prime trio of the form $p$,$p+2$,$p+4$.
I mean,we can only find the primes 3,5,7
That satisfies the condition.
My question is about number theory about the prime numbers.
Here is the question:
Prove that there is only one prime trio of the form $p$,$p+2$,$p+4$.
I mean,we can only find the primes 3,5,7
That satisfies the condition.
Tomcat 7 clears edits made to context.xml on startup
Tomcat 7 clears edits made to context.xml on startup
This is probably a very n00b question since this is the first time I'm
using Tomcat. I'm trying to specify a JDNI resource in the
/conf/context.xml file. But every time I start up the server and have a
look at the file. Everything I edited in the file has disappeared and the
file reverted back the way it looked at the initial default installation
of Tomcat.
Note that I do have the server shutdown when I do these edits.. Why is
this happening?
This is probably a very n00b question since this is the first time I'm
using Tomcat. I'm trying to specify a JDNI resource in the
/conf/context.xml file. But every time I start up the server and have a
look at the file. Everything I edited in the file has disappeared and the
file reverted back the way it looked at the initial default installation
of Tomcat.
Note that I do have the server shutdown when I do these edits.. Why is
this happening?
Subscribe to:
Comments (Atom)