Jquery get the id of clicked element and show hidden child div
i have an array of comments, and it should be possible to answer the comment.
<div>
<a href="#" class="answerBtn" id="<?=$comment->id ?>">Answer</a>
<div id="answerDiv" style="display:none;">
<form action="" method="POST">
<input type="hidden" value="<?=$comment->id ?>"/>
<p>
<label>Your name*</label>
<br />
<input type="text" name="answer_username"
id="answer_username" required />
</p>
<p>
<label>Your Email (optional)</label>
<br />
<input type="text" name="answer_email" />
</p>
<p>
<label>Your comment*</label>
<br />
<textarea name="answer_message" required></textarea>
</p>
<input type="hidden" value="<?=base_url()?>"
id="answer_baseurl"/>
<input type="submit" value="Send"/>
</form>
</div>
i want to display the form when clicking the link, but because each
comment has the same form i have to be specific, so i want to show the
form depending on the id of the comment. so i tried something like this
with jquery:
$('.answerBtn').click(function(){
var id = $(this).attr('id');
$('id + div').slideToggle();
});
but that doesn't really work...
can someone help me out?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Why SQLSTATE[42000]: Syntax error or access violation?
Why SQLSTATE[42000]: Syntax error or access violation?
I would like to run this Doctrine Query Builder query:
$repository = $this->getDoctrine()->getRepository('MyBundle:Usage');
$warranty_usage = $repository->createQueryBuilder('u')->where('u.var =
\'warranty\'')->getQuery()->getSingleResult();
But I always get:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'Usage u0_ WHERE u0_.var =
'warranty'' at line 1
This is my Usage entity:
<?php
namespace Herbanist\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Usage
*
* @ORM\Table()
* @ORM\Entity
*/
class Usage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="var", type="string", length=20)
*/
private $var;
/**
* @var string
*
* @ORM\Column(name="value", type="text")
*/
private $value;
public function getId()
{
return $this->id;
}
public function setVar($var)
{
$this->var = $var;
return $this;
}
public function getVar()
{
return $this->var;
}
public function setValue($value)
{
$this->value = $value;
return $this;
}
public function getValue()
{
return $this->value;
}
}
Usage table:
mysql> select * from `Usage`;
+----+----------+-------+
| id | var | value |
+----+----------+-------+
| 1 | warranty | 0 |
+----+----------+-------+
I would like to run this Doctrine Query Builder query:
$repository = $this->getDoctrine()->getRepository('MyBundle:Usage');
$warranty_usage = $repository->createQueryBuilder('u')->where('u.var =
\'warranty\'')->getQuery()->getSingleResult();
But I always get:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'Usage u0_ WHERE u0_.var =
'warranty'' at line 1
This is my Usage entity:
<?php
namespace Herbanist\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Usage
*
* @ORM\Table()
* @ORM\Entity
*/
class Usage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="var", type="string", length=20)
*/
private $var;
/**
* @var string
*
* @ORM\Column(name="value", type="text")
*/
private $value;
public function getId()
{
return $this->id;
}
public function setVar($var)
{
$this->var = $var;
return $this;
}
public function getVar()
{
return $this->var;
}
public function setValue($value)
{
$this->value = $value;
return $this;
}
public function getValue()
{
return $this->value;
}
}
Usage table:
mysql> select * from `Usage`;
+----+----------+-------+
| id | var | value |
+----+----------+-------+
| 1 | warranty | 0 |
+----+----------+-------+
C++ Main file does not display everything
C++ Main file does not display everything
My program read a *.txt file and prints a line from the file backwards. i
wanted to get the linenumber before it does so. after doing the loop, i
got my number, but everything after my "for loop" is not printing/
working. what is wrong with my code?
#include "oneLine.h"
#include <iostream>
#include <fstream>
using namespace std;
int main () {
OneLine aline;
ifstream testFile ("test.txt");
if (testFile.good()) {
int countLines = 0;
string temp;
for (int i = 0; getline(testFile, temp); i++)
countLines++;
cout << countLines;
aline.readLine(testFile);
aline.breakLine();
aline.printReverse();
//int a = aline.totalLines(testFile);
} else {
cout << "Error: Invalid File.";
}
return 0;
}
My program read a *.txt file and prints a line from the file backwards. i
wanted to get the linenumber before it does so. after doing the loop, i
got my number, but everything after my "for loop" is not printing/
working. what is wrong with my code?
#include "oneLine.h"
#include <iostream>
#include <fstream>
using namespace std;
int main () {
OneLine aline;
ifstream testFile ("test.txt");
if (testFile.good()) {
int countLines = 0;
string temp;
for (int i = 0; getline(testFile, temp); i++)
countLines++;
cout << countLines;
aline.readLine(testFile);
aline.breakLine();
aline.printReverse();
//int a = aline.totalLines(testFile);
} else {
cout << "Error: Invalid File.";
}
return 0;
}
Access a database from a DialogFragment and toast a message
Access a database from a DialogFragment and toast a message
I have a DialogFragment which displays a simple yes/no question. When the
user presses "yes", I perform a database request (which basicaly deletes
an entry). I then toast a message to report a success or failure to the
user.
I try to avoid calling the database from the UI thread, so I created a
thread which will delete the entry, and from that thread I call a handler
in the DialogFragment to display the toast message.
My problem is that when the user presses the button, the thread is started
and the dialog is closed. As the thread is started, the data is deleted
from the database. But when I toast my message from the handler, the
DialogFragment is already detached from the parent Activity so I don't
have a context anymore to call Toast.makeText().
My question is how can I toast the message ?
I know I could create a Service to handle the database operation, but
wouldn't it be too much hassle ? Is there a simpler way ?
Thanks !
I have a DialogFragment which displays a simple yes/no question. When the
user presses "yes", I perform a database request (which basicaly deletes
an entry). I then toast a message to report a success or failure to the
user.
I try to avoid calling the database from the UI thread, so I created a
thread which will delete the entry, and from that thread I call a handler
in the DialogFragment to display the toast message.
My problem is that when the user presses the button, the thread is started
and the dialog is closed. As the thread is started, the data is deleted
from the database. But when I toast my message from the handler, the
DialogFragment is already detached from the parent Activity so I don't
have a context anymore to call Toast.makeText().
My question is how can I toast the message ?
I know I could create a Service to handle the database operation, but
wouldn't it be too much hassle ? Is there a simpler way ?
Thanks !
Tuesday, 1 October 2013
PHP/SQL Where, And, Order By -- works on one statement but getting an error on another similar query
PHP/SQL Where, And, Order By -- works on one statement but getting an
error on another similar query
I'm trying to add a section that shows if any year end awards are won by
an individual. I have any Champions and Reserve Champions showing just
fine. However, when I went to add the "year end awards" section I keep
getting this error:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'show = yearend
ORDER BY year DESC' at line 1
I have played around with apostrphes, using a LIKE statement, removing the
ORDER BY, and anything I could think of but I am at a loss. I can't seem
to figure out what changed from the working statements that would cause an
error.
This works just fine
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND place = 'CH'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<small>(";
echo $row['show'];
echo ")</small><br>";
}
?>
This does not work The only change I made in the below is place = is now
show =
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND show = 'yearend'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<br>";
}
?>
error on another similar query
I'm trying to add a section that shows if any year end awards are won by
an individual. I have any Champions and Reserve Champions showing just
fine. However, when I went to add the "year end awards" section I keep
getting this error:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'show = yearend
ORDER BY year DESC' at line 1
I have played around with apostrphes, using a LIKE statement, removing the
ORDER BY, and anything I could think of but I am at a loss. I can't seem
to figure out what changed from the working statements that would cause an
error.
This works just fine
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND place = 'CH'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<small>(";
echo $row['show'];
echo ")</small><br>";
}
?>
This does not work The only change I made in the below is place = is now
show =
<?php
$id = $_GET['id']; //Gets the ID from the URL
$result = mysql_query("SELECT * FROM competition
WHERE id = $id
AND show = 'yearend'
ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['class'];
echo "<br>";
}
?>
How to change screen color temperature using C++?
How to change screen color temperature using C++?
How would I change the color temperature / hue of the current screen in a
Windows C++ program? I know this is possible but am not sure where to
start.
How would I change the color temperature / hue of the current screen in a
Windows C++ program? I know this is possible but am not sure where to
start.
Unknowingly improving my players' luck rpg.stackexchange.com
Unknowingly improving my players' luck – rpg.stackexchange.com
As a GM, I'd like to give my players a lucky item, one that improves their
dice rolls. However, I don't want them to immediately realize that the
item is improving their rolls. One thought I had was …
As a GM, I'd like to give my players a lucky item, one that improves their
dice rolls. However, I don't want them to immediately realize that the
item is improving their rolls. One thought I had was …
Getting the widget toolkit for a particular window
Getting the widget toolkit for a particular window
Is there a way to get the widget toolkit used to draw a particular window?
Something like xprop or xwininfo that will show it to be GTK+, Qt or
similar.
Is there a way to get the widget toolkit used to draw a particular window?
Something like xprop or xwininfo that will show it to be GTK+, Qt or
similar.
Monday, 30 September 2013
Apache - SSL Requests Stop working after a while
Apache - SSL Requests Stop working after a while
I have Apache 2.4.2, OpenSSL/1.0.1c, on Windows Web Server 2008 R2 (64 bits)
After 12 hours of heavier load, the SSL requests stopped working/being
answered. However if you requested the same page via http instead of
https, it worked fine. Restarting the Apache server fixes this, for a
while. Again after a few hours of traffic, the https requests stopped
working again. I checked the logs, and nothing notable, the mod_ssl
entries just...
The site is called only by client developed with Delphi 2007 (CodeGear
user-agent). Delphi client use THTTPRIO for sending HTTPS request to SOAP.
Any ideas?
httpd.conf
AcceptFilter http none
# AcceptFilter https none # (try to uncomment, but ssl stop work)
EnableMMAP off
EnableSendfile off
httpd-ssl.conf
Listen 443
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:logs/ssl.scache(512000)"
SSLSessionCacheTimeout 600
httpd-vhosts.conf
<VirtualHost 192.168.1.76:443>
DocumentRoot "C:/xampp/htdocs/mysite/"
ServerName secure.mysite.com:443
SSLEngine on
SSLProtocol -all +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
SSLCertificateFile conf/ssl.crt/secure.mysite.com.cer
SSLCertificateKeyFile conf/ssl.key/secure.mysite.com.rsa.key
SSLVerifyClient none
SSLProxyEngine off
BrowserMatch ".*CodeGear.*" nokeepalive ssl-unclean-shutdown downgrade-1.0
force-response-1.0
BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0
force-response-1.0
LogLevel trace6
ErrorLog "|bin/rotatelogs.exe logs/secure_mysite_com/%Y-%m-%d-error.log
86400"
CustomLog "|bin/rotatelogs.exe logs/secure_mysite_com/%Y-%m-%d-access.log
86400" combined
<directory "C:/xampp/htdocs/mysite/">
Options FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</directory>
# CGI #
<Directory "C:/xampp/htdocs/mysite/CodeGearSOAP_EXE/">
SetHandler cgi-script
AllowOverride None
Options ExecCGI
</Directory>
</VirtualHost>
TRACE LOG OF ONE SOAP REQUEST
access.log
xxx.xxx.xxx.xxx - - [27/Sep/2013:18:44:45 +0200] "POST
/CodeGearSOAP_EXE/soap.exe HTTP/1.1" 200 4882 "-" "CodeGear SOAP 1.3"
error.log
[Fri Sep 27 18:44:45.307377 2013] [ssl:info] [pid 1304:tid 1848] [client
xxx.xxx.xxx.xxx:20395] AH01964: Connection to child 141 established
(server secure.mysite.com:443)
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace2] [pid 1304:tid 1848]
ssl_engine_rand.c(123): Seeding PRNG with 144 bytes of entropy
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1841): [client xxx.xxx.xxx.xxx:20395] OpenSSL:
Handshake: start
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
before/accept initialization
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 11/11
bytes from BIO#126bbf0 [mem: 80152a0] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read
157/157 bytes from BIO#126bbf0 [mem: 80152ae] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [socache_shmcb:debug] [pid 1304:tid
1848] mod_socache_shmcb.c(512): AH00835: socache_shmcb_retrieve (0x35 ->
subcache 21)
[Fri Sep 27 18:44:45.307377 2013] [socache_shmcb:debug] [pid 1304:tid
1848] mod_socache_shmcb.c(836): AH00849: match at idx=0, data=0
[Fri Sep 27 18:44:45.307377 2013] [socache_shmcb:debug] [pid 1304:tid
1848] mod_socache_shmcb.c(523): AH00836: leaving socache_shmcb_retrieve
successfully
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace2] [pid 1304:tid 1848]
ssl_engine_kernel.c(1697): Inter-Process Session Cache: request=GET
status=FOUND
id=356A6FAB37A0E2729FBEEFAB028CA5C57F799A7F024CD6F037FAB7C9EB6C5010
(session reuse)
[Fri Sep 27 18:44:45.307377 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_kernel.c(1960): [client xxx.xxx.xxx.xxx:20395] AH02043: SSL
virtual host for servername secure.mysite.com found
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 read client hello A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 write server hello A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 write change cipher spec A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 write finished A
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 flush data
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 1/1
bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 48/48
bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 read finished A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1845): [client xxx.xxx.xxx.xxx:20395] OpenSSL:
Handshake: done
[Fri Sep 27 18:44:45.307377 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_kernel.c(1890): [client xxx.xxx.xxx.xxx:20395] AH02041:
Protocol: TLSv1, Cipher: AES128-SHA (128/128 bits)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read
544/544 bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace5] [pid 1304:tid 1848]
protocol.c(625): [client xxx.xxx.xxx.xxx:20395] Request received from
client: POST /soap/SOAP.exe HTTP/1.1
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting nokeepalive
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting
ssl-unclean-shutdown
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting downgrade-1.0
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting
force-response-1.0
[Fri Sep 27 18:44:45.307377 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_kernel.c(236): [client xxx.xxx.xxx.xxx:20395] AH02034: Initial
(No.1) HTTPS request received for child 141 (server secure.mysite.com:443)
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(300): [client xxx.xxx.xxx.xxx:20395] Headers received from
client:
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] MIME-Version: 1.0
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] SOAPAction:
\\"urn:SoapServerIntf-ISoapServer#SoapCommand\\"
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Content-Type:
multipart/related; boundary=MIME_boundaryB0R9532143182121
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] User-Agent: CodeGear
SOAP 1.3
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Host:
secure.mysite.com
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Content-Length: 4672
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Connection:
Keep-Alive
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Cache-Control:
no-cache
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Cookie:
SS_STRINGHELINGUA=IT;
__utma=10233637.1711321739.1377762381.1377762381.1377765561.2;
__utmz=10233637.1377762381.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
[Fri Sep 27 18:44:45.307377 2013] [authz_core:debug] [pid 1304:tid 1848]
mod_authz_core.c(808): [client xxx.xxx.xxx.xxx:20395] AH01628:
authorization result: granted (no directives)
[Fri Sep 27 18:44:45.307377 2013] [core:trace3] [pid 1304:tid 1848]
request.c(225): [client xxx.xxx.xxx.xxx:20395] request authorized without
authentication by access_checker_ex hook: /soap/SOAP.exe
[Fri Sep 27 18:44:45.307377 2013] [authz_core:debug] [pid 1304:tid 1848]
mod_authz_core.c(808): [client xxx.xxx.xxx.xxx:20395] AH01628:
authorization result: granted (no directives)
[Fri Sep 27 18:44:45.307377 2013] [core:trace3] [pid 1304:tid 1848]
request.c(225): [client xxx.xxx.xxx.xxx:20395] request authorized without
authentication by access_checker_ex hook: /soap/ISoapServer
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read
4704/4704 bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(519): [client xxx.xxx.xxx.xxx:20395] Headers from script
'SOAP.exe':
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Status: 200 OK
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace1] [pid 1304:tid 1848]
util_script.c(597): [client xxx.xxx.xxx.xxx:20395] Status line from script
'SOAP.exe': Status
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content-Version:
MIME-Version: 1.0
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content-Type:
multipart/related; boundary=MIME_boundaryB0R9532143182121;
start="<http://www.borland.com/rootpart.xml>"
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content-Length: 4882
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content:
[Fri Sep 27 18:44:45.400977 2013] [http:trace3] [pid 1304:tid 1848]
http_filters.c(960): [client xxx.xxx.xxx.xxx:20395] Response sent with
status 200, headers:
[Fri Sep 27 18:44:45.400977 2013] [http:trace5] [pid 1304:tid 1848]
http_filters.c(969): [client xxx.xxx.xxx.xxx:20395] Date: Fri, 27 Sep
2013 16:44:45 GMT
[Fri Sep 27 18:44:45.400977 2013] [http:trace5] [pid 1304:tid 1848]
http_filters.c(972): [client xxx.xxx.xxx.xxx:20395] Server: Apache/2.4.2
(Win32) OpenSSL/1.0.1c PHP/5.4.4
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content-Version:
MIME-Version: 1.0
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content:
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content-Length: 4882
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Connection: close
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content-Type:
multipart/related; boundary=MIME_boundaryB0R9532143182121;
start=\\"<http://www.borland.com/rootpart.xml>\\"
[Fri Sep 27 18:44:45.400977 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1439): [client xxx.xxx.xxx.xxx:20395] coalesce: have 0
bytes, adding 319 more
[Fri Sep 27 18:44:45.400977 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.432177 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.478978 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.478978 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.478978 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_io.c(984): [client xxx.xxx.xxx.xxx:20395] AH01999: Connection
closed to child 141 with unclean shutdown (server secure.mysite.com:443)
I have Apache 2.4.2, OpenSSL/1.0.1c, on Windows Web Server 2008 R2 (64 bits)
After 12 hours of heavier load, the SSL requests stopped working/being
answered. However if you requested the same page via http instead of
https, it worked fine. Restarting the Apache server fixes this, for a
while. Again after a few hours of traffic, the https requests stopped
working again. I checked the logs, and nothing notable, the mod_ssl
entries just...
The site is called only by client developed with Delphi 2007 (CodeGear
user-agent). Delphi client use THTTPRIO for sending HTTPS request to SOAP.
Any ideas?
httpd.conf
AcceptFilter http none
# AcceptFilter https none # (try to uncomment, but ssl stop work)
EnableMMAP off
EnableSendfile off
httpd-ssl.conf
Listen 443
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:logs/ssl.scache(512000)"
SSLSessionCacheTimeout 600
httpd-vhosts.conf
<VirtualHost 192.168.1.76:443>
DocumentRoot "C:/xampp/htdocs/mysite/"
ServerName secure.mysite.com:443
SSLEngine on
SSLProtocol -all +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
SSLCertificateFile conf/ssl.crt/secure.mysite.com.cer
SSLCertificateKeyFile conf/ssl.key/secure.mysite.com.rsa.key
SSLVerifyClient none
SSLProxyEngine off
BrowserMatch ".*CodeGear.*" nokeepalive ssl-unclean-shutdown downgrade-1.0
force-response-1.0
BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0
force-response-1.0
LogLevel trace6
ErrorLog "|bin/rotatelogs.exe logs/secure_mysite_com/%Y-%m-%d-error.log
86400"
CustomLog "|bin/rotatelogs.exe logs/secure_mysite_com/%Y-%m-%d-access.log
86400" combined
<directory "C:/xampp/htdocs/mysite/">
Options FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</directory>
# CGI #
<Directory "C:/xampp/htdocs/mysite/CodeGearSOAP_EXE/">
SetHandler cgi-script
AllowOverride None
Options ExecCGI
</Directory>
</VirtualHost>
TRACE LOG OF ONE SOAP REQUEST
access.log
xxx.xxx.xxx.xxx - - [27/Sep/2013:18:44:45 +0200] "POST
/CodeGearSOAP_EXE/soap.exe HTTP/1.1" 200 4882 "-" "CodeGear SOAP 1.3"
error.log
[Fri Sep 27 18:44:45.307377 2013] [ssl:info] [pid 1304:tid 1848] [client
xxx.xxx.xxx.xxx:20395] AH01964: Connection to child 141 established
(server secure.mysite.com:443)
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace2] [pid 1304:tid 1848]
ssl_engine_rand.c(123): Seeding PRNG with 144 bytes of entropy
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1841): [client xxx.xxx.xxx.xxx:20395] OpenSSL:
Handshake: start
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
before/accept initialization
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 11/11
bytes from BIO#126bbf0 [mem: 80152a0] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read
157/157 bytes from BIO#126bbf0 [mem: 80152ae] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [socache_shmcb:debug] [pid 1304:tid
1848] mod_socache_shmcb.c(512): AH00835: socache_shmcb_retrieve (0x35 ->
subcache 21)
[Fri Sep 27 18:44:45.307377 2013] [socache_shmcb:debug] [pid 1304:tid
1848] mod_socache_shmcb.c(836): AH00849: match at idx=0, data=0
[Fri Sep 27 18:44:45.307377 2013] [socache_shmcb:debug] [pid 1304:tid
1848] mod_socache_shmcb.c(523): AH00836: leaving socache_shmcb_retrieve
successfully
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace2] [pid 1304:tid 1848]
ssl_engine_kernel.c(1697): Inter-Process Session Cache: request=GET
status=FOUND
id=356A6FAB37A0E2729FBEEFAB028CA5C57F799A7F024CD6F037FAB7C9EB6C5010
(session reuse)
[Fri Sep 27 18:44:45.307377 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_kernel.c(1960): [client xxx.xxx.xxx.xxx:20395] AH02043: SSL
virtual host for servername secure.mysite.com found
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 read client hello A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 write server hello A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 write change cipher spec A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 write finished A
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 flush data
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 1/1
bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 48/48
bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1849): [client xxx.xxx.xxx.xxx:20395] OpenSSL: Loop:
SSLv3 read finished A
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace3] [pid 1304:tid 1848]
ssl_engine_kernel.c(1845): [client xxx.xxx.xxx.xxx:20395] OpenSSL:
Handshake: done
[Fri Sep 27 18:44:45.307377 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_kernel.c(1890): [client xxx.xxx.xxx.xxx:20395] AH02041:
Protocol: TLSv1, Cipher: AES128-SHA (128/128 bits)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read
544/544 bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace5] [pid 1304:tid 1848]
protocol.c(625): [client xxx.xxx.xxx.xxx:20395] Request received from
client: POST /soap/SOAP.exe HTTP/1.1
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting nokeepalive
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting
ssl-unclean-shutdown
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting downgrade-1.0
[Fri Sep 27 18:44:45.307377 2013] [setenvif:trace2] [pid 1304:tid 1848]
mod_setenvif.c(623): [client xxx.xxx.xxx.xxx:20395] Setting
force-response-1.0
[Fri Sep 27 18:44:45.307377 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_kernel.c(236): [client xxx.xxx.xxx.xxx:20395] AH02034: Initial
(No.1) HTTPS request received for child 141 (server secure.mysite.com:443)
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(300): [client xxx.xxx.xxx.xxx:20395] Headers received from
client:
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] MIME-Version: 1.0
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] SOAPAction:
\\"urn:SoapServerIntf-ISoapServer#SoapCommand\\"
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Content-Type:
multipart/related; boundary=MIME_boundaryB0R9532143182121
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] User-Agent: CodeGear
SOAP 1.3
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Host:
secure.mysite.com
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Content-Length: 4672
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Connection:
Keep-Alive
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Cache-Control:
no-cache
[Fri Sep 27 18:44:45.307377 2013] [http:trace4] [pid 1304:tid 1848]
http_request.c(303): [client xxx.xxx.xxx.xxx:20395] Cookie:
SS_STRINGHELINGUA=IT;
__utma=10233637.1711321739.1377762381.1377762381.1377765561.2;
__utmz=10233637.1377762381.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
[Fri Sep 27 18:44:45.307377 2013] [authz_core:debug] [pid 1304:tid 1848]
mod_authz_core.c(808): [client xxx.xxx.xxx.xxx:20395] AH01628:
authorization result: granted (no directives)
[Fri Sep 27 18:44:45.307377 2013] [core:trace3] [pid 1304:tid 1848]
request.c(225): [client xxx.xxx.xxx.xxx:20395] request authorized without
authentication by access_checker_ex hook: /soap/SOAP.exe
[Fri Sep 27 18:44:45.307377 2013] [authz_core:debug] [pid 1304:tid 1848]
mod_authz_core.c(808): [client xxx.xxx.xxx.xxx:20395] AH01628:
authorization result: granted (no directives)
[Fri Sep 27 18:44:45.307377 2013] [core:trace3] [pid 1304:tid 1848]
request.c(225): [client xxx.xxx.xxx.xxx:20395] request authorized without
authentication by access_checker_ex hook: /soap/ISoapServer
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read 5/5
bytes from BIO#126bbf0 [mem: 80152a3] (BIO dump follows)
[Fri Sep 27 18:44:45.307377 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.307377 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1989): [client xxx.xxx.xxx.xxx:20395] OpenSSL: read
4704/4704 bytes from BIO#126bbf0 [mem: 80152a8] (BIO dump follows)
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(519): [client xxx.xxx.xxx.xxx:20395] Headers from script
'SOAP.exe':
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Status: 200 OK
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace1] [pid 1304:tid 1848]
util_script.c(597): [client xxx.xxx.xxx.xxx:20395] Status line from script
'SOAP.exe': Status
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content-Version:
MIME-Version: 1.0
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content-Type:
multipart/related; boundary=MIME_boundaryB0R9532143182121;
start="<http://www.borland.com/rootpart.xml>"
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content-Length: 4882
[Fri Sep 27 18:44:45.400977 2013] [cgi:trace4] [pid 1304:tid 1848]
util_script.c(522): [client xxx.xxx.xxx.xxx:20395] Content:
[Fri Sep 27 18:44:45.400977 2013] [http:trace3] [pid 1304:tid 1848]
http_filters.c(960): [client xxx.xxx.xxx.xxx:20395] Response sent with
status 200, headers:
[Fri Sep 27 18:44:45.400977 2013] [http:trace5] [pid 1304:tid 1848]
http_filters.c(969): [client xxx.xxx.xxx.xxx:20395] Date: Fri, 27 Sep
2013 16:44:45 GMT
[Fri Sep 27 18:44:45.400977 2013] [http:trace5] [pid 1304:tid 1848]
http_filters.c(972): [client xxx.xxx.xxx.xxx:20395] Server: Apache/2.4.2
(Win32) OpenSSL/1.0.1c PHP/5.4.4
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content-Version:
MIME-Version: 1.0
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content:
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content-Length: 4882
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Connection: close
[Fri Sep 27 18:44:45.400977 2013] [http:trace4] [pid 1304:tid 1848]
http_filters.c(804): [client xxx.xxx.xxx.xxx:20395] Content-Type:
multipart/related; boundary=MIME_boundaryB0R9532143182121;
start=\\"<http://www.borland.com/rootpart.xml>\\"
[Fri Sep 27 18:44:45.400977 2013] [ssl:trace4] [pid 1304:tid 1848]
ssl_engine_io.c(1439): [client xxx.xxx.xxx.xxx:20395] coalesce: have 0
bytes, adding 319 more
[Fri Sep 27 18:44:45.400977 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.432177 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.478978 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.478978 2013] [core:trace6] [pid 1304:tid 1848]
core_filters.c(527): [client xxx.xxx.xxx.xxx:20395] core_output_filter:
flushing because of FLUSH bucket
[Fri Sep 27 18:44:45.478978 2013] [ssl:debug] [pid 1304:tid 1848]
ssl_engine_io.c(984): [client xxx.xxx.xxx.xxx:20395] AH01999: Connection
closed to child 141 with unclean shutdown (server secure.mysite.com:443)
How can I get my wirless adapter to work on Ubuntu 12.04 (Precise Pangolin)?
How can I get my wirless adapter to work on Ubuntu 12.04 (Precise Pangolin)?
I would really like to run Ubuntu on my main computer as a secondary OS.
The only problem is that my Rosewill rnx-600ube wireless adapter will not
function properly on Ubuntu. I can detect networks, but the computer will
not connect once the password is typed in. Is this a problem with the
rt2800 module my device uses? Or does it seem to be my router denying my
computer access and could it be fixed by connecting via WPS?
I would really like to run Ubuntu on my main computer as a secondary OS.
The only problem is that my Rosewill rnx-600ube wireless adapter will not
function properly on Ubuntu. I can detect networks, but the computer will
not connect once the password is typed in. Is this a problem with the
rt2800 module my device uses? Or does it seem to be my router denying my
computer access and could it be fixed by connecting via WPS?
Java program to deal with a "pair" of numbers?
Java program to deal with a "pair" of numbers?
I need help. For this exercise you will implement a class called Pair,
that represents a pair of two numbers.The Pair class should include the
following constructor and methods:
CONSTRUCTORS public Pair(double num1, double num2) -- Creates an object
that represents a pair of double values
METHODS public double getAverage() -- Returns the average value of the two
numbers
public double getDistance() -- Returns the absolute vale of the distance
between the two numbers
public double getMaximum() -- Returns the maximum value of the two numbers
public double getMinimum() -- Returns the minimum vale of the two numbers
Write a class called PairTest that tests your Pair implementation. The
PairTest should prompt the user for the two values, create a Pair object
with the values and then print the average, distance, maximum, and minimum
of the pair. The input / output should look like the following:
Enter the first number: 5.5 Enter the second number: 3.0
Average: 4.25 Distance: 2.5 Maximum: 5.5 Minimum: 3.0
NOTE: For this exercise, your solution should not use any conditional
statements. Instead you should use the methods provided by
thejava.util.Math.
I need help. For this exercise you will implement a class called Pair,
that represents a pair of two numbers.The Pair class should include the
following constructor and methods:
CONSTRUCTORS public Pair(double num1, double num2) -- Creates an object
that represents a pair of double values
METHODS public double getAverage() -- Returns the average value of the two
numbers
public double getDistance() -- Returns the absolute vale of the distance
between the two numbers
public double getMaximum() -- Returns the maximum value of the two numbers
public double getMinimum() -- Returns the minimum vale of the two numbers
Write a class called PairTest that tests your Pair implementation. The
PairTest should prompt the user for the two values, create a Pair object
with the values and then print the average, distance, maximum, and minimum
of the pair. The input / output should look like the following:
Enter the first number: 5.5 Enter the second number: 3.0
Average: 4.25 Distance: 2.5 Maximum: 5.5 Minimum: 3.0
NOTE: For this exercise, your solution should not use any conditional
statements. Instead you should use the methods provided by
thejava.util.Math.
Given x_0 and x_n+1 and that x_i is integer, how to calculate sum(x_0
Given x_0 and x_n+1 and that x_i is integer, how to calculate sum(x_0
If there are certain numbers x_0 and x_(n+1) and if x_i is an integer for
0<=i<=n+1, how to calculate the above sum with JAVA? The sum indicates
that it takes the sum of f(x_1,x_2,...x_n) for every possible combination
of (x_1,x_2,...x_n) such that the above inequality holds. I have an idea
for the solution, but it is a terribly ineffective algorithm using binary,
and it's O(2^n). Of course, I cannot use "for" because it must be used for
n (non-specific) times. Is there anyone who knows more effective algorithm
for this?
If there are certain numbers x_0 and x_(n+1) and if x_i is an integer for
0<=i<=n+1, how to calculate the above sum with JAVA? The sum indicates
that it takes the sum of f(x_1,x_2,...x_n) for every possible combination
of (x_1,x_2,...x_n) such that the above inequality holds. I have an idea
for the solution, but it is a terribly ineffective algorithm using binary,
and it's O(2^n). Of course, I cannot use "for" because it must be used for
n (non-specific) times. Is there anyone who knows more effective algorithm
for this?
Sunday, 29 September 2013
How to get the "real-time" updates from an android mobile phone's clock?
How to get the "real-time" updates from an android mobile phone's clock?
I am creating an alarm clock application and I would like to have a small
text-based representation of the actual time in "hh:MM:ss am/pm" format
that would be in sync with the actual time of the mobile phone.
I tried searching around but nothing seemed to help me. Any thoughts?
I am creating an alarm clock application and I would like to have a small
text-based representation of the actual time in "hh:MM:ss am/pm" format
that would be in sync with the actual time of the mobile phone.
I tried searching around but nothing seemed to help me. Any thoughts?
compat notification below 3.0
compat notification below 3.0
I want to use notification compat for android 2.3.6
mNotifyManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder = new NotificationCompat.Builder(c);
mBuilder.setContentTitle(book.getBook_name() + " download")
.setContentText("Download in progress")
.setSmallIcon(R.drawable.ic_launcher);
I want to use notification compat for android 2.3.6
mNotifyManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder = new NotificationCompat.Builder(c);
mBuilder.setContentTitle(book.getBook_name() + " download")
.setContentText("Download in progress")
.setSmallIcon(R.drawable.ic_launcher);
How to make a dropdown treeview?
How to make a dropdown treeview?
I tried to put a treeview in ajax toolkit DropDownExtender, But the
problem came here
My question is that can i put treeview in div and make div dropdown with
jquery ?
please help me, i need this so much.
I tried to put a treeview in ajax toolkit DropDownExtender, But the
problem came here
My question is that can i put treeview in div and make div dropdown with
jquery ?
please help me, i need this so much.
libssh2 iOS framework libraries not found
libssh2 iOS framework libraries not found
I was trying to use the libssh2 framework for iOS. Unfortunately I can't
build it because the libraries were not found:
How do i fix this? I ran the build-all script but it does not work.
Thanks for your help!
Best
I was trying to use the libssh2 framework for iOS. Unfortunately I can't
build it because the libraries were not found:
How do i fix this? I ran the build-all script but it does not work.
Thanks for your help!
Best
Saturday, 28 September 2013
Convert to PDO regexp bind error
Convert to PDO regexp bind error
I'm trying to convert from mysql to using PDO. I'm stuck on this error:
For the most part I got it working except when it comes to binding the
variable.
Fatal error: Call to a member function bindParam() on a non-object in
Here is what I tried:
global $keyword;
$_link = new PDO("mysql:host=$host;dbname=$db_name", "$username",
"$password");
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM PLD_ANINJA WHERE
`Text` REGEXP CONCAT('[[:<:]]',:keyword,'[[:>:]]') LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
$_query->bindParam(':keyword',$keyword, PDO::PARAM_STR);
$_query->execute();
Here is what worked originally:
global $keyword;
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM PLD_ANINJA WHERE
`Text` REGEXP '[[:<:]]" . $keyword . "[[:>:]]' LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
I'm trying to convert from mysql to using PDO. I'm stuck on this error:
For the most part I got it working except when it comes to binding the
variable.
Fatal error: Call to a member function bindParam() on a non-object in
Here is what I tried:
global $keyword;
$_link = new PDO("mysql:host=$host;dbname=$db_name", "$username",
"$password");
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM PLD_ANINJA WHERE
`Text` REGEXP CONCAT('[[:<:]]',:keyword,'[[:>:]]') LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
$_query->bindParam(':keyword',$keyword, PDO::PARAM_STR);
$_query->execute();
Here is what worked originally:
global $keyword;
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM PLD_ANINJA WHERE
`Text` REGEXP '[[:<:]]" . $keyword . "[[:>:]]' LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
Achieve a task using a single loop instead of 2 c++`
Achieve a task using a single loop instead of 2 c++`
This is a task specific code for which I want to know if there's a better
way of doing it. Thus, people who love logic and coding, please help me
out.
This is the question :
Let A be an array of n positive integers. All the elements are distinct.
If A[i] > A[j] and i < j then the pair (i, j) is called a special pair of
A. Given n find the number of special pairs of A.
Its pretty simple and straight. Here's the following solution I
implemented. The logic part.
for(int j=0;j<nos.size();j++)
{
for(int k=j+1;k<nos.size();k++)//always maintain
condition that i<j and simply compare the numbers.
{
if(nos[j] > nos[k])
{
spc++;//compute special pair.
}
}
}
Every nos[i] contains the array for which special pair is to be computed.
Is there a way to do this with using a single loop? Or any other logic
that can be time saving and is faster. Thanks in advance I seek to learn
more from this.
And can you please tell me how I can determine which code is faster
without having to execute the code. Your inputs are really welcome.
The main question is to compute the no.of special pairs. Thus, just the
increment of spc.
This is a task specific code for which I want to know if there's a better
way of doing it. Thus, people who love logic and coding, please help me
out.
This is the question :
Let A be an array of n positive integers. All the elements are distinct.
If A[i] > A[j] and i < j then the pair (i, j) is called a special pair of
A. Given n find the number of special pairs of A.
Its pretty simple and straight. Here's the following solution I
implemented. The logic part.
for(int j=0;j<nos.size();j++)
{
for(int k=j+1;k<nos.size();k++)//always maintain
condition that i<j and simply compare the numbers.
{
if(nos[j] > nos[k])
{
spc++;//compute special pair.
}
}
}
Every nos[i] contains the array for which special pair is to be computed.
Is there a way to do this with using a single loop? Or any other logic
that can be time saving and is faster. Thanks in advance I seek to learn
more from this.
And can you please tell me how I can determine which code is faster
without having to execute the code. Your inputs are really welcome.
The main question is to compute the no.of special pairs. Thus, just the
increment of spc.
Accounts/number of accounts you can have [on hold]
Accounts/number of accounts you can have [on hold]
How many accounts is 1 person allowed to have on facebook? I was just
curious because I was just wondering how many accounts 1 person can have.
How many accounts is 1 person allowed to have on facebook? I was just
curious because I was just wondering how many accounts 1 person can have.
Friday, 27 September 2013
getchar() unexpected behavior
getchar() unexpected behavior
char ch;
while((ch = getchar()) != EOF){
putchar(ch);
}
The above code, obviously enough, should copy my input. And it does work,
for basic ASCII text files.
However, if I send it a gif, in particular this one, but applicable to
most (http://www.cs.utexas.edu/~peterson/prog2/smile.gif), then when I
redirect stdin for the gif, and stdout to any file type, and run diff on
the original and the new one, errors galore. In this case, more than half
of the file isn't even processed, it simply quits. Any clues? I'd be
willing to switch off to another input/output functions, provided I can
input a byte at a time.
char ch;
while((ch = getchar()) != EOF){
putchar(ch);
}
The above code, obviously enough, should copy my input. And it does work,
for basic ASCII text files.
However, if I send it a gif, in particular this one, but applicable to
most (http://www.cs.utexas.edu/~peterson/prog2/smile.gif), then when I
redirect stdin for the gif, and stdout to any file type, and run diff on
the original and the new one, errors galore. In this case, more than half
of the file isn't even processed, it simply quits. Any clues? I'd be
willing to switch off to another input/output functions, provided I can
input a byte at a time.
Convert date of format dd mon yyyy to return integer of month in SQL
Convert date of format dd mon yyyy to return integer of month in SQL
I have a varchar variable containing value 01 May 2013 and I need to
obtain the integer of the Month part.
for eg if 01 May 2013 is input I should get the result as 5
The query I wrote was : select
DATEPART(MM,CONVERT(DATETIME,CONVERT(VARCHAR(15),'01
'+SUBSTRING(FISCAL_MONTH,1,3)+' 2013'),100)) FROM
Here FISCAL_MONTH is my column name from the table. However this query is
showing me the result, for eg 11 for November but is also throwing the
following error : Msg 241, Level 16, State 1, Line 1 Conversion failed
when converting date and/or time from character string.
I have tried various combinations, bit in vain. Kindly note I need it in a
query. Kindly help.
I have a varchar variable containing value 01 May 2013 and I need to
obtain the integer of the Month part.
for eg if 01 May 2013 is input I should get the result as 5
The query I wrote was : select
DATEPART(MM,CONVERT(DATETIME,CONVERT(VARCHAR(15),'01
'+SUBSTRING(FISCAL_MONTH,1,3)+' 2013'),100)) FROM
Here FISCAL_MONTH is my column name from the table. However this query is
showing me the result, for eg 11 for November but is also throwing the
following error : Msg 241, Level 16, State 1, Line 1 Conversion failed
when converting date and/or time from character string.
I have tried various combinations, bit in vain. Kindly note I need it in a
query. Kindly help.
How can I find the Windows Edition name
How can I find the Windows Edition name
How can I find the Microsoft Windows (Os name) for my c# application.
such as 'Windows 8 Pro' I mean the Edition from the os.
How can I find the Microsoft Windows (Os name) for my c# application.
such as 'Windows 8 Pro' I mean the Edition from the os.
How can i show information by relationship using ajax?
How can i show information by relationship using ajax?
How can i create an ajax in my search when i select a country it would
show me all states that i have in the country selected
My tables
Countries
|id| |country_name|
1 'USA'
2 'Peru'
States
|id| |state_name|
1 Alabama
2 Machupicchu
Country_States
|id| |country_id| |state_id|
1 1 1
2 2 2
My controller
class Country_StatesController < ApplicationController
def conditional
@countries = Country.find(:all)
@states= State.find(:all)
@selected_country = Country.find_by_id(params[:countries]) if
params[:countries].to_i
@selected_state = State.find_by_id(params[:states]) if
params[:states].to_i
@search= CountryState.find(:all,:conditions=> ['state_id','country_id'
],params[:states],params[:countries] )
end
end
My view
<% form_tag :controller=>"country_States",:action=>"conditional" do %>
<%= select_tag "countries", options_for_select(@states.collect {|t|
[t.state_name.to_s ,t.id]}) %>
<%= select_tag "states", options_for_select(@states.collect {|t|
[t.state_name.to_s ,t.id]}, params[:search].to_i ) %>
<%= submit_tag "Search", :name => nil %>
<% end %>
I will appreciate help.
How can i create an ajax in my search when i select a country it would
show me all states that i have in the country selected
My tables
Countries
|id| |country_name|
1 'USA'
2 'Peru'
States
|id| |state_name|
1 Alabama
2 Machupicchu
Country_States
|id| |country_id| |state_id|
1 1 1
2 2 2
My controller
class Country_StatesController < ApplicationController
def conditional
@countries = Country.find(:all)
@states= State.find(:all)
@selected_country = Country.find_by_id(params[:countries]) if
params[:countries].to_i
@selected_state = State.find_by_id(params[:states]) if
params[:states].to_i
@search= CountryState.find(:all,:conditions=> ['state_id','country_id'
],params[:states],params[:countries] )
end
end
My view
<% form_tag :controller=>"country_States",:action=>"conditional" do %>
<%= select_tag "countries", options_for_select(@states.collect {|t|
[t.state_name.to_s ,t.id]}) %>
<%= select_tag "states", options_for_select(@states.collect {|t|
[t.state_name.to_s ,t.id]}, params[:search].to_i ) %>
<%= submit_tag "Search", :name => nil %>
<% end %>
I will appreciate help.
Passing a variable to a lambda-function
Passing a variable to a lambda-function
How to pass a variable "$field" to a lambda-function?
function implode_assoc_array($array, $field)
{
// $ids = array_column($array, $field); PHP 5.5!
$ids = array_map(function($item) { return $item[$field]; }, $array);
return implode(', ', $ids);
}
implode_assoc_array($my_multidimensional_array, 'id');
Message: Undefined variable: field
How to pass a variable "$field" to a lambda-function?
function implode_assoc_array($array, $field)
{
// $ids = array_column($array, $field); PHP 5.5!
$ids = array_map(function($item) { return $item[$field]; }, $array);
return implode(', ', $ids);
}
implode_assoc_array($my_multidimensional_array, 'id');
Message: Undefined variable: field
C++ Undefined Reference Error for a template class
C++ Undefined Reference Error for a template class
I'm working on a template Priority Queue using a binary max-heap. I have 3
files:
the main class:
#include "PriorityQueue.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
PriorityQueue<string> queue;
queue.insert("Hello World",20.0f);
queue.insert("Lorem Ipsum",10.0f);
queue.insert(" is a phrase ",4.0f);
queue.insert("used by ",7.0f);
queue.insert("C++",12.0f);
queue.insert(" developers.",6.0f);
queue.remove("C++");
queue.pop();
queue.changePriority(" is a phrase ",9.0f);
queue.insert("commonly ",8.0f);
queue.changePriority(" developers.",2.0f);
queue.insert("web",4.0f);
cout << "The Max-Heap should spell out 'Lorem Ipsum is a phrase commonly
used by web developers.'" << endl;
for(int i=0;i<queue.getSize();i++) {
cout << (i+1) << ": " << queue.getObject(i) << endl;
}
return 0;
}
the source class:
#include "PriorityQueue.h"
// Constructor for the PQObj class.
template <class T> PQObj<T>::PQObj()
{
obj = NULL;
priority = 0;
}
// Constructor with parameters for the PQObj class.
template <class T> PQObj<T>::PQObj(T obj,float priority)
{
this->obj = obj;
this->priority = priority;
}
// Getter for the PQObj's obj.
template <class T> T PQObj<T>::getObj()
{
return obj;
}
// Setter for the PQObj's obj.
template <class T> void PQObj<T>::setObj(T obj)
{
this->obj = obj;
}
// Getter for the PQObj's priority.
template <class T> float PQObj<T>::getPriority()
{
return priority;
}
// Setter for the PQObj's priority.
template <class T> void PQObj<T>::setPriority(float priority)
{
this->priority = priority;
}
// Constructor for the PriorityQueue's class. Initializes the sort array
to a size 10.
template <class T> PriorityQueue<T>::PriorityQueue()
{
head = 0;
tail = 0;
size = 10;
sort = new PQObj<T>[10];
pQueue = NULL;
}
// Destructor for the PriorityQueue's class.
template <class T> PriorityQueue<T>::~PriorityQueue()
{
if(sort!=NULL)
delete [] sort;
if(pQueue!=NULL)
delete [] pQueue;
}
// Inserts a new object with a given priority. If the priority is larger
than the front, the two objects will be swapped.
template <class T> void PriorityQueue<T>::insert(T obj,float priority)
{
sort[tail] = new PQObj<T>(obj,priority);
if(priority>sort[head].getPriority())
swap(sort,head,tail);
tail++;
if(tail==size)
increaseCapacity();
}
// Returns the object in front of the Priority Queue, i.e. with the
highest priority.
template <class T> T PriorityQueue<T>::front()
{
if(isEmpty())
return NULL;
else
return sort[head].getObj();
}
// Returns the object in front of the Priority Queue, as well as removing it.
template <class T> T PriorityQueue<T>::pop()
{
PQObj<T> temp = sort[head];
sort[head] = NULL;
head++;
return temp.getObj();
}
// Checks to see if the Priority Queue is empty. Returns true if it is empty.
template <class T> bool PriorityQueue<T>::isEmpty()
{
if((tail-head)==0)
return true;
else
return false;
}
// Finds a specific object within the Priority Queue and changes its
priority.
template <class T> void PriorityQueue<T>::changePriority(T obj,float
new_priority)
{
for(int i=head;i<tail;i++) {
if(sort[i].getObj()==obj) {
sort[i].setPriority(new_priority);
if(i!=head)
swap(sort,head,i);
break;
}
}
}
// Removes a certain object from the Priority Queue by making it max
priority, then popping it.
template <class T> void PriorityQueue<T>::remove(T obj)
{
changePriority(obj,sort[head].getPriority()+1);
pop();
}
// Sorts the regular array into a Max Heap, storing the heap into an
exclusive array.
template <class T> void PriorityQueue<T>::createHeap()
{
int curr = (tail-head)/2;
for(int i=curr;i>0;i--) {
percolateDown(i);
}
int unSort = (tail-head);
int temp;
while(unSort > 0) {
temp = sort[1];
sort[1] = sort[unSort];
sort[unSort] = temp;
unSort--;
percolateDown(1);
}
pQueue = sort;
}
// Get the specific object within the Max-Heap.
template <class T> T PriorityQueue<T>::getObject(int index)
{
return pQueue[index].getObj();
}
// Get the size of the Max-Heap.
template <class T> int PriorityQueue<T>::getSize()
{
return (tail-head);
}
// Increases the size of the Priority Queue when necessary.
template <class T> void PriorityQueue<T>::increaseCapacity()
{
PQObj<T> *newSort = new PQObj<T>[size*2];
for(int i=0;i<size;i++)
newSort[i] = sort[i];
size *= 2;
sort = newSort;
delete [] newSort;
}
// Percolate Down in the Max Heap.
template <class T> void PriorityQueue<T>::percolateDown(int index)
{
int left = index * 2;
int right = (index * 2) + 1;
if(right <= (tail-head)) {
if(sort[left].getPriority() > sort[right].getPriority()) {
if(sort[index].getPriority() < sort[left].getPriority()) {
swap(sort,left,index);
percolateDown(left);
}
}
else {
if(sort[index].getPriority() < sort[right].getPriority()) {
swap(sort,right,index);
percolateDown(right);
}
}
}
else {
if(left <= (tail-head)) {
if(sort[index].getPriority() < sort[left].getPriority()) {
swap(sort,left,index);
percolateDown(left);
}
}
}
}
// Swaps the content of two specific spots of the Priority Queue.
template <class T> void PriorityQueue<T>::swap(PQObj<T> toSwap[],int
pos1,int pos2)
{
PQObj<T> temp = toSwap[pos1];
toSwap[pos1] = toSwap[pos2];
toSwap[pos2] = temp;
}
and the header class:
#ifndef _PRIORITYQUEUE_H_
#define _PRIORITYQUEUE_H_
#include <cstddef>
using namespace std;
template <class T> class PQObj
{
public:
PQObj();
PQObj(T obj,float priority);
T getObj();
float getPriority();
void setObj(T obj);
void setPriority(float priority);
private:
T obj;
float priority;
};
template <class T> class PriorityQueue
{
public:
PriorityQueue();
~PriorityQueue();
void insert(T obj,float priority);
T front();
T pop();
bool isEmpty();
void changePriority(T obj,float new_priority);
void remove(T obj);
void createHeap();
T getObject(int index);
int getSize();
private:
void increaseCapacity();
void percolateDown(int index);
void swap(PQObj<T> toSwap[],int pos1,int pos2);
PQObj<T> * pQueue, * sort;
int head,tail,size;
};
I'm working on a template Priority Queue using a binary max-heap. I have 3
files:
the main class:
#include "PriorityQueue.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
PriorityQueue<string> queue;
queue.insert("Hello World",20.0f);
queue.insert("Lorem Ipsum",10.0f);
queue.insert(" is a phrase ",4.0f);
queue.insert("used by ",7.0f);
queue.insert("C++",12.0f);
queue.insert(" developers.",6.0f);
queue.remove("C++");
queue.pop();
queue.changePriority(" is a phrase ",9.0f);
queue.insert("commonly ",8.0f);
queue.changePriority(" developers.",2.0f);
queue.insert("web",4.0f);
cout << "The Max-Heap should spell out 'Lorem Ipsum is a phrase commonly
used by web developers.'" << endl;
for(int i=0;i<queue.getSize();i++) {
cout << (i+1) << ": " << queue.getObject(i) << endl;
}
return 0;
}
the source class:
#include "PriorityQueue.h"
// Constructor for the PQObj class.
template <class T> PQObj<T>::PQObj()
{
obj = NULL;
priority = 0;
}
// Constructor with parameters for the PQObj class.
template <class T> PQObj<T>::PQObj(T obj,float priority)
{
this->obj = obj;
this->priority = priority;
}
// Getter for the PQObj's obj.
template <class T> T PQObj<T>::getObj()
{
return obj;
}
// Setter for the PQObj's obj.
template <class T> void PQObj<T>::setObj(T obj)
{
this->obj = obj;
}
// Getter for the PQObj's priority.
template <class T> float PQObj<T>::getPriority()
{
return priority;
}
// Setter for the PQObj's priority.
template <class T> void PQObj<T>::setPriority(float priority)
{
this->priority = priority;
}
// Constructor for the PriorityQueue's class. Initializes the sort array
to a size 10.
template <class T> PriorityQueue<T>::PriorityQueue()
{
head = 0;
tail = 0;
size = 10;
sort = new PQObj<T>[10];
pQueue = NULL;
}
// Destructor for the PriorityQueue's class.
template <class T> PriorityQueue<T>::~PriorityQueue()
{
if(sort!=NULL)
delete [] sort;
if(pQueue!=NULL)
delete [] pQueue;
}
// Inserts a new object with a given priority. If the priority is larger
than the front, the two objects will be swapped.
template <class T> void PriorityQueue<T>::insert(T obj,float priority)
{
sort[tail] = new PQObj<T>(obj,priority);
if(priority>sort[head].getPriority())
swap(sort,head,tail);
tail++;
if(tail==size)
increaseCapacity();
}
// Returns the object in front of the Priority Queue, i.e. with the
highest priority.
template <class T> T PriorityQueue<T>::front()
{
if(isEmpty())
return NULL;
else
return sort[head].getObj();
}
// Returns the object in front of the Priority Queue, as well as removing it.
template <class T> T PriorityQueue<T>::pop()
{
PQObj<T> temp = sort[head];
sort[head] = NULL;
head++;
return temp.getObj();
}
// Checks to see if the Priority Queue is empty. Returns true if it is empty.
template <class T> bool PriorityQueue<T>::isEmpty()
{
if((tail-head)==0)
return true;
else
return false;
}
// Finds a specific object within the Priority Queue and changes its
priority.
template <class T> void PriorityQueue<T>::changePriority(T obj,float
new_priority)
{
for(int i=head;i<tail;i++) {
if(sort[i].getObj()==obj) {
sort[i].setPriority(new_priority);
if(i!=head)
swap(sort,head,i);
break;
}
}
}
// Removes a certain object from the Priority Queue by making it max
priority, then popping it.
template <class T> void PriorityQueue<T>::remove(T obj)
{
changePriority(obj,sort[head].getPriority()+1);
pop();
}
// Sorts the regular array into a Max Heap, storing the heap into an
exclusive array.
template <class T> void PriorityQueue<T>::createHeap()
{
int curr = (tail-head)/2;
for(int i=curr;i>0;i--) {
percolateDown(i);
}
int unSort = (tail-head);
int temp;
while(unSort > 0) {
temp = sort[1];
sort[1] = sort[unSort];
sort[unSort] = temp;
unSort--;
percolateDown(1);
}
pQueue = sort;
}
// Get the specific object within the Max-Heap.
template <class T> T PriorityQueue<T>::getObject(int index)
{
return pQueue[index].getObj();
}
// Get the size of the Max-Heap.
template <class T> int PriorityQueue<T>::getSize()
{
return (tail-head);
}
// Increases the size of the Priority Queue when necessary.
template <class T> void PriorityQueue<T>::increaseCapacity()
{
PQObj<T> *newSort = new PQObj<T>[size*2];
for(int i=0;i<size;i++)
newSort[i] = sort[i];
size *= 2;
sort = newSort;
delete [] newSort;
}
// Percolate Down in the Max Heap.
template <class T> void PriorityQueue<T>::percolateDown(int index)
{
int left = index * 2;
int right = (index * 2) + 1;
if(right <= (tail-head)) {
if(sort[left].getPriority() > sort[right].getPriority()) {
if(sort[index].getPriority() < sort[left].getPriority()) {
swap(sort,left,index);
percolateDown(left);
}
}
else {
if(sort[index].getPriority() < sort[right].getPriority()) {
swap(sort,right,index);
percolateDown(right);
}
}
}
else {
if(left <= (tail-head)) {
if(sort[index].getPriority() < sort[left].getPriority()) {
swap(sort,left,index);
percolateDown(left);
}
}
}
}
// Swaps the content of two specific spots of the Priority Queue.
template <class T> void PriorityQueue<T>::swap(PQObj<T> toSwap[],int
pos1,int pos2)
{
PQObj<T> temp = toSwap[pos1];
toSwap[pos1] = toSwap[pos2];
toSwap[pos2] = temp;
}
and the header class:
#ifndef _PRIORITYQUEUE_H_
#define _PRIORITYQUEUE_H_
#include <cstddef>
using namespace std;
template <class T> class PQObj
{
public:
PQObj();
PQObj(T obj,float priority);
T getObj();
float getPriority();
void setObj(T obj);
void setPriority(float priority);
private:
T obj;
float priority;
};
template <class T> class PriorityQueue
{
public:
PriorityQueue();
~PriorityQueue();
void insert(T obj,float priority);
T front();
T pop();
bool isEmpty();
void changePriority(T obj,float new_priority);
void remove(T obj);
void createHeap();
T getObject(int index);
int getSize();
private:
void increaseCapacity();
void percolateDown(int index);
void swap(PQObj<T> toSwap[],int pos1,int pos2);
PQObj<T> * pQueue, * sort;
int head,tail,size;
};
Thursday, 26 September 2013
Android thumb is not center_horizontaled at the progress?
Android thumb is not center_horizontaled at the progress?
this is the view,the thumb is not centered at the current progress,i've
seen it's really a problem
http://i.imgur.com/I5DFV.jpg "tooltip"">
and here is xml:
<SeekBar
android:id="@+id/controller_play_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxHeight="25dip"
android:minHeight="25dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:progressDrawable="@drawable/mediacontroller_seekbar"
android:thumb="@drawable/mediacontroller_seekbar_thumb"
android:thumbOffset="8dip" />
this is the view,the thumb is not centered at the current progress,i've
seen it's really a problem
http://i.imgur.com/I5DFV.jpg "tooltip"">
and here is xml:
<SeekBar
android:id="@+id/controller_play_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxHeight="25dip"
android:minHeight="25dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:progressDrawable="@drawable/mediacontroller_seekbar"
android:thumb="@drawable/mediacontroller_seekbar_thumb"
android:thumbOffset="8dip" />
Wednesday, 25 September 2013
How to execute a block of code in IOS7 not in IOS6?
How to execute a block of code in IOS7 not in IOS6?
Hi In past I had developed one application which supports IOS6.Now the
time came to support the same app for IOS7 also. For supporting the app
for IOS6 & IOS7 I increased the Y value of each and every component by 20
pixels.
Here I am getting the OS version by using[[[UIDevice
CurrentDevice]SystemVersion] floatvalue]; method.Based on that OS version
I am changing the rect values for each and every component.
For handling the StatusbarStyle I am using the following methods in IOS7
[self setNeedsStatusBarAppearanceUpdate];
2.-(UIStatusBarStyle)preferredStatusBarStyle;
These methods are working fine in IOS7, But if I install the app in IOS6
the app is crashing due to the above two methods.
So now my requirement is I have to hide or not execute IOS7 related
methods or changes in IOS6 Device.With the help of this Implementation I
hope I can resolve the issue.
Even I used few methods to resolve this crash issue.The methods which I
used are
#if __IPHONE_OS_VERSION_MAX_ALLOWED== 70000 2.#if
__IPHONE_OS_VERSION_MIN_REQUIRED==70000
Here while creating the ipa file deployment Target Which I had set is 6.0.
Because I have to support IOS6 & IOS7.
So please help me to resolve this issue. Thanks in Advance.
Hi In past I had developed one application which supports IOS6.Now the
time came to support the same app for IOS7 also. For supporting the app
for IOS6 & IOS7 I increased the Y value of each and every component by 20
pixels.
Here I am getting the OS version by using[[[UIDevice
CurrentDevice]SystemVersion] floatvalue]; method.Based on that OS version
I am changing the rect values for each and every component.
For handling the StatusbarStyle I am using the following methods in IOS7
[self setNeedsStatusBarAppearanceUpdate];
2.-(UIStatusBarStyle)preferredStatusBarStyle;
These methods are working fine in IOS7, But if I install the app in IOS6
the app is crashing due to the above two methods.
So now my requirement is I have to hide or not execute IOS7 related
methods or changes in IOS6 Device.With the help of this Implementation I
hope I can resolve the issue.
Even I used few methods to resolve this crash issue.The methods which I
used are
#if __IPHONE_OS_VERSION_MAX_ALLOWED== 70000 2.#if
__IPHONE_OS_VERSION_MIN_REQUIRED==70000
Here while creating the ipa file deployment Target Which I had set is 6.0.
Because I have to support IOS6 & IOS7.
So please help me to resolve this issue. Thanks in Advance.
Thursday, 19 September 2013
SVN Revision Numbers for multipel file commits
SVN Revision Numbers for multipel file commits
Is there any way that a developer commits multiple files (suppose 5 files)
and only a single revision is generated, or each file commit, no matter
how it is committed, always causes a new revision number to be generated.
Is there any way that a developer commits multiple files (suppose 5 files)
and only a single revision is generated, or each file commit, no matter
how it is committed, always causes a new revision number to be generated.
Trac tickets have file reference
Trac tickets have file reference
I am a trac newbie. I would like to make my trac tickets have automatic
references to change-sets in my git repository.
I.e. if i commit with
git commit -m "Refs #1 - some commit" .
I would like for the ticket itself to show the changeset that was
committed at "."
Currently, following these instructions:
http://trac.edgewall.org/wiki/Ubuntu-10.04.03-Git
For the individual files, it does show the ticket number that was
referenced. It seems like it would be easy to make the reverse also true.
Thanks
I am a trac newbie. I would like to make my trac tickets have automatic
references to change-sets in my git repository.
I.e. if i commit with
git commit -m "Refs #1 - some commit" .
I would like for the ticket itself to show the changeset that was
committed at "."
Currently, following these instructions:
http://trac.edgewall.org/wiki/Ubuntu-10.04.03-Git
For the individual files, it does show the ticket number that was
referenced. It seems like it would be easy to make the reverse also true.
Thanks
Multiple objects in BorderLayout regions
Multiple objects in BorderLayout regions
i'm making a title bar, and i'm putting the title on the left and two
buttons on the right. But if I use BorderLayout.EAST for both buttons,
only the last one will be showed. I can I get both visible? I tried using
the JPanel but it's going to make padding/margin around itself, and i
don't want that. I tried removing it using createEmptyBorder(0, 0, 0, 0)
but nothing changed..
i'm making a title bar, and i'm putting the title on the left and two
buttons on the right. But if I use BorderLayout.EAST for both buttons,
only the last one will be showed. I can I get both visible? I tried using
the JPanel but it's going to make padding/margin around itself, and i
don't want that. I tried removing it using createEmptyBorder(0, 0, 0, 0)
but nothing changed..
use json object in javascript to show in confirm window
use json object in javascript to show in confirm window
i have jsonObject coming as string from controller, jsonObject is
something like this:
`{"loadList":[{"Name":"AAAA","Load":"N GND"},
{"Name":"BBBB","Load":"N GND"},
{"Name":"CCCC","Load":"N GND"},
{"Name":"DDDD","Load":"N GND"}]
} );`
I need to use the above text in a java script confirm window like,
Name:AAAA Load:N GND
Name:BBBB Load:N GND
Name:CCCC Load:N GND
Name:DDDD Load:N GND
what I am doing is var obj = $.parseJSON( ${jsonObject} ); but obj turn
out to be null!
Any help is appreciated!
i have jsonObject coming as string from controller, jsonObject is
something like this:
`{"loadList":[{"Name":"AAAA","Load":"N GND"},
{"Name":"BBBB","Load":"N GND"},
{"Name":"CCCC","Load":"N GND"},
{"Name":"DDDD","Load":"N GND"}]
} );`
I need to use the above text in a java script confirm window like,
Name:AAAA Load:N GND
Name:BBBB Load:N GND
Name:CCCC Load:N GND
Name:DDDD Load:N GND
what I am doing is var obj = $.parseJSON( ${jsonObject} ); but obj turn
out to be null!
Any help is appreciated!
Reverting tab in visual studio
Reverting tab in visual studio
I'm using Visual Studio 2012, and I was wondering if there is any keyboard
that does the reverse effect of tab button. Thank you in advance.
I'm using Visual Studio 2012, and I was wondering if there is any keyboard
that does the reverse effect of tab button. Thank you in advance.
python - pandas: create dummies from column with multiple values
python - pandas: create dummies from column with multiple values
I am looking for for a pythonic way to handle the following problem.
The pandas.get_dummies() method is great to create dummies from a
categorical column of a dataframe. For example, if the column has values
in ['A', 'B'], get_dummies() creates 2 dummy variables and assigns 0 or 1
accordingly.
Now, I need to handle this situation. A column has values like ['A', 'B',
'C', 'D', 'A*C', 'C*D'] . get_dummies() creates 6 dummies, but I only want
4 of them, so that a row could have multiple 1s.
Is there a way to handle this in a pythonic way? I could only think of
some step-by-step algorithm to get it, but that would not include
get_dummies(). Thanks
I am looking for for a pythonic way to handle the following problem.
The pandas.get_dummies() method is great to create dummies from a
categorical column of a dataframe. For example, if the column has values
in ['A', 'B'], get_dummies() creates 2 dummy variables and assigns 0 or 1
accordingly.
Now, I need to handle this situation. A column has values like ['A', 'B',
'C', 'D', 'A*C', 'C*D'] . get_dummies() creates 6 dummies, but I only want
4 of them, so that a row could have multiple 1s.
Is there a way to handle this in a pythonic way? I could only think of
some step-by-step algorithm to get it, but that would not include
get_dummies(). Thanks
Wednesday, 18 September 2013
how to check my jdbc version in my classpath
how to check my jdbc version in my classpath
How can I check if what is the type of jdbc driver I am using
I am currently using ojdbc14.jar. How can I check if my driver is JDBC 4
complaint driver?
How can I check if what is the type of jdbc driver I am using
I am currently using ojdbc14.jar. How can I check if my driver is JDBC 4
complaint driver?
Need an HTML Download button works with condition
Need an HTML Download button works with condition
I want to add a submit button to my site as in this image:
http://i.stack.imgur.com/8Lrrl.jpg
the captcha and part above that is not necessary, only need the button and
the check box after it..
I will explain,
When clicked on the button,
If the box is checked goto (http:// google.com/download)
if unchecked goto (http:// yahoo.com/download)
I want to add a submit button to my site as in this image:
http://i.stack.imgur.com/8Lrrl.jpg
the captcha and part above that is not necessary, only need the button and
the check box after it..
I will explain,
When clicked on the button,
If the box is checked goto (http:// google.com/download)
if unchecked goto (http:// yahoo.com/download)
D3.js: get value of selected option?
D3.js: get value of selected option?
I want to get the value of the selected option from a dropdown list, in
D3.js.
<select>
<option data-graph="1">1</option>
<option value="2">2</option>
</select>
I have seen this question which explains how to get the value when the
select changes:
d3.select("#myselect").on("change", change)
function change() {
this.options[this.selectedIndex].value
}
But how can I get the selected value on page load, not when the select is
changed?
I want to get the value of the selected option from a dropdown list, in
D3.js.
<select>
<option data-graph="1">1</option>
<option value="2">2</option>
</select>
I have seen this question which explains how to get the value when the
select changes:
d3.select("#myselect").on("change", change)
function change() {
this.options[this.selectedIndex].value
}
But how can I get the selected value on page load, not when the select is
changed?
Objective-C Modifying Class Instance Superclass
Objective-C Modifying Class Instance Superclass
I was wondering if there was a way of dynamically taking an Instance of a
class, so lets say I have a UIViewController called menu.
I could take menu's superclass which in this case would be
UIViewController and create a subclass of it. I would then assign this new
subclass to menu, I could also then dynamically override the methods as
well.
So that when Menu calls a method such as "ButtonClicked:" my code in the
new Class I created fires followed by the original code :).
This all has to be done at runtime for security reasons.
I was wondering if there was a way of dynamically taking an Instance of a
class, so lets say I have a UIViewController called menu.
I could take menu's superclass which in this case would be
UIViewController and create a subclass of it. I would then assign this new
subclass to menu, I could also then dynamically override the methods as
well.
So that when Menu calls a method such as "ButtonClicked:" my code in the
new Class I created fires followed by the original code :).
This all has to be done at runtime for security reasons.
NullReferenceException on String Property
NullReferenceException on String Property
In my program I allow the user to add to a Data Collection bound to a
TreeView. When the user creates the new node they are allowed to assign it
a name. The user writes the nodes name in a textBox located in a pop up
window. The text from the text box is bound to a property in a ViewModel.
However, I can't seem to get the property or the string in the ViewModel
to read the value that it is bound to. It just shows up in the debugger as
null, which is when I get the exception. I've created other windows
exactly like this, but for some reason this one doesn't want to work.
XAML:
<TextBox Text="{Binding TransName}" MaxHeight="20" MinHeight="20"
Height="20" Margin="142,24,12,40" Name="textBox1"
TextChanged="textBox1_TextChanged"></TextBox>
In the View Model:
private string _nodeName;
//Property for Node Name
public string NodeName
{
get { return _nodeName; }
set
{
_nodeName = value;
NotifyPropertyChange(() => NodeName);
}
}
Still in the View Model, this is the line in which the Exception occurs
//hasSpace is a boolean
hasSpace = _nodeName.Contains(" ");
In my program I allow the user to add to a Data Collection bound to a
TreeView. When the user creates the new node they are allowed to assign it
a name. The user writes the nodes name in a textBox located in a pop up
window. The text from the text box is bound to a property in a ViewModel.
However, I can't seem to get the property or the string in the ViewModel
to read the value that it is bound to. It just shows up in the debugger as
null, which is when I get the exception. I've created other windows
exactly like this, but for some reason this one doesn't want to work.
XAML:
<TextBox Text="{Binding TransName}" MaxHeight="20" MinHeight="20"
Height="20" Margin="142,24,12,40" Name="textBox1"
TextChanged="textBox1_TextChanged"></TextBox>
In the View Model:
private string _nodeName;
//Property for Node Name
public string NodeName
{
get { return _nodeName; }
set
{
_nodeName = value;
NotifyPropertyChange(() => NodeName);
}
}
Still in the View Model, this is the line in which the Exception occurs
//hasSpace is a boolean
hasSpace = _nodeName.Contains(" ");
Don't refresh when typing jquery and coldfusion
Don't refresh when typing jquery and coldfusion
I have a simple page:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function () {
$('#myform').on('submit', function (e) {
$.ajax({
type: 'post',
url: 'test2.cfm',
data: $('form').serialize(),
success: function () {
//alert('form was submitted');
$("#alldetails").load('details.cfm?randval='+ Math.random());
document.myform.tekst.value = "";
}
});
e.preventDefault();
});
});
</script>
</head>
<body>
<form id="myform" name="myform">
<input type="text" name="text"><br>
<input name="submit" type="submit" value="Submit">
</form>
<br>
<div id="alldetails">Loading</div>
<!--- stop when typing comment check and auto refresh --->
<script>
var isTyping = false;
$("#input-box").focus(function() {
isTyping = true;
});
$("#input-box").blur(function() {
isTyping = false;
});
$(document).ready(function() {
$("#alldetails").load("details.cfm");
$(document).ready(function() {
var refreshId = setInterval(function() {
if (!isTyping) {
$("#alldetails").load('details.cfm?randval='+ Math.random());
}}, 20000);
});
$.ajaxSetup({ cache: false });
});
</script>
</body>
</html>
the details are loaded in the div (allDetails) and that is working fine so
far. Now on my details.cfm page I'm showing the messages and people can
react on them. So far so good, but what I want to do is stop the
autorefresh when some is typing a comment. I have try this, see the
comment in the code above 'stop when typing and auto rerfesh'. Because the
comment input field is on the comment.cfm page, it is ignoring this
script.
Hope you understand the question.
Regards!
Edit:
the code of details.cfm:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function () {
$('#testform').on('submit', function (e) {
$.ajax({
type: 'post',
url: 'save_comment.cfm',
data: $('form').serialize(),
success: function () {
alert('form was submitted');
}
});
e.preventDefault();
});
});
</script>
<cfquery datasource="#ns#" name="getdata">
select text, timeline_id
from timeline
order by t_datum desc
</cfquery>
<cfoutput query="getdata">
<p>#tekst#</p>
<cfform id="testform">
<cfinput type="hidden" value="#timeline_id#" name="timeline_id">
<cfinput type="text" name="comment#timeline_id#" id="input-box"><input
type="submit">
</cfform>
</cfoutput>
I have a simple page:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function () {
$('#myform').on('submit', function (e) {
$.ajax({
type: 'post',
url: 'test2.cfm',
data: $('form').serialize(),
success: function () {
//alert('form was submitted');
$("#alldetails").load('details.cfm?randval='+ Math.random());
document.myform.tekst.value = "";
}
});
e.preventDefault();
});
});
</script>
</head>
<body>
<form id="myform" name="myform">
<input type="text" name="text"><br>
<input name="submit" type="submit" value="Submit">
</form>
<br>
<div id="alldetails">Loading</div>
<!--- stop when typing comment check and auto refresh --->
<script>
var isTyping = false;
$("#input-box").focus(function() {
isTyping = true;
});
$("#input-box").blur(function() {
isTyping = false;
});
$(document).ready(function() {
$("#alldetails").load("details.cfm");
$(document).ready(function() {
var refreshId = setInterval(function() {
if (!isTyping) {
$("#alldetails").load('details.cfm?randval='+ Math.random());
}}, 20000);
});
$.ajaxSetup({ cache: false });
});
</script>
</body>
</html>
the details are loaded in the div (allDetails) and that is working fine so
far. Now on my details.cfm page I'm showing the messages and people can
react on them. So far so good, but what I want to do is stop the
autorefresh when some is typing a comment. I have try this, see the
comment in the code above 'stop when typing and auto rerfesh'. Because the
comment input field is on the comment.cfm page, it is ignoring this
script.
Hope you understand the question.
Regards!
Edit:
the code of details.cfm:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function () {
$('#testform').on('submit', function (e) {
$.ajax({
type: 'post',
url: 'save_comment.cfm',
data: $('form').serialize(),
success: function () {
alert('form was submitted');
}
});
e.preventDefault();
});
});
</script>
<cfquery datasource="#ns#" name="getdata">
select text, timeline_id
from timeline
order by t_datum desc
</cfquery>
<cfoutput query="getdata">
<p>#tekst#</p>
<cfform id="testform">
<cfinput type="hidden" value="#timeline_id#" name="timeline_id">
<cfinput type="text" name="comment#timeline_id#" id="input-box"><input
type="submit">
</cfform>
</cfoutput>
Insert values in mySQL using wcf REST and Android
Insert values in mySQL using wcf REST and Android
I wrote a REST web service in C#. Get request works fine, but insert,
update and delete not. When I try to insert some values from an Android
tablet (client) via the REST service into a mySQL database an error
occurs: Method not allowed
I send a JSON string from the android client to the web service:
in Android Developer Tool (eclipse):
String url = IP + PORT +"/RESTService/insert/";
HttpClient client = new DefaultHttpClient();
HttpResponse response;
JSONObject json = new JSONObject();
HttpPost post = new HttpPost(url);
json.put("userName", name);
json.put("userPassword", password);
StringEntity se = new StringEntity(json.toString());
se.setContentType(new
BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
post.setEntity(se);
response = client.execute(post);
in C#: Service interface:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/insert/{jsonObj}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]
void InsertUser(string jsonObj);
Service methode:
public void InsertUser(string jsonObj)
{
string name = null;
string password = null;
DataContractJsonSerializer obj = new
DataContractJsonSerializer(typeof(User));
dynamic dynObj = JsonConvert.DeserializeObject(jsonObj);
foreach (var data in dynObj.userObject)
{
name = data.userName;
password = data.userPassword;
}
string sql = "INSERT INTO user (userName, userPassword) VALUES('" +
name + "', '" + password +"';)";
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
command = new MySqlCommand(sql, conn);
command.ExecuteNonQuery();
conn.Close();
command.Dispose();
}
My User:
namespace RESTService
{
[DataContract]
public class User
{
[DataMember]
public string userName { get; set; }
[DataMember]
public string userPassword { get; set; }
public User(string name, string password)
{
this.userName = name;
this.userPassword = password;
}
}
When I start the web service and try to insert the values via android app,
nothing happens. I think, that the values from the app don't reach the web
service. But I have no idea why. It would be great, if somebody can help
me :).
Thanks in advance
I wrote a REST web service in C#. Get request works fine, but insert,
update and delete not. When I try to insert some values from an Android
tablet (client) via the REST service into a mySQL database an error
occurs: Method not allowed
I send a JSON string from the android client to the web service:
in Android Developer Tool (eclipse):
String url = IP + PORT +"/RESTService/insert/";
HttpClient client = new DefaultHttpClient();
HttpResponse response;
JSONObject json = new JSONObject();
HttpPost post = new HttpPost(url);
json.put("userName", name);
json.put("userPassword", password);
StringEntity se = new StringEntity(json.toString());
se.setContentType(new
BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
post.setEntity(se);
response = client.execute(post);
in C#: Service interface:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/insert/{jsonObj}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]
void InsertUser(string jsonObj);
Service methode:
public void InsertUser(string jsonObj)
{
string name = null;
string password = null;
DataContractJsonSerializer obj = new
DataContractJsonSerializer(typeof(User));
dynamic dynObj = JsonConvert.DeserializeObject(jsonObj);
foreach (var data in dynObj.userObject)
{
name = data.userName;
password = data.userPassword;
}
string sql = "INSERT INTO user (userName, userPassword) VALUES('" +
name + "', '" + password +"';)";
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
command = new MySqlCommand(sql, conn);
command.ExecuteNonQuery();
conn.Close();
command.Dispose();
}
My User:
namespace RESTService
{
[DataContract]
public class User
{
[DataMember]
public string userName { get; set; }
[DataMember]
public string userPassword { get; set; }
public User(string name, string password)
{
this.userName = name;
this.userPassword = password;
}
}
When I start the web service and try to insert the values via android app,
nothing happens. I think, that the values from the app don't reach the web
service. But I have no idea why. It would be great, if somebody can help
me :).
Thanks in advance
Make ajax call a new jquery version
Make ajax call a new jquery version
I'm tying to have an ajax call to load an external website content in a
div. This content has for example an image slider or an email form that
works with jquery too. Is it possible to have another jquery script loaded
when clicking "Home" together with the content? Home
<script>jQuery(document).ready(function($) {$('.home').on('click',
function() {
var href = $(this).attr('href');
if ($('#ajax').is(':visible')) {
$('#ajax').css({ display:'block' }).animate({ height:'0' }).empty();
}
$('#ajax').css({ display:'block' }).animate({ height:'200px' },function() {
$('#loader').css({ border:'none', position:'relative', top:'24px',
left:'48px', boxShadow:'none' });
$('#ajax').load('home.php ' + href, function() {
$('#ajax').hide().fadeIn('slow').colorFade({ 'fadeColor':
'#0e0e0e' }); }); }); }); });
I tried to implement the scripts on the main page and on the external
page, but it just won't work. Many thanks in advance!
I'm tying to have an ajax call to load an external website content in a
div. This content has for example an image slider or an email form that
works with jquery too. Is it possible to have another jquery script loaded
when clicking "Home" together with the content? Home
<script>jQuery(document).ready(function($) {$('.home').on('click',
function() {
var href = $(this).attr('href');
if ($('#ajax').is(':visible')) {
$('#ajax').css({ display:'block' }).animate({ height:'0' }).empty();
}
$('#ajax').css({ display:'block' }).animate({ height:'200px' },function() {
$('#loader').css({ border:'none', position:'relative', top:'24px',
left:'48px', boxShadow:'none' });
$('#ajax').load('home.php ' + href, function() {
$('#ajax').hide().fadeIn('slow').colorFade({ 'fadeColor':
'#0e0e0e' }); }); }); }); });
I tried to implement the scripts on the main page and on the external
page, but it just won't work. Many thanks in advance!
Tuesday, 17 September 2013
Selenium IDE CaptureEntirePageScreenshot Error message
Selenium IDE CaptureEntirePageScreenshot Error message
I am currently using selenium ide within Firefox , my issue is when i am
trying to use the CaptureEntirePageScreenshot Command , i get an error
message, I am currently unable to post the image as i need 10 reputations
but the error message says
[error] locator not found: C:\\Users\\me\\Documents\\Screenshot\\test.jpg
I have tried with one slash but same error :
[error] locator not found: C:\Users\me\Documents\Screenshot\test.jpg
Thanks for your help!
I am currently using selenium ide within Firefox , my issue is when i am
trying to use the CaptureEntirePageScreenshot Command , i get an error
message, I am currently unable to post the image as i need 10 reputations
but the error message says
[error] locator not found: C:\\Users\\me\\Documents\\Screenshot\\test.jpg
I have tried with one slash but same error :
[error] locator not found: C:\Users\me\Documents\Screenshot\test.jpg
Thanks for your help!
How to reload a superview
How to reload a superview
Ok, so I'm writing a program for iPhone that has multiple views. The main
view calls a second view (the settings page). When the user then selects a
button on the second view, I want the main view to reload by calling the
viewDidLoad method again. Any suggestions on how to do this?
Ok, so I'm writing a program for iPhone that has multiple views. The main
view calls a second view (the settings page). When the user then selects a
button on the second view, I want the main view to reload by calling the
viewDidLoad method again. Any suggestions on how to do this?
Can't intslall phonegap with ADT
Can't intslall phonegap with ADT
I just checked here
PhoneGap not running in Android
What I did are as follows
I copied cordova-2.9.0.jar file from phonegap inside libs folder though it
dont show there! dont know why
Then made www folder under assets and added cordova-2.9.0.js file there
Then I replaced mainactivity.java with this code
package com.cordovatest;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("file:///android_asset/www/index.html",1000);
}
}
But I see so many errors see screenshot
http://gyazo.com/4e1fa15d0f5926d7a6ff6524645b0952
Then I added this code to my androidmanifest.xml
I just checked here
PhoneGap not running in Android
What I did are as follows
I copied cordova-2.9.0.jar file from phonegap inside libs folder though it
dont show there! dont know why
Then made www folder under assets and added cordova-2.9.0.js file there
Then I replaced mainactivity.java with this code
package com.cordovatest;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("file:///android_asset/www/index.html",1000);
}
}
But I see so many errors see screenshot
http://gyazo.com/4e1fa15d0f5926d7a6ff6524645b0952
Then I added this code to my androidmanifest.xml
Fortran character arrays
Fortran character arrays
I am looking for a way to address a body of character information with two
concurrent arrays in the same program unit.
For example, I want
CHARACTER(1) Array1(40960)
and
CHARACTER(4096) Array2(10)
pointing to the same body of information.
Note I have been careful in this example that the product of the
dimensions and rank of the arrays are the same.
I want the solution to be allocatable, so I don't think EQUIVALENCE or
COMMON would work.
Any ideas?
I am looking for a way to address a body of character information with two
concurrent arrays in the same program unit.
For example, I want
CHARACTER(1) Array1(40960)
and
CHARACTER(4096) Array2(10)
pointing to the same body of information.
Note I have been careful in this example that the product of the
dimensions and rank of the arrays are the same.
I want the solution to be allocatable, so I don't think EQUIVALENCE or
COMMON would work.
Any ideas?
9 patch isn't working on device
9 patch isn't working on device
I'm trying to make a 9 patch image to be a header of my application but it
doesn't work.
This is the image:
As you can already imagine, I want only the middle (blank) part to be
streched and nothing else. It works normally in eclipse screen preview but
it stretches it as if it wasn't 9 patch when i run it on my device.
I've had problems like this before so I'm clearly doing something wrong
with 9 patches, I looked up a lot of info and tutorials on 9 patches and I
just don't seem to get it. Could someone give me a good explanation where
exactly to put the black dots for it to work and why?
I'm trying to make a 9 patch image to be a header of my application but it
doesn't work.
This is the image:
As you can already imagine, I want only the middle (blank) part to be
streched and nothing else. It works normally in eclipse screen preview but
it stretches it as if it wasn't 9 patch when i run it on my device.
I've had problems like this before so I'm clearly doing something wrong
with 9 patches, I looked up a lot of info and tutorials on 9 patches and I
just don't seem to get it. Could someone give me a good explanation where
exactly to put the black dots for it to work and why?
Sunday, 15 September 2013
Opening installed application from another iOS application
Opening installed application from another iOS application
I trying to find a way for opening an installed application from my iPhone
app. An app named "Good Reader" which i want to open from my app. Can
anyone suggest the procedure.
Thanks in advance.
I trying to find a way for opening an installed application from my iPhone
app. An app named "Good Reader" which i want to open from my app. Can
anyone suggest the procedure.
Thanks in advance.
Why does VC++ introduce such an evil nonstandard keyword: __leave?
Why does VC++ introduce such an evil nonstandard keyword: __leave?
According to MSDN:
The __leave statement is more efficient because it does not cause stack
unwinding.
To my understanding, that is to say: "Such a common code snippet is
dangerous!"
struct A
{
int* p;
A() : p(new int) {}
~A() { delete p; }
};
void f()
{
__try
{
A a;
... // Doing somthing
if (the thing has gone bad) __leave;
... // Continue
}
__finally
{}
}
Is it a best practice to totally avoid __leave in C++ projects?
According to MSDN:
The __leave statement is more efficient because it does not cause stack
unwinding.
To my understanding, that is to say: "Such a common code snippet is
dangerous!"
struct A
{
int* p;
A() : p(new int) {}
~A() { delete p; }
};
void f()
{
__try
{
A a;
... // Doing somthing
if (the thing has gone bad) __leave;
... // Continue
}
__finally
{}
}
Is it a best practice to totally avoid __leave in C++ projects?
distinct values in sql?
distinct values in sql?
I need an sql query to count the number of distinct occurrences of the
numbers 2, 5, 7, & 9 in the left hand column (table below).
I have played w DISTINCT and COUNT. Need a query to show how many of each
value there are.
I know there's a bone-head simple solution to this, just cant figure it
out. Thanks!
CLASS_ID STUDENT_ID
2 12
2 11
2 2
2 7
2 8
2 16
2 21
7 10
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
9 2
9 11
9 12
9 13
9 14
9 15
9 16
9 17
9 18
9 20
9 21
9 22
10 12
10 4
10 3
10 6
10 8
10 9
10 12
10 16
10 18
10 20
10 2
10 4
I need an sql query to count the number of distinct occurrences of the
numbers 2, 5, 7, & 9 in the left hand column (table below).
I have played w DISTINCT and COUNT. Need a query to show how many of each
value there are.
I know there's a bone-head simple solution to this, just cant figure it
out. Thanks!
CLASS_ID STUDENT_ID
2 12
2 11
2 2
2 7
2 8
2 16
2 21
7 10
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
9 2
9 11
9 12
9 13
9 14
9 15
9 16
9 17
9 18
9 20
9 21
9 22
10 12
10 4
10 3
10 6
10 8
10 9
10 12
10 16
10 18
10 20
10 2
10 4
How to create simple poker hand class in C++
How to create simple poker hand class in C++
I am having a hard time constructing my hand class and for some reason I
keep getting an error about my _card[] is an undeclared identifier. Can I
get some help with this? As you can see I tried my effort in the hand
class. And I also I should mention that we are just now learn inheritance
for C++;
//card.h
#define Card_H
#include <string>
#include <iostream>//cout and cin
using namespace std;
//types of card
typedef enum Suit_t
{
club = 1,
diamond,
heart,
spade
}Suit_t;
//value each card holds
typedef enum Rank_t
{
two = 1,
three,
four,
five,
six,
seven,
eight,
nine,
ten,
jack ,
king ,
queen ,
ace
}Rank_t;
// card class
class Card
{
private:
Suit_t _suit;
Rank_t _rank;
public:
Card();//constructor that has no parameters
Card(Suit_t suit, Rank_t rank);//2nd constructor
//getters
Suit_t getSuit() const;
string getSuitName() const;
Rank_t getRank() const;
int getRankValue() const;
string getRankName() const;
};//card class
I am having a hard time constructing my hand class and for some reason I
keep getting an error about my _card[] is an undeclared identifier. Can I
get some help with this? As you can see I tried my effort in the hand
class. And I also I should mention that we are just now learn inheritance
for C++;
//card.h
#define Card_H
#include <string>
#include <iostream>//cout and cin
using namespace std;
//types of card
typedef enum Suit_t
{
club = 1,
diamond,
heart,
spade
}Suit_t;
//value each card holds
typedef enum Rank_t
{
two = 1,
three,
four,
five,
six,
seven,
eight,
nine,
ten,
jack ,
king ,
queen ,
ace
}Rank_t;
// card class
class Card
{
private:
Suit_t _suit;
Rank_t _rank;
public:
Card();//constructor that has no parameters
Card(Suit_t suit, Rank_t rank);//2nd constructor
//getters
Suit_t getSuit() const;
string getSuitName() const;
Rank_t getRank() const;
int getRankValue() const;
string getRankName() const;
};//card class
obj-c array handling - How to add first object?
obj-c array handling - How to add first object?
I am struggling with a noob thing. I have this loop through an initialized
array:
for (int i = 0; i < array.count; i++) {
[array addSomeObject...];
}
How do I add the first object? The loop is not executed as array.count is
0. I probably deserve to be voted down for this. Just tell me how to deal
with it :! Many thanks!
I am struggling with a noob thing. I have this loop through an initialized
array:
for (int i = 0; i < array.count; i++) {
[array addSomeObject...];
}
How do I add the first object? The loop is not executed as array.count is
0. I probably deserve to be voted down for this. Just tell me how to deal
with it :! Many thanks!
Dynamic element input select
Dynamic element input select
you know, It is the code when you click the any class, it changed and
created dynamically input and select element. I change the element's value
and then focus go out, It change text node originally. but sometimes, It
works improperly. I want to know more advanced code. please any advice!!
$(document).ready(function () {
$(".set_dt").click(function () {
var val = $(this).text();
var inp_obj = document.createElement("input");
inp_obj.type = "text";
inp_obj.value = val;
$(this).text('');
this.appendChild(inp_obj);
inp_obj.select();
$(inp_obj).bind("blur", function () {
var set_dt = inp_obj.value;
var txt_obj = document.createTextNode(set_dt);
$(inp_obj).after(txt_obj);
//data ajax transition
inp_obj.parentNode.removeChild(inp_obj);
});
});
$(".pro_st").click(function () {
var val = $(this).text();
var app_no = $(this).val();
var sel_obj = document.createElement("select");
var opt1 = document.createElement("option");
var opt2 = document.createElement("option");
opt1.value = "app_ing";
opt1.appendChild(document.createTextNode("applying"));
opt2.value = "app_ed";
opt2.appendChild(document.createTextNode("applied"));
sel_obj.appendChild(opt1);
sel_obj.appendChild(opt2);
$(this).text('');
this.appendChild(sel_obj);
for (var i = 0; i < sel_obj.length; i++) {
if (sel_obj.options[i].text == val) {
sel_obj.options[i].selected = "selected";
}
}
$(sel_obj).change(function () {
var pro_st_txt = sel_obj.options[sel_obj.selectedIndex].text;
var pro_st = sel_obj.value;
var txt_obj = document.createTextNode(pro_st_txt);
$(sel_obj).after(txt_obj);
//data ajax transition
sel_obj.parentNode.removeChild(sel_obj);
});
});
});
you know, It is the code when you click the any class, it changed and
created dynamically input and select element. I change the element's value
and then focus go out, It change text node originally. but sometimes, It
works improperly. I want to know more advanced code. please any advice!!
$(document).ready(function () {
$(".set_dt").click(function () {
var val = $(this).text();
var inp_obj = document.createElement("input");
inp_obj.type = "text";
inp_obj.value = val;
$(this).text('');
this.appendChild(inp_obj);
inp_obj.select();
$(inp_obj).bind("blur", function () {
var set_dt = inp_obj.value;
var txt_obj = document.createTextNode(set_dt);
$(inp_obj).after(txt_obj);
//data ajax transition
inp_obj.parentNode.removeChild(inp_obj);
});
});
$(".pro_st").click(function () {
var val = $(this).text();
var app_no = $(this).val();
var sel_obj = document.createElement("select");
var opt1 = document.createElement("option");
var opt2 = document.createElement("option");
opt1.value = "app_ing";
opt1.appendChild(document.createTextNode("applying"));
opt2.value = "app_ed";
opt2.appendChild(document.createTextNode("applied"));
sel_obj.appendChild(opt1);
sel_obj.appendChild(opt2);
$(this).text('');
this.appendChild(sel_obj);
for (var i = 0; i < sel_obj.length; i++) {
if (sel_obj.options[i].text == val) {
sel_obj.options[i].selected = "selected";
}
}
$(sel_obj).change(function () {
var pro_st_txt = sel_obj.options[sel_obj.selectedIndex].text;
var pro_st = sel_obj.value;
var txt_obj = document.createTextNode(pro_st_txt);
$(sel_obj).after(txt_obj);
//data ajax transition
sel_obj.parentNode.removeChild(sel_obj);
});
});
});
different layout in mobiles for same site
different layout in mobiles for same site
I have already created a website but i want to different layout in mobiles
for same site how it is possible, and is there any way to switch from
mobile to desktop view of a website?
I have already created a website but i want to different layout in mobiles
for same site how it is possible, and is there any way to switch from
mobile to desktop view of a website?
Saturday, 14 September 2013
Python script not working as required
Python script not working as required
Hello I am writing a python script to generate count of monthly and daily
visits for web pages. Input file:
ArticleName Date Hour Count/Visit
Aa 20130601 10000 1
Aa 20130601 10000 1
Ew 20130601 10000 1
H 20130601 10000 2
H 20130602 10000 1
R 20130601 20000 2
R 20130602 10000 1
Ra 20130601 0 1
Ra 20130601 10000 2
Ra 20130602 10000 1
Ram 20130601 0 2
Ram 20130601 10000 3
Ram 20130602 10000 4
Re 20130601 20000 1
Re 20130602 10000 3
Rz 20130602 10000 1
I need to count total Monthly and Daily page views of each page.
Output:
ArticleName Date DailyView MonthlyView
Aa 20130601 2 2
Ew 20130601 1 1
H 20130601 2 2
H 20130602 1 3
R 20130601 2 2
R 20130602 1 4
Ra 20130601 5 5
Ra 20130602 1 6
Ram 20130601 5 5
Ram 20130602 4 9
Re 20130601 1 1
Re 20130602 3 4
Rz 20130602 1 1
My Script:
#!/usr/bin/python
import sys
last_date = 20130601
last_hour = 0
last_count = 0
last_article = None
monthly_count = 0
daily_count = 0
for line in sys.stdin:
article, date, hour, count = line.split()
count = int(count)
date = int(date)
hour = int(hour)
#Articles match and date match
if last_article == article and last_date == date:
daily_count = count+last_count
monthly_count = count+last_count
# print '%s\t%s\t%s\t%s' % (article, date, daily_count, monthly_count)
#Article match but date doesn't match
if last_article == article and last_date != date:
monthly_count = count
daily_count=count
print '%s\t%s\t%s\t%s' % (article, date, daily_count,
monthly_count)
#Article doesn't match
if last_article != article:
last_article = article
last_count = count
monthly_count = count
daily_count=count
last_date = date
print '%s\t%s\t%s\t%s' % (article, date, daily_count,
monthly_count)
I am able to get most of the output but my output is wrong for two
condition: 1. Couldn't get a way to sum up the ArticleName if ArticleName
and ArticleDate are same. For eg this script gives output for row Ra:
Ra 20130601 1 1
Ra 20130601 3 3
Ra 20130602 1 1
So at the end Ra should print 1+3+1=5 as final total monthly count instead
of 1.
Since I output in the 3rd if condition all the articles which are not
equal to last article I get the value of an article with same article name
and date twice. Like: Ra 20130601 1 1 should not have been printed. Does
anybody know how to correct this? Let me know if you need any more
information.
Hello I am writing a python script to generate count of monthly and daily
visits for web pages. Input file:
ArticleName Date Hour Count/Visit
Aa 20130601 10000 1
Aa 20130601 10000 1
Ew 20130601 10000 1
H 20130601 10000 2
H 20130602 10000 1
R 20130601 20000 2
R 20130602 10000 1
Ra 20130601 0 1
Ra 20130601 10000 2
Ra 20130602 10000 1
Ram 20130601 0 2
Ram 20130601 10000 3
Ram 20130602 10000 4
Re 20130601 20000 1
Re 20130602 10000 3
Rz 20130602 10000 1
I need to count total Monthly and Daily page views of each page.
Output:
ArticleName Date DailyView MonthlyView
Aa 20130601 2 2
Ew 20130601 1 1
H 20130601 2 2
H 20130602 1 3
R 20130601 2 2
R 20130602 1 4
Ra 20130601 5 5
Ra 20130602 1 6
Ram 20130601 5 5
Ram 20130602 4 9
Re 20130601 1 1
Re 20130602 3 4
Rz 20130602 1 1
My Script:
#!/usr/bin/python
import sys
last_date = 20130601
last_hour = 0
last_count = 0
last_article = None
monthly_count = 0
daily_count = 0
for line in sys.stdin:
article, date, hour, count = line.split()
count = int(count)
date = int(date)
hour = int(hour)
#Articles match and date match
if last_article == article and last_date == date:
daily_count = count+last_count
monthly_count = count+last_count
# print '%s\t%s\t%s\t%s' % (article, date, daily_count, monthly_count)
#Article match but date doesn't match
if last_article == article and last_date != date:
monthly_count = count
daily_count=count
print '%s\t%s\t%s\t%s' % (article, date, daily_count,
monthly_count)
#Article doesn't match
if last_article != article:
last_article = article
last_count = count
monthly_count = count
daily_count=count
last_date = date
print '%s\t%s\t%s\t%s' % (article, date, daily_count,
monthly_count)
I am able to get most of the output but my output is wrong for two
condition: 1. Couldn't get a way to sum up the ArticleName if ArticleName
and ArticleDate are same. For eg this script gives output for row Ra:
Ra 20130601 1 1
Ra 20130601 3 3
Ra 20130602 1 1
So at the end Ra should print 1+3+1=5 as final total monthly count instead
of 1.
Since I output in the 3rd if condition all the articles which are not
equal to last article I get the value of an article with same article name
and date twice. Like: Ra 20130601 1 1 should not have been printed. Does
anybody know how to correct this? Let me know if you need any more
information.
Travis project failing but not on own server
Travis project failing but not on own server
I'm pulling my hair out trying to fix the issues in my Travis CI build
failling. I can't seem to find out why it's working locally (probably a
configuration setting) but doesn't work on Travis CI.
My project is located at https://travis-ci.org/crazycodr/data-grouper on
Travis CI and the source is at https://github.com/crazycodr/data-grouper.
I have several issues in my build all related to
/src/CrazyCodr/Data/Grouper/GroupResult.php:447
But i don't see anything passed by reference over there so it's either a
configuration issues or something i just don't get!
Further more, if one could find out why i only have 65/68 tests being
run... I really don't get why i'm having this too, i check all my test
files and there are no test without an assertion or an @exceptedException
so i'm a bit clueless as to what is hapenning there... Note i have the
65/68 problem on both servers but the Reference error in the build is only
on Travis CI.
I'm pulling my hair out trying to fix the issues in my Travis CI build
failling. I can't seem to find out why it's working locally (probably a
configuration setting) but doesn't work on Travis CI.
My project is located at https://travis-ci.org/crazycodr/data-grouper on
Travis CI and the source is at https://github.com/crazycodr/data-grouper.
I have several issues in my build all related to
/src/CrazyCodr/Data/Grouper/GroupResult.php:447
But i don't see anything passed by reference over there so it's either a
configuration issues or something i just don't get!
Further more, if one could find out why i only have 65/68 tests being
run... I really don't get why i'm having this too, i check all my test
files and there are no test without an assertion or an @exceptedException
so i'm a bit clueless as to what is hapenning there... Note i have the
65/68 problem on both servers but the Reference error in the build is only
on Travis CI.
Why am I unable to print my number constant in NASM Assembly?
Why am I unable to print my number constant in NASM Assembly?
Learning NASM Assembly in 32-bit Ubuntu. I am somewhat confused:
In .bss, I reserve a byte for a variable:
num resb 1
Later I decided to give it a value of 5:
mov byte [num],5
And at some point print it out:
mov EAX,4
mov EBX,0
mov ECX,num
add ECX,'0' ; From decimal to ASCII
mov EDX,1
int 0x80
But it isn't printing anything.
I'm guessing that the problem is when I give num its value of 5. I
originally wanted to do this:
mov byte num,5
As I thought that num refers to a position in memory, and so mov would
copy 5 to such position. But I got an error saying
invalid combination of opcode and operands
So basically, why is the program not printing 5? And also, why was my
suggestion above invalid?
Learning NASM Assembly in 32-bit Ubuntu. I am somewhat confused:
In .bss, I reserve a byte for a variable:
num resb 1
Later I decided to give it a value of 5:
mov byte [num],5
And at some point print it out:
mov EAX,4
mov EBX,0
mov ECX,num
add ECX,'0' ; From decimal to ASCII
mov EDX,1
int 0x80
But it isn't printing anything.
I'm guessing that the problem is when I give num its value of 5. I
originally wanted to do this:
mov byte num,5
As I thought that num refers to a position in memory, and so mov would
copy 5 to such position. But I got an error saying
invalid combination of opcode and operands
So basically, why is the program not printing 5? And also, why was my
suggestion above invalid?
Windows Store Application Place SQLite File in LocalState Folder
Windows Store Application Place SQLite File in LocalState Folder
I am building a Windows 8 application using sql-net and mvvmcross for data
access to a sqlite database. This would be applicable to any Win-8 or
Win-Phone app.
I need to install an existing sqlite file on app start.
When using the connection you use syntax such as this
public FlashCardManager(ISQLiteConnectionFactory factory, IMvxMessenger
messenger)
{
_messenger = messenger;
_connection = factory.Create("Dictionary.sqlite");
_connection.CreateTable<FlashCardSet>();
_connection.CreateTable<FlashCard>();
}
public void CreateCard(FlashCard flashCard)
{
_connection.Insert(flashCard);
}
That connection creates a file in:
C:\Users\USER\AppData\Local\Packages\793fd702-171e-474f-ab3b-d9067c58709b_ka9b83fa3fse2\LocalState
My application uses an existing sqlite database file that I have created.
I need to place it in this folder when the application is installed. How
would I go about doing this?
Thanks, JH
I am building a Windows 8 application using sql-net and mvvmcross for data
access to a sqlite database. This would be applicable to any Win-8 or
Win-Phone app.
I need to install an existing sqlite file on app start.
When using the connection you use syntax such as this
public FlashCardManager(ISQLiteConnectionFactory factory, IMvxMessenger
messenger)
{
_messenger = messenger;
_connection = factory.Create("Dictionary.sqlite");
_connection.CreateTable<FlashCardSet>();
_connection.CreateTable<FlashCard>();
}
public void CreateCard(FlashCard flashCard)
{
_connection.Insert(flashCard);
}
That connection creates a file in:
C:\Users\USER\AppData\Local\Packages\793fd702-171e-474f-ab3b-d9067c58709b_ka9b83fa3fse2\LocalState
My application uses an existing sqlite database file that I have created.
I need to place it in this folder when the application is installed. How
would I go about doing this?
Thanks, JH
How can I log out users when they close their browser?
How can I log out users when they close their browser?
I am trying to make a chat room . In Session_Start() in Global.asax I have
added user to Onlineusers list . And in Session_End I delete it from
onlineusers table . But it removes the username after 20 minutes . How can
i resolve this problem ?
Shall i use another method ?
I am trying to make a chat room . In Session_Start() in Global.asax I have
added user to Onlineusers list . And in Session_End I delete it from
onlineusers table . But it removes the username after 20 minutes . How can
i resolve this problem ?
Shall i use another method ?
MySQL multiple fields foreign key referencing to single field
MySQL multiple fields foreign key referencing to single field
I have languages table which looks like that:
-id
-name
-iso
and in multiple tables I need to reference this iso field as foreign key.
The problem is, I can't do it even if I give completely unique FK names.
What is problem?
I have languages table which looks like that:
-id
-name
-iso
and in multiple tables I need to reference this iso field as foreign key.
The problem is, I can't do it even if I give completely unique FK names.
What is problem?
what to do to get 3 products in eacyh row in "featured products" module in prestashop
what to do to get 3 products in eacyh row in "featured products" module in
prestashop
I am not able to keep only 3 products in each row of the featured products
module in Prestashop. Will please any one help me? i have tried to change
the width in homefeatured.tpl but did not get the solution.
prestashop
I am not able to keep only 3 products in each row of the featured products
module in Prestashop. Will please any one help me? i have tried to change
the width in homefeatured.tpl but did not get the solution.
why libvirtd fails to create vm with internal error 'cpuacct', 'devices' & 'memory' cgroups controllers must be mounted?
why libvirtd fails to create vm with internal error 'cpuacct', 'devices' &
'memory' cgroups controllers must be mounted?
To try out LXC on CentOS 6.4 host, I followed the steps in
http://wiki.centos.org/HowTos/LXC-on-CentOS6, but it fails with ERROR:
internal error 'cpuacct', 'devices' & 'memory' cgroups controllers must be
mounted, when install vm using virt-install.
'memory' cgroups controllers must be mounted?
To try out LXC on CentOS 6.4 host, I followed the steps in
http://wiki.centos.org/HowTos/LXC-on-CentOS6, but it fails with ERROR:
internal error 'cpuacct', 'devices' & 'memory' cgroups controllers must be
mounted, when install vm using virt-install.
Friday, 13 September 2013
How to make a responsive image gallery?
How to make a responsive image gallery?
I'm trying to create a responsive gallery of fixed-width images. I need
the number of images on a given row to vary based on the width of the
browser window, and the row of images to be centered on the page.
Either of two ways is fine. There can be a constant number of pixels
between each image (10px for instance), and the container div can change
width to match. Or the container div can be fixed-width, and the distance
between the images varies to fit.
Thanks in advance
I'm trying to create a responsive gallery of fixed-width images. I need
the number of images on a given row to vary based on the width of the
browser window, and the row of images to be centered on the page.
Either of two ways is fine. There can be a constant number of pixels
between each image (10px for instance), and the container div can change
width to match. Or the container div can be fixed-width, and the distance
between the images varies to fit.
Thanks in advance
Process PHP Script in HTML Template
Process PHP Script in HTML Template
I've been working on a template system for the past few weeks. Here's a
basic rundown of the function. I use file_get_contents() to get the HTML
template, then I use a parameter replacement function to replace variables
wrapped in %'s (ex: %title% replaced by <title> Here's my title!
</title>).
After both of those, I use return to, for lack of a better word, return,
the parameter-filtered data. But, what would be the best way to execute
PHP? One idea I had was simply including the parameter-filtered page into
index.php, but I can't really do that.
Keep in mind, I want this to be a flexible script, so please make it so I
can write the code straight into my function.
I've been working on a template system for the past few weeks. Here's a
basic rundown of the function. I use file_get_contents() to get the HTML
template, then I use a parameter replacement function to replace variables
wrapped in %'s (ex: %title% replaced by <title> Here's my title!
</title>).
After both of those, I use return to, for lack of a better word, return,
the parameter-filtered data. But, what would be the best way to execute
PHP? One idea I had was simply including the parameter-filtered page into
index.php, but I can't really do that.
Keep in mind, I want this to be a flexible script, so please make it so I
can write the code straight into my function.
How to merge two database tables when only some fields are common?
How to merge two database tables when only some fields are common?
In MS Access I have two tables (A and B), and the task is to insert B into
A. However, there are some special conditions:
All fields are of type text.
A and B have a some common fields.
The same key field is guaranteed to exist in both, and its values to be
always different.
A has some fields that B does not have. The inserted records should have
those fields blank.
B has some fields that A does not have. These fields must be created in A,
and the existing records in A should have them blank.
There are many cases like this one, so the query should not explicitly
include the field names, since it would be tedious to personalize the
query for each case. However, the key field is always named the same.
Creating a new table C instead of directly replacing A is acceptable.
Example:
Table A:
key field_a field_b field_c
--- ------- ------- -------
k0 hello dear world
k1 bye cruel world
Table B:
key field_a field_d field_e
--- ------- ------- -------
k2 welcome john doe
k3 turulu ann harp
Table C (the new A):
key field_a field_b field_c field_d field_e
--- ------- ------- ------- ------- -------
k0 hello dear world
k1 bye cruel world
k2 welcome john doe
k3 turulu ann harp
In MS Access I have two tables (A and B), and the task is to insert B into
A. However, there are some special conditions:
All fields are of type text.
A and B have a some common fields.
The same key field is guaranteed to exist in both, and its values to be
always different.
A has some fields that B does not have. The inserted records should have
those fields blank.
B has some fields that A does not have. These fields must be created in A,
and the existing records in A should have them blank.
There are many cases like this one, so the query should not explicitly
include the field names, since it would be tedious to personalize the
query for each case. However, the key field is always named the same.
Creating a new table C instead of directly replacing A is acceptable.
Example:
Table A:
key field_a field_b field_c
--- ------- ------- -------
k0 hello dear world
k1 bye cruel world
Table B:
key field_a field_d field_e
--- ------- ------- -------
k2 welcome john doe
k3 turulu ann harp
Table C (the new A):
key field_a field_b field_c field_d field_e
--- ------- ------- ------- ------- -------
k0 hello dear world
k1 bye cruel world
k2 welcome john doe
k3 turulu ann harp
What does in Java mean?
What does in Java mean?
Tried to google it but not sure how to phrase it! Tilde in between angular
brackets?! Did not return anything..I know < T > is a generic, not sure
what generic a tilde represents.
Tried to google it but not sure how to phrase it! Tilde in between angular
brackets?! Did not return anything..I know < T > is a generic, not sure
what generic a tilde represents.
C# - Split string by lines?
C# - Split string by lines?
Let's say, for example, I have the following string downloaded from a .txt
file in the web.
line1
line2
line3
How can I split the whole string by lines, so I can use splitted[0] to get
line1, splitted[1] to get line 2, etc..? Thanks!
Can I use?
string[] tokens = Regex.Split(input, @"\r?\n|\r");
Thanks
Let's say, for example, I have the following string downloaded from a .txt
file in the web.
line1
line2
line3
How can I split the whole string by lines, so I can use splitted[0] to get
line1, splitted[1] to get line 2, etc..? Thanks!
Can I use?
string[] tokens = Regex.Split(input, @"\r?\n|\r");
Thanks
Thursday, 12 September 2013
PyQt4 Toolbar Button Alignment
PyQt4 Toolbar Button Alignment
I have this code
Menu = self.menuBar()
EditMenu = Menu.addMenu("&File")
OptionMenu = Menu.addMenu("&Options")
HelpMenu = Menu.addMenu("&Help")
EditMenu.addActions((fileNewAction,faultAction,storeAction,localAction,scheduleAction))
OptionMenu.addAction(settingAction)
Toolbar = QtGui.QToolBar()
Toolbar.setIconSize(QtCore.QSize(50,50))
Toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon|QtCore.Qt.AlignLeading)
#<= Toolbuttonstyle
self.addToolBar(QtCore.Qt.LeftToolBarArea,Toolbar)
Toolbar.addActions((fileNewAction,faultAction,scheduleAction,storeAction,localAction,settingAction))
settings = QtCore.QSettings()
self.restoreGeometry(settings.value("Geometry").toByteArray())
which give me this
i used
Toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon|QtCore.Qt.AlignLeading)
to display the text on the right side of the toolbar button and to align
all the toolbar button images to the left. But the texts are not appearing
on the right side.
If i remove the QtCore.Qt.AlignLeading,
I get unaligned (left side) buttons like this
(1) How do i get my toolbar button icons align to the left and display the
text on the right side at the same time?
Another question is
(2) How do i adjust the width of the raised button effect when i mouse
over on each button? I want the width of all the buttons to be the same.
The width seems to be different depending on how long the text is.
I have this code
Menu = self.menuBar()
EditMenu = Menu.addMenu("&File")
OptionMenu = Menu.addMenu("&Options")
HelpMenu = Menu.addMenu("&Help")
EditMenu.addActions((fileNewAction,faultAction,storeAction,localAction,scheduleAction))
OptionMenu.addAction(settingAction)
Toolbar = QtGui.QToolBar()
Toolbar.setIconSize(QtCore.QSize(50,50))
Toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon|QtCore.Qt.AlignLeading)
#<= Toolbuttonstyle
self.addToolBar(QtCore.Qt.LeftToolBarArea,Toolbar)
Toolbar.addActions((fileNewAction,faultAction,scheduleAction,storeAction,localAction,settingAction))
settings = QtCore.QSettings()
self.restoreGeometry(settings.value("Geometry").toByteArray())
which give me this
i used
Toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon|QtCore.Qt.AlignLeading)
to display the text on the right side of the toolbar button and to align
all the toolbar button images to the left. But the texts are not appearing
on the right side.
If i remove the QtCore.Qt.AlignLeading,
I get unaligned (left side) buttons like this
(1) How do i get my toolbar button icons align to the left and display the
text on the right side at the same time?
Another question is
(2) How do i adjust the width of the raised button effect when i mouse
over on each button? I want the width of all the buttons to be the same.
The width seems to be different depending on how long the text is.
How to convert string Date to Timestamp in Java for the format dd-MMM-yyyy?
How to convert string Date to Timestamp in Java for the format dd-MMM-yyyy?
I want to convert string Date to Timestamp in java. The following are the
codes that I have written. The date value passed is in the format
19-SEP-2013.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
Date date = dateFormat.parse(tcmo.getCtsDate());
ps.setTimestamp(ctr++, new Timestamp(date.getTime());
The variable ctr is declared already. ps is the PreparedStatement object.
Later codes include ps.executeUpdate().
tcmo.getCtsDate() returns the value 19-Sep-2013.
Database can accept only Timestamp in the format 2013-09-19 00:00:00.0
The exception thrown is Unparseable Date "19-SEP-2013". can anyone help me
to clear this?
I want to convert string Date to Timestamp in java. The following are the
codes that I have written. The date value passed is in the format
19-SEP-2013.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
Date date = dateFormat.parse(tcmo.getCtsDate());
ps.setTimestamp(ctr++, new Timestamp(date.getTime());
The variable ctr is declared already. ps is the PreparedStatement object.
Later codes include ps.executeUpdate().
tcmo.getCtsDate() returns the value 19-Sep-2013.
Database can accept only Timestamp in the format 2013-09-19 00:00:00.0
The exception thrown is Unparseable Date "19-SEP-2013". can anyone help me
to clear this?
Novice issue of this jQuery code not working
Novice issue of this jQuery code not working
I'm really new to jQuery, and I want this code to show an alert box when
the button is pressed.
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$("button").click(function() {
alert("You clicked.");
});
</script>
<button>Button</button>
I try it, and nothing happens when I click the button.
I'm really new to jQuery, and I want this code to show an alert box when
the button is pressed.
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$("button").click(function() {
alert("You clicked.");
});
</script>
<button>Button</button>
I try it, and nothing happens when I click the button.
Finally dispose of connection
Finally dispose of connection
I am connecting to an IBM Websphere MQ server in my .Net code and I wanted
to make sure that I am following best practice when using "finally".
I currently have the below code block which I believe can be modified to
just have the close portion in the finally clause. Is that correct? (I am
catching errors in the calling portion of the application).
try
{
var queueDepth = qmgr.AccessQueue(userQueue,
MQC.MQOO_INPUT_AS_Q_DEF +
MQC.MQOO_FAIL_IF_QUIESCING +
MQC.MQOO_INQUIRE).CurrentDepth;
if (qmgr.IsOpen)
qmgr.Close();
return queueDepth;
}
finally
{
if (qmgr.IsOpen)
qmgr.Close();
}
Is now this
try
{
var queueDepth = qmgr.AccessQueue(userQueue,
MQC.MQOO_INPUT_AS_Q_DEF +
MQC.MQOO_FAIL_IF_QUIESCING +
MQC.MQOO_INQUIRE).CurrentDepth;
return queueDepth;
}
finally
{
if (qmgr.IsOpen)
qmgr.Close();
}
I am connecting to an IBM Websphere MQ server in my .Net code and I wanted
to make sure that I am following best practice when using "finally".
I currently have the below code block which I believe can be modified to
just have the close portion in the finally clause. Is that correct? (I am
catching errors in the calling portion of the application).
try
{
var queueDepth = qmgr.AccessQueue(userQueue,
MQC.MQOO_INPUT_AS_Q_DEF +
MQC.MQOO_FAIL_IF_QUIESCING +
MQC.MQOO_INQUIRE).CurrentDepth;
if (qmgr.IsOpen)
qmgr.Close();
return queueDepth;
}
finally
{
if (qmgr.IsOpen)
qmgr.Close();
}
Is now this
try
{
var queueDepth = qmgr.AccessQueue(userQueue,
MQC.MQOO_INPUT_AS_Q_DEF +
MQC.MQOO_FAIL_IF_QUIESCING +
MQC.MQOO_INQUIRE).CurrentDepth;
return queueDepth;
}
finally
{
if (qmgr.IsOpen)
qmgr.Close();
}
How can I add more time-series data after drawing a D3 line chart?
How can I add more time-series data after drawing a D3 line chart?
I have a D3 line chart that loads and displays a lot of live streaming
data. In order to make the UI feel faster, I am progressively rendering
the chart as data comes in in chunks. So, for example, I may be showing a
chart that spans 15 minutes, but load the latest 5 minutes, then load the
data from 10 minutes ago, then 15 minutes ago. In that time, I'll
re-render the chart 3 times.
My problem is that when I re-render the chart, a line is drawn across the
entire chart.
This is best explained through an example:
var end_ts = new Date().getTime();
var range = 60000;
var start_ts = end_ts - range;
var n = 30,
random = d3.random.normal(0, .2),
data = d3.range(n).map(function(i) {
return { time:new Date(end_ts - (n*1000) + i*1000), value:random() };
});
var margin = {top: 20, right: 20, bottom: 20, left: 40},
width = 500 - margin.left - margin.right,
height = 300 - margin.top - margin.bottom;
var x = d3.time.scale()
.domain([new Date(start_ts), new Date(end_ts)])
.range([0, width]);
var y = d3.scale.linear()
.domain([-1, 1])
.range([height, 0]);
var line = d3.svg.line()
.x(function(d, i) { return x(d.time); })
.y(function(d, i) { return y(d.value); });
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("defs").append("clipPath")
.attr("id", "clip")
.append("rect")
.attr("width", width)
.attr("height", height);
var xAxis = d3.svg.axis().scale(x).orient("bottom")
var xAxisGroup = svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + y(0) + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
var path = svg.append("g")
.attr("clip-path", "url(#clip)")
.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
// Render the first time
path.attr("d", line)
// Add some more data
for (var i=0; i < 10; i++)
data.push({time: new Date(start_ts+5000+i*1000), value: random()});
// Render the second time
path.attr("d", line)
See this on jsfiddle: http://jsfiddle.net/DANuz/
Anyone know how to add data to a chart and make this work? Note that it is
important that I am adding the newest data first, then older data later.
That's the behavior that I need.
Thanks.
I have a D3 line chart that loads and displays a lot of live streaming
data. In order to make the UI feel faster, I am progressively rendering
the chart as data comes in in chunks. So, for example, I may be showing a
chart that spans 15 minutes, but load the latest 5 minutes, then load the
data from 10 minutes ago, then 15 minutes ago. In that time, I'll
re-render the chart 3 times.
My problem is that when I re-render the chart, a line is drawn across the
entire chart.
This is best explained through an example:
var end_ts = new Date().getTime();
var range = 60000;
var start_ts = end_ts - range;
var n = 30,
random = d3.random.normal(0, .2),
data = d3.range(n).map(function(i) {
return { time:new Date(end_ts - (n*1000) + i*1000), value:random() };
});
var margin = {top: 20, right: 20, bottom: 20, left: 40},
width = 500 - margin.left - margin.right,
height = 300 - margin.top - margin.bottom;
var x = d3.time.scale()
.domain([new Date(start_ts), new Date(end_ts)])
.range([0, width]);
var y = d3.scale.linear()
.domain([-1, 1])
.range([height, 0]);
var line = d3.svg.line()
.x(function(d, i) { return x(d.time); })
.y(function(d, i) { return y(d.value); });
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("defs").append("clipPath")
.attr("id", "clip")
.append("rect")
.attr("width", width)
.attr("height", height);
var xAxis = d3.svg.axis().scale(x).orient("bottom")
var xAxisGroup = svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + y(0) + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
var path = svg.append("g")
.attr("clip-path", "url(#clip)")
.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
// Render the first time
path.attr("d", line)
// Add some more data
for (var i=0; i < 10; i++)
data.push({time: new Date(start_ts+5000+i*1000), value: random()});
// Render the second time
path.attr("d", line)
See this on jsfiddle: http://jsfiddle.net/DANuz/
Anyone know how to add data to a chart and make this work? Note that it is
important that I am adding the newest data first, then older data later.
That's the behavior that I need.
Thanks.
show/hide fragments and adding it to backstack
show/hide fragments and adding it to backstack
I have a menu with 4 menu options... Each of these options shows the
corresponding fragment. I have 3 functions to add,show and hide a
fragment:
private void addFragment(Fragment newFragment, String fragmentName) {
fragmentManager
.beginTransaction()
.add(R.id.content_frame, newFragment,
fragmentName).addToBackStack(null)
.commit();
}
private void hideFragment(Fragment existingFragment) {
if(existingFragment!=null && existingFragment.isVisible()){
fragmentManager.beginTransaction().hide(existingFragment).addToBackStack(null).commit();
}
}
private void showFragment(Fragment existingFragment) {
if(existingFragment!=null){
fragmentManager.beginTransaction().show(existingFragment)
.addToBackStack(null).commit();
}
}
The navitemswitchlogic is as follows:
onNavItemSelected(int id) {
switch (id) {
case 1: //option 1 - hide rest of the fragments and show
Option1Fragment
hideFragment(option2Fragment);
hideFragment(option3Fragment);
hideFragment(option4Fragment);
if (Option1FragmentDoesnotExist) { //create option1Fragment
and add it to FragmentTransaction
option1Fragment = new option1Fragment();
addFragment(option1Fragment,"option1Fragment");
} else
showFragment(option1Fragment);
break;
case 2:
//same as option 1
}
}
Problem: When I go from Fragment 1 to 2 and hit back button - an empty
screen shows up.. hitting back again takes me to fragment 1.. now, when I
try loading fragment 2 from the menu an empty screen shows up.. I know I
am making some mistake adding and retrieving fragments to/from the
backstack..But,I am not sure what exactly it is. Also, I dont want to
replace the fragments... Hope I framed my question right.. Any help is
appreciated.Thanks!
I have a menu with 4 menu options... Each of these options shows the
corresponding fragment. I have 3 functions to add,show and hide a
fragment:
private void addFragment(Fragment newFragment, String fragmentName) {
fragmentManager
.beginTransaction()
.add(R.id.content_frame, newFragment,
fragmentName).addToBackStack(null)
.commit();
}
private void hideFragment(Fragment existingFragment) {
if(existingFragment!=null && existingFragment.isVisible()){
fragmentManager.beginTransaction().hide(existingFragment).addToBackStack(null).commit();
}
}
private void showFragment(Fragment existingFragment) {
if(existingFragment!=null){
fragmentManager.beginTransaction().show(existingFragment)
.addToBackStack(null).commit();
}
}
The navitemswitchlogic is as follows:
onNavItemSelected(int id) {
switch (id) {
case 1: //option 1 - hide rest of the fragments and show
Option1Fragment
hideFragment(option2Fragment);
hideFragment(option3Fragment);
hideFragment(option4Fragment);
if (Option1FragmentDoesnotExist) { //create option1Fragment
and add it to FragmentTransaction
option1Fragment = new option1Fragment();
addFragment(option1Fragment,"option1Fragment");
} else
showFragment(option1Fragment);
break;
case 2:
//same as option 1
}
}
Problem: When I go from Fragment 1 to 2 and hit back button - an empty
screen shows up.. hitting back again takes me to fragment 1.. now, when I
try loading fragment 2 from the menu an empty screen shows up.. I know I
am making some mistake adding and retrieving fragments to/from the
backstack..But,I am not sure what exactly it is. Also, I dont want to
replace the fragments... Hope I framed my question right.. Any help is
appreciated.Thanks!
TcpClient connection attempts in C#
TcpClient connection attempts in C#
I have a simple program. I wanted to check if the server actually is
online so my users can connect to it before doing stuff, so on the form
load event I have the following:
private void frmMain_Load(object sender, EventArgs e)
{
try
{
tcp.Connect("110.174.194.138", 8484);
MessageBox.Show("siccces");
}
catch
{
MessageBox.Show("failed");
}
if (tcp.Connected)
{
//do whatever once program has connected.
}
else
{
MessageBox.Show("FAILED");
}
}
It all works fine when the server is online (and it can connect). It
connects in 0.1 seconds and nothing bad happens .However, when the server
is off, it attempts to reconnect about 5 times I think, which takes up to
15 seconds. How can I make it attempt to connect only once so I can show a
failed message instantly?
Thanks.
I have a simple program. I wanted to check if the server actually is
online so my users can connect to it before doing stuff, so on the form
load event I have the following:
private void frmMain_Load(object sender, EventArgs e)
{
try
{
tcp.Connect("110.174.194.138", 8484);
MessageBox.Show("siccces");
}
catch
{
MessageBox.Show("failed");
}
if (tcp.Connected)
{
//do whatever once program has connected.
}
else
{
MessageBox.Show("FAILED");
}
}
It all works fine when the server is online (and it can connect). It
connects in 0.1 seconds and nothing bad happens .However, when the server
is off, it attempts to reconnect about 5 times I think, which takes up to
15 seconds. How can I make it attempt to connect only once so I can show a
failed message instantly?
Thanks.
Can't use static library without adding header files in iOS
Can't use static library without adding header files in iOS
I followed this below link in order to use static library alone by adding
just .a file and not including header files.
http://muthukumarela.wordpress.com/2012/05/24/ios-static-libraries-without-adding-header-files/#comments
But still it gives me an error
Please guide someone.
Thanks in advance
I followed this below link in order to use static library alone by adding
just .a file and not including header files.
http://muthukumarela.wordpress.com/2012/05/24/ios-static-libraries-without-adding-header-files/#comments
But still it gives me an error
Please guide someone.
Thanks in advance
how to get callback value from cameratag in controller rails
how to get callback value from cameratag in controller rails
How to get callback value from cameratag in controller rails?
How to use below code in controller rails in tutorial server callback?
data = JSON.parse(request.raw_post)
video_uuid = data["uuid"]
How to get callback value from cameratag in controller rails?
How to use below code in controller rails in tutorial server callback?
data = JSON.parse(request.raw_post)
video_uuid = data["uuid"]
Wednesday, 11 September 2013
CAD: programatically create models
CAD: programatically create models
I want to create a CAD model for the purpose of finding its properties
like mass, CG, inertia etc.
I want to do this programmatically because i have to vary the model
slightly and get the new properties
What CAD software should i look into? maybe Inventor, Solidworks, FreeCAD,
Sketchup (Pro or Make?)
thanks
I want to create a CAD model for the purpose of finding its properties
like mass, CG, inertia etc.
I want to do this programmatically because i have to vary the model
slightly and get the new properties
What CAD software should i look into? maybe Inventor, Solidworks, FreeCAD,
Sketchup (Pro or Make?)
thanks
ZF2 form collections. Elements that added dynamically completely ignored
ZF2 form collections. Elements that added dynamically completely ignored
I use ZF2 form collections
I create collection:
'type' => 'Zend\Form\Element\Collection',
'name' => 'domains',
'options' => array(
'count' => 2,
'should_create_template' => true,
'allow_add' => true,
'target_element' => array(
'type' => 'loginzaFieldset'
)
)
It works fine when I fill in two copies of fieldset "loginzaFieldset". But
when I dynamically add another one copy and save the form, third fieldset
is ignored. (When I call $form->getData() it returns only first and second
fieldset in array)
I use ZF2 form collections
I create collection:
'type' => 'Zend\Form\Element\Collection',
'name' => 'domains',
'options' => array(
'count' => 2,
'should_create_template' => true,
'allow_add' => true,
'target_element' => array(
'type' => 'loginzaFieldset'
)
)
It works fine when I fill in two copies of fieldset "loginzaFieldset". But
when I dynamically add another one copy and save the form, third fieldset
is ignored. (When I call $form->getData() it returns only first and second
fieldset in array)
SQL Left Join losing rows after filtering
SQL Left Join losing rows after filtering
I have a multi-table join (only two shown in example) where I need to
retain all rows from the base table. Obviously I use a LEFT JOIN to
include all rows on the base table. Without the WHERE clause it works
great – When a row doesn't exist in the Right table the row from the Left
table still shows, just with a 0 from the column in the Right table. The
first two rows in the dataset are Labels from the Left table and Count of
rows from the Right table, grouped by Label. All I want is a count of 0
when a label does not have a value from Table2 assigned.
Table1
Label | FK
Blue | 1
Red | 2
Green | 3
Table2
Values Color Date
Dog | 1 | 02/02/2010
Cat | 2 | 02/02/2010
Dog | 1 | 02/02/2010
Cat | 2 | 02/02/2010
SELECT 1.Label, COUNT(2.values)
FROM Table1 1
LEFT JOIN Table2 2 ON 1.fk = 1.pk
GROUP BY 1.Label
Good Result Set - No filters
Blue | 2
Red | 2
Green | 0
Great!
My issue is that when I add filtering criteria to remove rows from the
Right table the row is removed for my Left join rows (zeroing them out),
the Left rows are dropped. I need the Left rows to remain even if their
count is filtered down to zero.
SELECT 1.Label, COUNT(2.values)
FROM Table1 1
LEFT JOIN Table2 2 ON 1.fk = 1.pk
WHERE 2.Date BETWEEN 1/1/2010 AND 12/31/2010
GROUP BY 1.Label
Bummer Result Set - After Filters
Blue | 2
Red | 2
Dukes!
So, what the hell? Do I need to get a temp table with the filtered dataset
THEN join it to the Left table? What am I missing? Thanks!
Do a second join or recursive join. Get my "good" join table, get a second
"filtered" table, then LEFT JOIN them
I have a multi-table join (only two shown in example) where I need to
retain all rows from the base table. Obviously I use a LEFT JOIN to
include all rows on the base table. Without the WHERE clause it works
great – When a row doesn't exist in the Right table the row from the Left
table still shows, just with a 0 from the column in the Right table. The
first two rows in the dataset are Labels from the Left table and Count of
rows from the Right table, grouped by Label. All I want is a count of 0
when a label does not have a value from Table2 assigned.
Table1
Label | FK
Blue | 1
Red | 2
Green | 3
Table2
Values Color Date
Dog | 1 | 02/02/2010
Cat | 2 | 02/02/2010
Dog | 1 | 02/02/2010
Cat | 2 | 02/02/2010
SELECT 1.Label, COUNT(2.values)
FROM Table1 1
LEFT JOIN Table2 2 ON 1.fk = 1.pk
GROUP BY 1.Label
Good Result Set - No filters
Blue | 2
Red | 2
Green | 0
Great!
My issue is that when I add filtering criteria to remove rows from the
Right table the row is removed for my Left join rows (zeroing them out),
the Left rows are dropped. I need the Left rows to remain even if their
count is filtered down to zero.
SELECT 1.Label, COUNT(2.values)
FROM Table1 1
LEFT JOIN Table2 2 ON 1.fk = 1.pk
WHERE 2.Date BETWEEN 1/1/2010 AND 12/31/2010
GROUP BY 1.Label
Bummer Result Set - After Filters
Blue | 2
Red | 2
Dukes!
So, what the hell? Do I need to get a temp table with the filtered dataset
THEN join it to the Left table? What am I missing? Thanks!
Do a second join or recursive join. Get my "good" join table, get a second
"filtered" table, then LEFT JOIN them
Making a FOR (batch file) search creates an infinite loop. How do I stop it?
Making a FOR (batch file) search creates an infinite loop. How do I stop it?
The following command creates an infinite loop which is not what I want
since I am iterating through files and it needs to end sometime...
Here is what I have:
cd C:\
FOR /R %i IN (*.pst) do @echo %i
See what happens is that when it reaches AppData and finds a .pst (in
AppData\Local\Microsoft\Outlook) there is a shortcut folder inside
AppData\Local called "Application Data" which loops back to AppData\Local
but keeps adding it's name to the address like so:
%AppData%\Local\Application Data\Application Data\Application
Data\Microsoft\Outlook\%filename%.pst
What could I add to my code to keep it from looping or much better to
completely ignore shortcuts so that the loop ends when it finds all the
files that I need?
The following command creates an infinite loop which is not what I want
since I am iterating through files and it needs to end sometime...
Here is what I have:
cd C:\
FOR /R %i IN (*.pst) do @echo %i
See what happens is that when it reaches AppData and finds a .pst (in
AppData\Local\Microsoft\Outlook) there is a shortcut folder inside
AppData\Local called "Application Data" which loops back to AppData\Local
but keeps adding it's name to the address like so:
%AppData%\Local\Application Data\Application Data\Application
Data\Microsoft\Outlook\%filename%.pst
What could I add to my code to keep it from looping or much better to
completely ignore shortcuts so that the loop ends when it finds all the
files that I need?
k2 notify and recaptcha error
k2 notify and recaptcha error
I use on my joomla website k2 notify plugin, but the form will be sent
also if re-capctha field is empty or not right filled, i found this code
part what work with recaptcha:
if ($params->get('recaptcha') && $user->guest)
{
if (!function_exists('_recaptcha_qsencode'))
{
require_once
(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'recaptchalib.php');
}
$privatekey = $params->get('recaptcha_private_key');
$recaptcha_challenge_field =
isset($_POST["recaptcha_challenge_field"]) ?
$_POST["recaptcha_challenge_field"] : '';
$recaptcha_response_field =
isset($_POST["recaptcha_response_field"]) ?
$_POST["recaptcha_response_field"] : '';
$resp = recaptcha_check_answer($privatekey,
$_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field,
$recaptcha_response_field);
if (!$resp->is_valid)
{
return;
}
}
I have to give return so:
if($_POST['recaptcha_response_field'] == ""){
return;
}
But that not works, can someone give me a idea how can i fix it?
I use on my joomla website k2 notify plugin, but the form will be sent
also if re-capctha field is empty or not right filled, i found this code
part what work with recaptcha:
if ($params->get('recaptcha') && $user->guest)
{
if (!function_exists('_recaptcha_qsencode'))
{
require_once
(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'recaptchalib.php');
}
$privatekey = $params->get('recaptcha_private_key');
$recaptcha_challenge_field =
isset($_POST["recaptcha_challenge_field"]) ?
$_POST["recaptcha_challenge_field"] : '';
$recaptcha_response_field =
isset($_POST["recaptcha_response_field"]) ?
$_POST["recaptcha_response_field"] : '';
$resp = recaptcha_check_answer($privatekey,
$_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field,
$recaptcha_response_field);
if (!$resp->is_valid)
{
return;
}
}
I have to give return so:
if($_POST['recaptcha_response_field'] == ""){
return;
}
But that not works, can someone give me a idea how can i fix it?
Unable to import more than 200 records by using feeds module in drupal 7
Unable to import more than 200 records by using feeds module in drupal 7
Help us to overcome with this problem to unable to import more than 200
records.
I have changed in php.ini which is given as follows. max_exec_time 1000
memory_limit 1024 post_max_size 22M
and then restarted the Apache server at all.But did't get the solution.
I have tried by updating the settings.php(sites/default/settings.php) as
adding
$conf['feeds_process_limit'] = 2000;
Please help us as soon as possible .
Thanks in Advance enter code here
Ishwar
Help us to overcome with this problem to unable to import more than 200
records.
I have changed in php.ini which is given as follows. max_exec_time 1000
memory_limit 1024 post_max_size 22M
and then restarted the Apache server at all.But did't get the solution.
I have tried by updating the settings.php(sites/default/settings.php) as
adding
$conf['feeds_process_limit'] = 2000;
Please help us as soon as possible .
Thanks in Advance enter code here
Ishwar
Subscribe to:
Comments (Atom)