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?
Monday, 30 September 2013
Intersection of compact sets in the unit interval mathoverflow.net
Intersection of compact sets in the unit interval – mathoverflow.net
Let $\mathscr K$ be an uncountable set such that every $K\in\mathscr K$ is
a compact subset of $[0,1]$ with positive Lebesgue measure. Does it then
follow that there exists an uncountable $\mathscr …
Let $\mathscr K$ be an uncountable set such that every $K\in\mathscr K$ is
a compact subset of $[0,1]$ with positive Lebesgue measure. Does it then
follow that there exists an uncountable $\mathscr …
sudo visudo question
sudo visudo question
I am attempting to add the entry to 'visudo:
admin ALL=(ALL) /bin/kill
I have attempted to make changes to this in the past but crashed the
visudo file. Can someone assist in telling me where exactly the command
above should be placed?
I am attempting to add the entry to 'visudo:
admin ALL=(ALL) /bin/kill
I have attempted to make changes to this in the past but crashed the
visudo file. Can someone assist in telling me where exactly the command
above should be placed?
Firefox retina support for background images (mediaqueries)
Firefox retina support for background images (mediaqueries)
I developped several websites using mediaqueries for making them retina
ready. On firefox I now see that all background images (managed by
mediaqueries) are blurry, not retina ready.
Is this normal? Why firefox does not support the mediaqueries for
pixel-ration yet?
Ex:
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2) { ... }
Thanks for your help.
I developped several websites using mediaqueries for making them retina
ready. On firefox I now see that all background images (managed by
mediaqueries) are blurry, not retina ready.
Is this normal? Why firefox does not support the mediaqueries for
pixel-ration yet?
Ex:
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2) { ... }
Thanks for your help.
Sunday, 29 September 2013
Why IntelliJ builds Android APK that is incompatible with x86 architecture
Why IntelliJ builds Android APK that is incompatible with x86 architecture
Further to this post INSTALL_FAILED_CPU_ABI_INCOMPATIBLE on device using
intellij my IntelliJ 12.1.4 builds an Android APK that is incompatible
with the Samsung Galaxy Tab 3 10.1 as the CPU architecture for that device
is x86 rather than ARM.
I successfully got a build running by building on the command line (ant
clean debug) and installing the resulting APK via adb.
I'm trying to understand why IntelliJ is building an incompatible APK. I
searched the bug tracker and couldn't find an existing bug so I'm also
wondering how many people are also having this issue.
Further to this post INSTALL_FAILED_CPU_ABI_INCOMPATIBLE on device using
intellij my IntelliJ 12.1.4 builds an Android APK that is incompatible
with the Samsung Galaxy Tab 3 10.1 as the CPU architecture for that device
is x86 rather than ARM.
I successfully got a build running by building on the command line (ant
clean debug) and installing the resulting APK via adb.
I'm trying to understand why IntelliJ is building an incompatible APK. I
searched the bug tracker and couldn't find an existing bug so I'm also
wondering how many people are also having this issue.
Inheritance in CSS properties
Inheritance in CSS properties
Here, In this example I have two divisions where one is nested within
another. I'm calling the outer division a parent and the division which is
nested a child.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untilted</title>
<style type="text/css">
/* for parent div tag*/
#parent{
width: 500px;
height: 300px;
z-index: 1;
background-color: #CCC;
border:thin solid black;
margin:25px;
padding:20px;
}
/* for child div tag */
#child{
border:thin solid #F00;
height:50px;
background-color:#FFC;
}
</style>
</head>
<body>
<!-- Start of parent tag -->
<div id="parent">
<p> This is parent div tag. </p>
<!-- Child div tag -->
<div class="box">
<p> This is child div tag. </p>
</div>
<!-- End of parent tag. -->
</div>
</body>
</html>
It looks like this in the web browser:
My question is: How does the child div tag gets it's the size of it's
width? Is it because of inheritance from the parent div tag or is it just
by default behavior that it will expand up to the parent div container if
you don't specify a width?
Here, In this example I have two divisions where one is nested within
another. I'm calling the outer division a parent and the division which is
nested a child.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untilted</title>
<style type="text/css">
/* for parent div tag*/
#parent{
width: 500px;
height: 300px;
z-index: 1;
background-color: #CCC;
border:thin solid black;
margin:25px;
padding:20px;
}
/* for child div tag */
#child{
border:thin solid #F00;
height:50px;
background-color:#FFC;
}
</style>
</head>
<body>
<!-- Start of parent tag -->
<div id="parent">
<p> This is parent div tag. </p>
<!-- Child div tag -->
<div class="box">
<p> This is child div tag. </p>
</div>
<!-- End of parent tag. -->
</div>
</body>
</html>
It looks like this in the web browser:
My question is: How does the child div tag gets it's the size of it's
width? Is it because of inheritance from the parent div tag or is it just
by default behavior that it will expand up to the parent div container if
you don't specify a width?
How to import an XEN disk.raw VM into OracleVM
How to import an XEN disk.raw VM into OracleVM
I have two virtual machines running on an OpenSuse 12.3 Linux with XEN.
These VMs has disk.raw files with Linux running inside them. I'm trying to
use Oracle VM and want to get the two XEN disk.raw files imported to
Oracle VM hypervisor with OracleVM Manager and I couldn't do it. Whem I
google about this I found that Oracle VM is based on XEN. But I can't find
how to put my XEN VMs into Oracle VM.
Anyone could help me?
Thanks.
IOSJRUS
I have two virtual machines running on an OpenSuse 12.3 Linux with XEN.
These VMs has disk.raw files with Linux running inside them. I'm trying to
use Oracle VM and want to get the two XEN disk.raw files imported to
Oracle VM hypervisor with OracleVM Manager and I couldn't do it. Whem I
google about this I found that Oracle VM is based on XEN. But I can't find
how to put my XEN VMs into Oracle VM.
Anyone could help me?
Thanks.
IOSJRUS
Thread Pool Executor
Thread Pool Executor
I am working on changing legacy design with Thread Pool Executor. The
details are as follows:-
Legacy:- In case of legacy design 600 threads are created at the time of
application start up. and are placed in various pools, which are then
picked up when required and task is assigned to the corresponding thread.
New:- In new design i replaced the thread pool by executor service as
ThreadPoolExecutor thpool = new ThreadPoolExecutor(coreSize,poolsize,...);
What i am observing is that in case of Executor no threads are created at
the time of start up. They are created when request is fired from the
client. As a result of which threads created in memory are quite less as
compared to previous one.
But what my question is that is it right way because Thread creation is
also a overhead which is happening at the time of call is triggered.
Please tell which is more hevay process Thread creation at the time of
call from client or Idle threads being there in memory as per legacy
approach.
Also suggest which Executor pool to use in order to get best results in
terms of performance.
Thanks & Regards, Tushar
I am working on changing legacy design with Thread Pool Executor. The
details are as follows:-
Legacy:- In case of legacy design 600 threads are created at the time of
application start up. and are placed in various pools, which are then
picked up when required and task is assigned to the corresponding thread.
New:- In new design i replaced the thread pool by executor service as
ThreadPoolExecutor thpool = new ThreadPoolExecutor(coreSize,poolsize,...);
What i am observing is that in case of Executor no threads are created at
the time of start up. They are created when request is fired from the
client. As a result of which threads created in memory are quite less as
compared to previous one.
But what my question is that is it right way because Thread creation is
also a overhead which is happening at the time of call is triggered.
Please tell which is more hevay process Thread creation at the time of
call from client or Idle threads being there in memory as per legacy
approach.
Also suggest which Executor pool to use in order to get best results in
terms of performance.
Thanks & Regards, Tushar
Saturday, 28 September 2013
Creating a "database" in rails
Creating a "database" in rails
I have a rails 4 application where users define for example a tools
database and creates fields that store items like brand, year, etc. Then a
CRUD interface is presented before them, based on the fields they defined.
Right now I have a Database model that looks like this:
class Database < ActiveRecord::Base
has_many :fields
and a Field Model that looks like this:
class Field < ActiveRecord::Base
belongs_to :database
Basically, right now on the Add Fields page (which is after you have a
created a database and defined the fields), I'm creating a unique id and
storing that with all the fields on that page, which I then use to group
fields into a "row" (using a rails groupby statement).
I have two questions: 1. Is the most efficient way to implement a
"database"? 2. I can't figure out how to best link the field names you
define when you create the database with the fields in the CRUD interface.
So for example, If I create a name field when I'm initially defining all
of the fields, how can I have it associated with fields in the CRUD
interface?
Thanks for all help! If I need to clarify more, please tell!
I have a rails 4 application where users define for example a tools
database and creates fields that store items like brand, year, etc. Then a
CRUD interface is presented before them, based on the fields they defined.
Right now I have a Database model that looks like this:
class Database < ActiveRecord::Base
has_many :fields
and a Field Model that looks like this:
class Field < ActiveRecord::Base
belongs_to :database
Basically, right now on the Add Fields page (which is after you have a
created a database and defined the fields), I'm creating a unique id and
storing that with all the fields on that page, which I then use to group
fields into a "row" (using a rails groupby statement).
I have two questions: 1. Is the most efficient way to implement a
"database"? 2. I can't figure out how to best link the field names you
define when you create the database with the fields in the CRUD interface.
So for example, If I create a name field when I'm initially defining all
of the fields, how can I have it associated with fields in the CRUD
interface?
Thanks for all help! If I need to clarify more, please tell!
Normals inversion because of gluPerspercitve?
Normals inversion because of gluPerspercitve?
Just fooling around with opengl and glut. I was trying to make cube full
visibe so I decided that I could make it with gluPerspective(); So here's
the code
#include <iostream>
#include <GL/glut.h>
#include <GL/gl.h>
using namespace std;
float _angle = 0.1f;
void render(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluPerspective(90.0, 1, 0.1, 100.0);
gluLookAt(1, 1, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
glPushMatrix();
glRotatef(_angle, 0.0f,0.0f,1.0f);
glColor3f(1.0f,0.0f,0.0f);
glutSolidCube (1.0);
glPopMatrix();
_angle +=0.03f;
// check OpenGL error
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR) {
cerr << "OpenGL error: " << err << endl;
}
glutSwapBuffers();
glutPostRedisplay();
}
void init(){
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(640, 480);
glutCreateWindow("test");
glClearColor(0.2,0.2,0.2,0.0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glutDisplayFunc(render);
glutMainLoop();
}
int main(int argc, char * argv[]) {
glutInit(&argc, argv);
init();
return 0;
}
and that is result:
how part of cube looks without gluPerspective():
How can I make it looks normal?
Just fooling around with opengl and glut. I was trying to make cube full
visibe so I decided that I could make it with gluPerspective(); So here's
the code
#include <iostream>
#include <GL/glut.h>
#include <GL/gl.h>
using namespace std;
float _angle = 0.1f;
void render(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluPerspective(90.0, 1, 0.1, 100.0);
gluLookAt(1, 1, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
glPushMatrix();
glRotatef(_angle, 0.0f,0.0f,1.0f);
glColor3f(1.0f,0.0f,0.0f);
glutSolidCube (1.0);
glPopMatrix();
_angle +=0.03f;
// check OpenGL error
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR) {
cerr << "OpenGL error: " << err << endl;
}
glutSwapBuffers();
glutPostRedisplay();
}
void init(){
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(640, 480);
glutCreateWindow("test");
glClearColor(0.2,0.2,0.2,0.0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glutDisplayFunc(render);
glutMainLoop();
}
int main(int argc, char * argv[]) {
glutInit(&argc, argv);
init();
return 0;
}
and that is result:
how part of cube looks without gluPerspective():
How can I make it looks normal?
Direct link to app-store application in iOS 7
Direct link to app-store application in iOS 7
I have a free version of app. And there is a link to a full version in
free app. The link works fine in iOS 6. But in iOS 7 it shows a blank
page. Any help is appreciated!
The link I use:
- (void) getFull
{
[self hideAnimated];
NSString *iTunesLink =
@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=604760686&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL
URLWithString:iTunesLink]];
}
I have a free version of app. And there is a link to a full version in
free app. The link works fine in iOS 6. But in iOS 7 it shows a blank
page. Any help is appreciated!
The link I use:
- (void) getFull
{
[self hideAnimated];
NSString *iTunesLink =
@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=604760686&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL
URLWithString:iTunesLink]];
}
What is wrong with this insertion sort using linked list code in c?
What is wrong with this insertion sort using linked list code in c?
I am getting error while executing this. Compiler does not give any error
but when executed it give random output. Any help ? What am i doing is
taking input from user & storing them to linked list & then implimenting
insertion sort.
#include<stdio.h>
#include<stdlib.h>
struct node
{
int info;
struct node *next;
};
typedef struct node *NODEPTR;
NODEPTR getnode();
NODEPTR insertionSortLinkedList(NODEPTR head);
int main()
{
int i,n,temp;
NODEPTR head,lptr,prevlptr;
printf("No of input integers to be sorted\n");
scanf("%d",&n);
if (n<2){printf("n should be atleast 2 \n");return 0;}
printf("\nType space-separated array of %d integers\n",n);
scanf("%d",&temp);
head=getnode();
head->info=temp;
head->next=NULL;
prevlptr=head;
for (i=0;i<n-1;i++)
{
scanf("%d",&temp);
lptr=getnode();
lptr->info=temp;
prevlptr->next=lptr;
lptr->next=NULL;
prevlptr=lptr;
}
head=insertionSortLinkedList(head);
lptr=head;
while(lptr!=NULL)
{
printf("%d ",lptr->info);
prevlptr=lptr;
lptr=lptr->next;
free(prevlptr);
}
return 0;
}
NODEPTR getnode()
{
NODEPTR p;
p=(struct node*)malloc(sizeof(struct node));
return p;
}
NODEPTR insertionSort(NODEPTR head)
{
NODEPTR listptr,tempptr,prevptr,prevtempptr;
prevptr=head;
listptr=prevptr->next;
while(listptr!=NULL)
{
while (listptr->info < prevptr->info)
{
prevptr->next=listptr->next;
tempptr=head;
prevtempptr=head;
while(tempptr->info <= listptr->info)
{
prevtempptr=tempptr;
tempptr=tempptr->next;
}
if(tempptr->info == prevtempptr->info)
{
listptr->next=head;
head=listptr;
}
else
{e
listptr->next=prevtempptr->next;
prevtempptr->next=listptr;
}
listptr=prevptr->next;
if (listptr==NULL)
break;
}
prevptr=prevptr->next;
if (prevptr=NULL)
break;
listptr=prevptr->next;
}
return(head);
}
I am getting error while executing this. Compiler does not give any error
but when executed it give random output. Any help ? What am i doing is
taking input from user & storing them to linked list & then implimenting
insertion sort.
#include<stdio.h>
#include<stdlib.h>
struct node
{
int info;
struct node *next;
};
typedef struct node *NODEPTR;
NODEPTR getnode();
NODEPTR insertionSortLinkedList(NODEPTR head);
int main()
{
int i,n,temp;
NODEPTR head,lptr,prevlptr;
printf("No of input integers to be sorted\n");
scanf("%d",&n);
if (n<2){printf("n should be atleast 2 \n");return 0;}
printf("\nType space-separated array of %d integers\n",n);
scanf("%d",&temp);
head=getnode();
head->info=temp;
head->next=NULL;
prevlptr=head;
for (i=0;i<n-1;i++)
{
scanf("%d",&temp);
lptr=getnode();
lptr->info=temp;
prevlptr->next=lptr;
lptr->next=NULL;
prevlptr=lptr;
}
head=insertionSortLinkedList(head);
lptr=head;
while(lptr!=NULL)
{
printf("%d ",lptr->info);
prevlptr=lptr;
lptr=lptr->next;
free(prevlptr);
}
return 0;
}
NODEPTR getnode()
{
NODEPTR p;
p=(struct node*)malloc(sizeof(struct node));
return p;
}
NODEPTR insertionSort(NODEPTR head)
{
NODEPTR listptr,tempptr,prevptr,prevtempptr;
prevptr=head;
listptr=prevptr->next;
while(listptr!=NULL)
{
while (listptr->info < prevptr->info)
{
prevptr->next=listptr->next;
tempptr=head;
prevtempptr=head;
while(tempptr->info <= listptr->info)
{
prevtempptr=tempptr;
tempptr=tempptr->next;
}
if(tempptr->info == prevtempptr->info)
{
listptr->next=head;
head=listptr;
}
else
{e
listptr->next=prevtempptr->next;
prevtempptr->next=listptr;
}
listptr=prevptr->next;
if (listptr==NULL)
break;
}
prevptr=prevptr->next;
if (prevptr=NULL)
break;
listptr=prevptr->next;
}
return(head);
}
Subscribe to:
Posts (Atom)