Memory allocation of 3-d arrays for reading pixel data of images using
libjpeg
I am trying to copy the pixel data of an image to a matrix using libjpeg.
Something is going wrong with the pointers. Please help.
The problem in brief: I pass an int ***p pointer to a function which reads
pixel data. Within the function, I am able to access the elements
p[i][j][k] and perform operations on them but when I try to do the same in
main the program crashes. The main function is:
#include<stdio.h>
#include<stdlib.h>
#include<jpeglib.h>
#include"functions.h"
void main(void)
{
char * file="a.jpg";
int ***p; // to store the pixel values
int s[2]={0,0}; // to store the dimensions of the image
read_JPEG_file(file,p,s); // Function that reads the image
printf("%d",p[0][0][0]); // This makes the program crash
}
The file functions.h reads:
int read_JPEG_file(char * file, int ***p, int **s)
{
int i,j;
//-----------------libjpeg procedure which I got from the
documentation------------
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err=jpeg_std_error(&jerr);
FILE * infile; /* source file */
JSAMPARRAY buffer; /* Output row buffer */
int row_stride;
if ((infile = fopen(filename, "rb")) == NULL)
{
fprintf(stderr, "can't open %s\n", filename);
return 0;
}
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, infile);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
row_stride = cinfo.output_width * cinfo.output_components;
buffer=(*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE,
row_stride, 1);
s[0]=cinfo.output_height;
s[1]=cinfo.output_width;
p=(int ***)malloc(s[0]*sizeof(int **));
for (i=0;i<s[0];i++)
{
p[i]=(int **)malloc(s[1]*sizeof(int *));
for (j=0;j<s[1];j++)
{
p[i][j]=(int *)malloc(3*sizeof(int));
}
}
while (cinfo.output_scanline < cinfo.output_height)
{
jpeg_read_scanlines(&cinfo, buffer, 1);
for ( i=0; i<cinfo.output_width; i++)
{
p[cinfo.output_scanline-1][i][0]=(int)buffer[0][0+3*i];
p[cinfo.output_scanline-1][i][1]=(int)buffer[0][1+3*i];
p[cinfo.output_scanline-1][i][2]=(int)buffer[0][2+3*i];
}
}
printf("%d",p[0][0][0]); // This works just fine
return 0;
}
I know that something is wrong with the memory allocation but I don't know
what. I tried another test program and successfully allocated a memory
block 500X500X500 integers long, and it was working-it was outputting
random integers without crashing- so lack of memory is not a problem.
Thursday, 3 October 2013
Wednesday, 2 October 2013
Implications of $\|Ax\|_1\leq \|Bx\|_1$
Implications of $\|Ax\|_1\leq \|Bx\|_1$
Let us assume that $A,B\in\mathbb{R}^{m\times n}$ and $\|\cdot\|_1$ is the
(vector) norm-1 defined as $\|x\|_1=\sum_{i=1}^n|x(i)|$, and the induced
matrix norm is $\|A\|_1=\sup_{\|x\|_1=1}\|Ax\|_1$. Let us assume that:
$$ \|Ax\|_1 \leq \|Bx\|_1, \forall x\in\mathbb{R}^n. $$
What does this imply about $A$ and $B$? I can only tell that if $n=m$ and
$B$ is invertible then we may set $y=Bx$ so $x=B^{-1}y$, hence the above
inequality becomes:
$$ \|AB^{-1}y\|_1 \leq \|y\|_1, \forall x\in\mathbb{R}^n, $$
Therefore,
$$ \|AB^{-1}\|_{1}\leq 1 $$
But, I would be interested in the case where $B$ is not assumed to be
invertible and may also not be a square matrix.
Let us assume that $A,B\in\mathbb{R}^{m\times n}$ and $\|\cdot\|_1$ is the
(vector) norm-1 defined as $\|x\|_1=\sum_{i=1}^n|x(i)|$, and the induced
matrix norm is $\|A\|_1=\sup_{\|x\|_1=1}\|Ax\|_1$. Let us assume that:
$$ \|Ax\|_1 \leq \|Bx\|_1, \forall x\in\mathbb{R}^n. $$
What does this imply about $A$ and $B$? I can only tell that if $n=m$ and
$B$ is invertible then we may set $y=Bx$ so $x=B^{-1}y$, hence the above
inequality becomes:
$$ \|AB^{-1}y\|_1 \leq \|y\|_1, \forall x\in\mathbb{R}^n, $$
Therefore,
$$ \|AB^{-1}\|_{1}\leq 1 $$
But, I would be interested in the case where $B$ is not assumed to be
invertible and may also not be a square matrix.
How to properly use the IF Statement
How to properly use the IF Statement
Which one is correct and WHY
in both examples we have a function that determines if a certain string is
valid...
(using some other function that's not defined here)
private Validator = new Validator();
public Boolean IsValid(String foo)
{
if (Validator.Validate(foo))
{
return true;
}
else
{
return false;
}
}
in the second scenario we have a function that ends with a TRUE statement
and with no else.
private Validator = new Validator();
public Boolean IsValid(String foo)
{
if (!Validator.Validate(foo))
{
return false;
}
return true;
}
NOW INB4 please dont say that you can simply do it this way
return Validator.Validate(foo);
How to save a few lines its not what i want to know...but the implications
and unknown consecuences ( to me ) of using one method or the other.
Which one is correct and WHY
in both examples we have a function that determines if a certain string is
valid...
(using some other function that's not defined here)
private Validator = new Validator();
public Boolean IsValid(String foo)
{
if (Validator.Validate(foo))
{
return true;
}
else
{
return false;
}
}
in the second scenario we have a function that ends with a TRUE statement
and with no else.
private Validator = new Validator();
public Boolean IsValid(String foo)
{
if (!Validator.Validate(foo))
{
return false;
}
return true;
}
NOW INB4 please dont say that you can simply do it this way
return Validator.Validate(foo);
How to save a few lines its not what i want to know...but the implications
and unknown consecuences ( to me ) of using one method or the other.
skip elements in each function by conditions
skip elements in each function by conditions
how can I skip some elements in each function of jquery by the next
condition:
var number_of_td = 0;
$('td').each(function() {
if (number_of_td == 0) {
if ($(this).attr('id') == "1") {
//skip the next three elements:
//something like: $(this) = $(this).next().next().next();
}
}
else if (number_of_td == 1) {
if ($(this).attr('id') == "2") {
//skip the next two elements
}
}
else if (number_of_td == 2) {
if ($(this).attr('id') == "3") {
//skip the next element
}
}
else if (number_of_td == 3) {
if ($(this).attr('id') == "4") {
//skip the next element
}
}
else {
number_of_td++;
if (number_of_td == 4) {
number_of_td = 0;
}
}
});
for example:
<td attr="1"></td>
<td attr="6"></td>
<td attr="7"></td>
<td attr="9"></td>
//-------------------
<td attr="2"></td>
<td attr="5"></td>
<td attr="3"></td>
<td attr="6"></td>
//-------------------
<td attr="7"></td>
<td attr="2"></td>
<td attr="8"></td>
<td attr="6"></td>
if one of the 4th conditions exists, skip till the td element with attr=2.
in this example, the first td attribute is 1, so it skips till attr=2 and
not check the other elements (attr=6,7,9).
2 is not equal to 1, 5 is not equal to 2, 3 is equal to 3, so it skips
till attr=7, etc.
I hope you can understand my example.
any help appreciated!
how can I skip some elements in each function of jquery by the next
condition:
var number_of_td = 0;
$('td').each(function() {
if (number_of_td == 0) {
if ($(this).attr('id') == "1") {
//skip the next three elements:
//something like: $(this) = $(this).next().next().next();
}
}
else if (number_of_td == 1) {
if ($(this).attr('id') == "2") {
//skip the next two elements
}
}
else if (number_of_td == 2) {
if ($(this).attr('id') == "3") {
//skip the next element
}
}
else if (number_of_td == 3) {
if ($(this).attr('id') == "4") {
//skip the next element
}
}
else {
number_of_td++;
if (number_of_td == 4) {
number_of_td = 0;
}
}
});
for example:
<td attr="1"></td>
<td attr="6"></td>
<td attr="7"></td>
<td attr="9"></td>
//-------------------
<td attr="2"></td>
<td attr="5"></td>
<td attr="3"></td>
<td attr="6"></td>
//-------------------
<td attr="7"></td>
<td attr="2"></td>
<td attr="8"></td>
<td attr="6"></td>
if one of the 4th conditions exists, skip till the td element with attr=2.
in this example, the first td attribute is 1, so it skips till attr=2 and
not check the other elements (attr=6,7,9).
2 is not equal to 1, 5 is not equal to 2, 3 is equal to 3, so it skips
till attr=7, etc.
I hope you can understand my example.
any help appreciated!
Is there an open source engine to provide related topics?
Is there an open source engine to provide related topics?
I am looking for an open source API or library that, given a query, will
generate related topics
For example:
Programming might be linked to c++, code and Java
Car might be linked to truck, Ford and Holden
Social science might be linked to history, philosophy, psychology
I am looking for an open source API or library that, given a query, will
generate related topics
For example:
Programming might be linked to c++, code and Java
Car might be linked to truck, Ford and Holden
Social science might be linked to history, philosophy, psychology
Tuesday, 1 October 2013
Doctrine2 Self Reference Query -- Doesn't work
Doctrine2 Self Reference Query -- Doesn't work
$ I am trying to create following scenario with doctrine 2 query builder
SELECT
p . *
FROM
_tree p
LEFT JOIN
_tree c ON p.id = c.parent_id
AND (c.lft >= p.lft AND c.rgt <= p.rgt)
WHERE
p.id = 3
I have set following relationship self generated by Doctrine2
class Tree {
/**
* @var \Tree
*
* @ORM\ManyToOne(targetEntity="Tree")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
* })
*/
private $parent;
// other code
}
here is my repo class
_em->createQueryBuilder();
$qb->select('p')
->from('Entity\Tree', 'p')
->leftJoin('p.Entity\Tree','c', 'ON','p.id = c.parent_id');
return $qb->getQuery()->getResult();
}
}
but I couldn't get it done. It throws following errors
[Tue Oct 01 22:30:11 2013] [error] [client 127.0.0.1] PHP Fatal error:
Uncaught exception 'Doctrine\ORM\Query\QueryException' with message
'SELECT p FROM Entity\Tree p LEFT JOIN p.Entity\Tree c ON p.id =
c.parent_id' in
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/QueryException.php:39\nStack
trace:\n#0
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(429):
Doctrine\ORM\Query\QueryException::dqlError('SELECT p FROM E...')\n#1
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(925):
Doctrine\ORM\Query\Parser->semanticalError('Class Entity\Ed...')\n#2
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(1561):
Doctrine\ORM\Query\Parser->JoinAssociationPathExpression()\n#3
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(1506):
Doctrine\ORM\Query\Parser->JoinAssociationDeclaration()\n#4
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(1435):
Doctrine\ORM\Query\Parser->Join()\n#5
/var/www/pcb_frame_work/System/Librari in
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/QueryException.php
on line 49, referer:
$ I am trying to create following scenario with doctrine 2 query builder
SELECT
p . *
FROM
_tree p
LEFT JOIN
_tree c ON p.id = c.parent_id
AND (c.lft >= p.lft AND c.rgt <= p.rgt)
WHERE
p.id = 3
I have set following relationship self generated by Doctrine2
class Tree {
/**
* @var \Tree
*
* @ORM\ManyToOne(targetEntity="Tree")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
* })
*/
private $parent;
// other code
}
here is my repo class
_em->createQueryBuilder();
$qb->select('p')
->from('Entity\Tree', 'p')
->leftJoin('p.Entity\Tree','c', 'ON','p.id = c.parent_id');
return $qb->getQuery()->getResult();
}
}
but I couldn't get it done. It throws following errors
[Tue Oct 01 22:30:11 2013] [error] [client 127.0.0.1] PHP Fatal error:
Uncaught exception 'Doctrine\ORM\Query\QueryException' with message
'SELECT p FROM Entity\Tree p LEFT JOIN p.Entity\Tree c ON p.id =
c.parent_id' in
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/QueryException.php:39\nStack
trace:\n#0
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(429):
Doctrine\ORM\Query\QueryException::dqlError('SELECT p FROM E...')\n#1
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(925):
Doctrine\ORM\Query\Parser->semanticalError('Class Entity\Ed...')\n#2
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(1561):
Doctrine\ORM\Query\Parser->JoinAssociationPathExpression()\n#3
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(1506):
Doctrine\ORM\Query\Parser->JoinAssociationDeclaration()\n#4
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/Parser.php(1435):
Doctrine\ORM\Query\Parser->Join()\n#5
/var/www/pcb_frame_work/System/Librari in
/var/www/pcb_frame_work/System/Libraries/Vendors/Doctrine/ORM/Query/QueryException.php
on line 49, referer:
Cannot set focus to a form field in a jQuery UI dialog on clicking a jQueryUI menu item
Cannot set focus to a form field in a jQuery UI dialog on clicking a
jQueryUI menu item
I've got a jQuery UI dialog containing a one-field form and the autoOpen
property is set to false at the beginning. There's another jQuery UI menu
on the page and the dialog's open function is binding to the click event
of the menu items. I've been trying to set focus to the only form field of
the dialog when the dialog is open on click of the menu items somehow no
luck. To pinpoint the cause I also added another test button and by
clicking that button I can set focus to the form field. So I'm pretty sure
it's the jQuery UI menu that is preventing the focus of the field. I
wonder if there's any way that I can circumvent this constraint. Any
insight is appreciated. Thanks!
<ul id="menu">
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
</ul>
</br>
<button id="btn">Open the dialog</button>
<div id="dialog" title="Basic dialog">
<form>
<input type="text" id="fld" />
</form>
</div>
$( "#dialog" ).dialog({
autoOpen: false,
open: function(event, ui){
$('#fld').focus();
}
});
$('#btn').click(function(e){
$( "#dialog" ).dialog('open');
});
$('#menu li a').click(function(){
$( "#dialog" ).dialog('open');
})
$( "#menu" ).menu({
select: function( event, ui ) {
$( "#dialog" ).dialog('open');
}
});
Here is the js fiddle
jQueryUI menu item
I've got a jQuery UI dialog containing a one-field form and the autoOpen
property is set to false at the beginning. There's another jQuery UI menu
on the page and the dialog's open function is binding to the click event
of the menu items. I've been trying to set focus to the only form field of
the dialog when the dialog is open on click of the menu items somehow no
luck. To pinpoint the cause I also added another test button and by
clicking that button I can set focus to the form field. So I'm pretty sure
it's the jQuery UI menu that is preventing the focus of the field. I
wonder if there's any way that I can circumvent this constraint. Any
insight is appreciated. Thanks!
<ul id="menu">
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
</ul>
</br>
<button id="btn">Open the dialog</button>
<div id="dialog" title="Basic dialog">
<form>
<input type="text" id="fld" />
</form>
</div>
$( "#dialog" ).dialog({
autoOpen: false,
open: function(event, ui){
$('#fld').focus();
}
});
$('#btn').click(function(e){
$( "#dialog" ).dialog('open');
});
$('#menu li a').click(function(){
$( "#dialog" ).dialog('open');
})
$( "#menu" ).menu({
select: function( event, ui ) {
$( "#dialog" ).dialog('open');
}
});
Here is the js fiddle
How to connect a data center network to a cloud provider with VPN
How to connect a data center network to a cloud provider with VPN
We have our production environment on EC2 classic, and we have a lease on
some servers in a managed hosting environment. We would like to put a
portion of our backend service in the data center, but there is no
security built into the application yet, so we need to rely on private
networks and VPN. I think this will be easier once we migrate to VPC as
AWS already provides this kind of service, but we are not there yet.
Network Description
EC2 Classic puts all instances in 10.0.0.0/8. Our data center also has a
subnet within that range, but I suspect we can change that. There are two
routers at the data center that can connect an IPSEC VPN.
Service Description
The services running in the data center need to be able to initiate
connections to services in EC2 and also receive connections initiated by
services in EC2.
Ideas
I'm sure that if our services at the data center only needed to initiate
connections to services in EC2, then it would just be a matter of setting
up VPN endpoints in EC2 for the routers at the data center to connect to,
use a different subnet in the data center, and finally, route all
connections to 10.0.0.0/8 over the VPN.
For the other direction, is the best option to configure an extra route on
all EC2 instances that need to initiate connections to services in the
data center?
We have our production environment on EC2 classic, and we have a lease on
some servers in a managed hosting environment. We would like to put a
portion of our backend service in the data center, but there is no
security built into the application yet, so we need to rely on private
networks and VPN. I think this will be easier once we migrate to VPC as
AWS already provides this kind of service, but we are not there yet.
Network Description
EC2 Classic puts all instances in 10.0.0.0/8. Our data center also has a
subnet within that range, but I suspect we can change that. There are two
routers at the data center that can connect an IPSEC VPN.
Service Description
The services running in the data center need to be able to initiate
connections to services in EC2 and also receive connections initiated by
services in EC2.
Ideas
I'm sure that if our services at the data center only needed to initiate
connections to services in EC2, then it would just be a matter of setting
up VPN endpoints in EC2 for the routers at the data center to connect to,
use a different subnet in the data center, and finally, route all
connections to 10.0.0.0/8 over the VPN.
For the other direction, is the best option to configure an extra route on
all EC2 instances that need to initiate connections to services in the
data center?
Lost connection to MySQL server at 'waiting for initial communication packet', system error: 2
Lost connection to MySQL server at 'waiting for initial communication
packet', system error: 2
I've just spun up a new RackSpace VPS using Ubuntu. I'm normally using
CentOS so forgive me for any Ubuntu newbie mistakes.
I set up an SSH tunnel using Putty and tried to connect via SQLYog,
something I've done on CentOS countless times.
I'm receiving the error message
Lost connection to MySQL server at 'waiting for initial communication
packet', system error: 2
I'm connecting via local
SQLYog 127.0.0.1 8115 root
Tunnel 8115 127.0.0.1:3306
Within my.cnf I have bind-address 127.0.0.1 and skip-networking isn't
there. At this point I've exhausted my knowledge.
Thanks
packet', system error: 2
I've just spun up a new RackSpace VPS using Ubuntu. I'm normally using
CentOS so forgive me for any Ubuntu newbie mistakes.
I set up an SSH tunnel using Putty and tried to connect via SQLYog,
something I've done on CentOS countless times.
I'm receiving the error message
Lost connection to MySQL server at 'waiting for initial communication
packet', system error: 2
I'm connecting via local
SQLYog 127.0.0.1 8115 root
Tunnel 8115 127.0.0.1:3306
Within my.cnf I have bind-address 127.0.0.1 and skip-networking isn't
there. At this point I've exhausted my knowledge.
Thanks
Monday, 30 September 2013
Desktop icons missing after "logging on" to 13.04
Desktop icons missing after "logging on" to 13.04
So I signed in to my Ubuntu 13.04 (dual booted) computer today and I
noticed something strange, the unity lancher had appeared as soon as I
signed in, but sign in box has stayed where it is and not disappeared,
along with the Ubuntu logo and white dots all over the screen. In addition
to this my desktop icons have disappeared.
Any advice as how I could go about getting rid of the login screen and
retrieve my icons?
Cheers.
So I signed in to my Ubuntu 13.04 (dual booted) computer today and I
noticed something strange, the unity lancher had appeared as soon as I
signed in, but sign in box has stayed where it is and not disappeared,
along with the Ubuntu logo and white dots all over the screen. In addition
to this my desktop icons have disappeared.
Any advice as how I could go about getting rid of the login screen and
retrieve my icons?
Cheers.
Hausdorff spaces from continuous functions
Hausdorff spaces from continuous functions
The question is to prove a topological space is Hausdorff if for every $p$
in the space there exists a continuous function $f_{p}$ such that
$f^{-1}(0) = \{p\}.$ (The inverse here is implied as converse, not a
bijective inverse).
My thinking is that if we take the open subset of $\mathbb{R}$ $(-1;1)$
for each $f$ since the map is continuous we get open sets containing
$p_i,$ and it boils down to showing the intersection is empty. I can't
quite follow this important part through.
Thanks in advance.
The question is to prove a topological space is Hausdorff if for every $p$
in the space there exists a continuous function $f_{p}$ such that
$f^{-1}(0) = \{p\}.$ (The inverse here is implied as converse, not a
bijective inverse).
My thinking is that if we take the open subset of $\mathbb{R}$ $(-1;1)$
for each $f$ since the map is continuous we get open sets containing
$p_i,$ and it boils down to showing the intersection is empty. I can't
quite follow this important part through.
Thanks in advance.
jquerymobile file input text is invisible on android 3.2 browser
jquerymobile file input text is invisible on android 3.2 browser
I'm using in a jquerymobile web application. It works good on several
platforms, but on samsung galaxy tab 10" (Android 3.2) file input filename
is not visible after file was selected. After some investigations I've
found that removing data-position="fixed" almost fix the problem (input
text is visible but shifted down).
Here is my test html.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<link rel="stylesheet" href="css/jquery.mobile-1.3.1.css" />
<script src="js/jquery.mobile-1.3.1.js"></script>
<title>Test</title>
</head>
<body>
<div data-role="page">
<div data-role="panel" id="leftpanel">
left panel
</div>
<div data-role="header" data-position="fixed">
<h1>Test item</h1>
<a href="#leftpanel" data-role="button"
data-inline="true">left panel</a>
</div>
<div data-role="content">
<input type="file" data-clear-btn="true" id="file1">
</div>
</body>
</html>
I'm using in a jquerymobile web application. It works good on several
platforms, but on samsung galaxy tab 10" (Android 3.2) file input filename
is not visible after file was selected. After some investigations I've
found that removing data-position="fixed" almost fix the problem (input
text is visible but shifted down).
Here is my test html.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<link rel="stylesheet" href="css/jquery.mobile-1.3.1.css" />
<script src="js/jquery.mobile-1.3.1.js"></script>
<title>Test</title>
</head>
<body>
<div data-role="page">
<div data-role="panel" id="leftpanel">
left panel
</div>
<div data-role="header" data-position="fixed">
<h1>Test item</h1>
<a href="#leftpanel" data-role="button"
data-inline="true">left panel</a>
</div>
<div data-role="content">
<input type="file" data-clear-btn="true" id="file1">
</div>
</body>
</html>
PLEASE ANSWER THESE JAVA BASED QUESTIONS
PLEASE ANSWER THESE JAVA BASED QUESTIONS
TO READ HTML FROM ANY WEBSITE SAY "http://www.google.com"(you can use any
API of inbuilt APIs in java like URLConnection) 2.PRINT ON CONSOLE THE
HTML FROM THE URL ABOVE AND SAVE IT TO A FILE (web-content.txt) in local
machine. 3.JUnit test cases for the above programme.
TO READ HTML FROM ANY WEBSITE SAY "http://www.google.com"(you can use any
API of inbuilt APIs in java like URLConnection) 2.PRINT ON CONSOLE THE
HTML FROM THE URL ABOVE AND SAVE IT TO A FILE (web-content.txt) in local
machine. 3.JUnit test cases for the above programme.
Sunday, 29 September 2013
Recieve 400 Bad Request when using Jquery Form Plugin
Recieve 400 Bad Request when using Jquery Form Plugin
I changed my code to using the Jquery Form Plugin so that I could upload
pictures. My original form was simple
$.ajax({
type: "POST",
url: "register.htm",
data:{
account_name: $('#regAccount_name').val(),
pwd: MD5($('#regPwd').val()),
fname: $('#regFname').val(),
lname: $('#regLname').val(),
},
success: function(data){
changeMainIFrame('MenuFrame.jsp?regStatus=User Successfully
Registered');
},
error:function(e){
console.log("sendRegistration(): " + e);
}
});
but changed to this
var options = {
beforeSend: function()
{
//alert(MD5($('#regPwd').val()));
// document.getElementById('regPwd').value =
MD5($('#regPwd').val());
},
uploadProgress: function(event, position, total, percentComplete)
{
},
success: function()
{
changeMainIFrame('MenuFrame.jsp?regStatus=User Successfully
Registered');
},
complete: function(response)
{
},
error: function(e)
{
console.log("sendRegistration(): " + e);
}
};
$("#regForm").ajaxForm(options);
However now I get a 400 Bad Request which I take it to mean the my
controller isn't even picking up the request. Here's my controller code:
@RequestMapping("/register.htm")
public String register(// @RequestParam("regProfilePic") File pic,
@RequestParam("regAccount_name") String account_name,
@RequestParam("pwd") String pwd,
@RequestParam("fname") String fname,
@RequestParam("lname") String lname,
ModelMap params){
setup();
System.out.println("Register");
service.registerUser(fname, lname, account_name, pwd);
return "MenuFrame";
}
Here's My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"
version="3.0">
<display-name>Volt</display-name>
<welcome-file-list>
<welcome-file>Mugenjou.jsp</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/beans.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>volts</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>volts</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
and here's my servlet
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.mugenjou.control" />
<!-- /WEB-INF/jsp/VIEWNAME.jsp -->
<bean id="viewNameTranslator"
class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- <property name="prefix" value="/WEB-INF/jsp/"/> -->
<property value="" name="prefix"/> <property value=".jsp"
name="suffix"/>
</bean>
</beans>
the html
<form id ='regForm' action="register.htm" method="POST"
enctype="multipart/form-data">
<table cellpadding=5>
<!-- <tr>
<td>Profile Picture <br> <input type = "file" id
="regProfilePic" name ="regProfilePic" /></td>
</tr> -->
<tr>
<td> *Account Name <br> <input id
="regAccount_name" name = "regAccount_name"
type="text" size ="20"
onblur="isAccount_name();registerBtn();"/></td>
<td>
<div id ="chkUserLb"></div>
</td>
</tr>
<tr>
<td> *Password <br> <input id = "regPwd" name =
"pwd" type="text" size ="20"
onblur="isPwd();registerBtn();"/></td>
<td id=chkPwdLb></td>
</tr>
<tr>
<td> *First Name <br> <input id = "regFname" name
="fname" type="text" size ="20"
onblur="isFname();registerBtn();"/></td>
<td id=chkFnameLb></td>
</tr>
<tr>
<td> *Last Name <br> <input id = "regLname" name =
"lname" type="text" size ="20"
onblur="isLname();registerBtn();"/></td>
<td id=chkLnameLb></td>
</tr>
<tr>
<td><input id = "regSubmitBtn" type="submit"
value="Submit" disabled></td>
</tr>
</table>
*Required
</form>
I changed my code to using the Jquery Form Plugin so that I could upload
pictures. My original form was simple
$.ajax({
type: "POST",
url: "register.htm",
data:{
account_name: $('#regAccount_name').val(),
pwd: MD5($('#regPwd').val()),
fname: $('#regFname').val(),
lname: $('#regLname').val(),
},
success: function(data){
changeMainIFrame('MenuFrame.jsp?regStatus=User Successfully
Registered');
},
error:function(e){
console.log("sendRegistration(): " + e);
}
});
but changed to this
var options = {
beforeSend: function()
{
//alert(MD5($('#regPwd').val()));
// document.getElementById('regPwd').value =
MD5($('#regPwd').val());
},
uploadProgress: function(event, position, total, percentComplete)
{
},
success: function()
{
changeMainIFrame('MenuFrame.jsp?regStatus=User Successfully
Registered');
},
complete: function(response)
{
},
error: function(e)
{
console.log("sendRegistration(): " + e);
}
};
$("#regForm").ajaxForm(options);
However now I get a 400 Bad Request which I take it to mean the my
controller isn't even picking up the request. Here's my controller code:
@RequestMapping("/register.htm")
public String register(// @RequestParam("regProfilePic") File pic,
@RequestParam("regAccount_name") String account_name,
@RequestParam("pwd") String pwd,
@RequestParam("fname") String fname,
@RequestParam("lname") String lname,
ModelMap params){
setup();
System.out.println("Register");
service.registerUser(fname, lname, account_name, pwd);
return "MenuFrame";
}
Here's My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"
version="3.0">
<display-name>Volt</display-name>
<welcome-file-list>
<welcome-file>Mugenjou.jsp</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/beans.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>volts</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>volts</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
and here's my servlet
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.mugenjou.control" />
<!-- /WEB-INF/jsp/VIEWNAME.jsp -->
<bean id="viewNameTranslator"
class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- <property name="prefix" value="/WEB-INF/jsp/"/> -->
<property value="" name="prefix"/> <property value=".jsp"
name="suffix"/>
</bean>
</beans>
the html
<form id ='regForm' action="register.htm" method="POST"
enctype="multipart/form-data">
<table cellpadding=5>
<!-- <tr>
<td>Profile Picture <br> <input type = "file" id
="regProfilePic" name ="regProfilePic" /></td>
</tr> -->
<tr>
<td> *Account Name <br> <input id
="regAccount_name" name = "regAccount_name"
type="text" size ="20"
onblur="isAccount_name();registerBtn();"/></td>
<td>
<div id ="chkUserLb"></div>
</td>
</tr>
<tr>
<td> *Password <br> <input id = "regPwd" name =
"pwd" type="text" size ="20"
onblur="isPwd();registerBtn();"/></td>
<td id=chkPwdLb></td>
</tr>
<tr>
<td> *First Name <br> <input id = "regFname" name
="fname" type="text" size ="20"
onblur="isFname();registerBtn();"/></td>
<td id=chkFnameLb></td>
</tr>
<tr>
<td> *Last Name <br> <input id = "regLname" name =
"lname" type="text" size ="20"
onblur="isLname();registerBtn();"/></td>
<td id=chkLnameLb></td>
</tr>
<tr>
<td><input id = "regSubmitBtn" type="submit"
value="Submit" disabled></td>
</tr>
</table>
*Required
</form>
generate random string in php for file name
generate random string in php for file name
How would I go about creating a random string of text for use with file
names?
I am uploading photos and renaming them upon completion. All photos are
going to be stored in one directory so their filenames need to be unique.
Is there a standard way of doing this?
How would I go about creating a random string of text for use with file
names?
I am uploading photos and renaming them upon completion. All photos are
going to be stored in one directory so their filenames need to be unique.
Is there a standard way of doing this?
When should I prefer a clone over an reference in javascript?
When should I prefer a clone over an reference in javascript?
at the moment I'm writing a small app and came to the point, where I
thought it would be clever to clone an object, instead of using a
reference.
The reason I'm doing this is, because I'm collecting objects in a list.
Later I will only work with this list, because it's part of a model. The
reference isn't something I need and I want to avoid having references to
outside objects in the list, because I don't want someone to build a
construct, where the model can be changed from an inconsiderate place in
their code. (The integrity of the information in the model is very
important.)
Additional I thought I will get a better performance out of it, when I
don't use references.
So my overall question still is: When should I prefer a clone over an
reference in javascript?
Thanks!
at the moment I'm writing a small app and came to the point, where I
thought it would be clever to clone an object, instead of using a
reference.
The reason I'm doing this is, because I'm collecting objects in a list.
Later I will only work with this list, because it's part of a model. The
reference isn't something I need and I want to avoid having references to
outside objects in the list, because I don't want someone to build a
construct, where the model can be changed from an inconsiderate place in
their code. (The integrity of the information in the model is very
important.)
Additional I thought I will get a better performance out of it, when I
don't use references.
So my overall question still is: When should I prefer a clone over an
reference in javascript?
Thanks!
Find MAC address of system, using python (in chat system)
Find MAC address of system, using python (in chat system)
is there anyway,to find MAC address of a device ( in chat system )using
python? except uuid library
is there anyway,to find MAC address of a device ( in chat system )using
python? except uuid library
Saturday, 28 September 2013
cakephp multiple domains & Configure::write
cakephp multiple domains & Configure::write
Running multiple domains on one install. In bootstrap I have:
Configure::write('Application.name', 'example1.com');
Configure::write('Application.name', 'example2.com');
What's the best way to define these variables so that I can check my main
domain and set them up all at once?
Running multiple domains on one install. In bootstrap I have:
Configure::write('Application.name', 'example1.com');
Configure::write('Application.name', 'example2.com');
What's the best way to define these variables so that I can check my main
domain and set them up all at once?
What does assertion failure mean in xcode?
What does assertion failure mean in xcode?
Currently following a checklists tutorial built with io6 in mind. I'm
using xcode 5, ios7 sdk. The tutorial hasn't been updated for IOS7 but I
didn't want to stop my learning so decided to go ahead and work with the
outdated tutorial and hopefully use it as a learning experience. Using
reading of official Apple docs and extensive googling as my guide along
the way.
Very early I've run into an issue already and not sure what is wrong. I
noticed that the autocomplete had part of the methods below crossed out (a
deprecation maybe?). The issue is definitely coming from the code below
because once I remove it the simulator loads the app fine.
Code causing crash:
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"ChecklistItem"];
return cell;
}
Here is the stack trace:
2013-09-28 20:51:26.208 Checklists[47289:a0b] *** Assertion failure in
-[UITableView _configureCellForDisplay:forIndexPath:],
/SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:6235
2013-09-28 20:51:26.218 Checklists[47289:a0b] *** Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason:
'UITableView dataSource must return a cell from
tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0 CoreFoundation 0x017335e4
__exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b68b6
objc_exception_throw + 44
2 CoreFoundation 0x01733448 +[NSException
raise:format:arguments:] + 136
3 Foundation 0x0109723e
-[NSAssertionHandler
handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x00311ae5 __53-[UITableView
_configureCellForDisplay:forIndexPath:]_block_invoke + 426
5 UIKit 0x0028af5f +[UIView(Animation)
performWithoutAnimation:] + 82
6 UIKit 0x0028afa8 +[UIView(Animation)
_performWithoutAnimation:] + 40
7 UIKit 0x00311936 -[UITableView
_configureCellForDisplay:forIndexPath:] + 108
8 UIKit 0x00317d4d -[UITableView
_createPreparedCellForGlobalRow:withIndexPath:] + 442
9 UIKit 0x00317e03 -[UITableView
_createPreparedCellForGlobalRow:] + 69
10 UIKit 0x002fc124 -[UITableView
_updateVisibleCellsNow:] + 2378
11 UIKit 0x0030f5a5 -[UITableView
layoutSubviews] + 213
12 UIKit 0x00293dd7
-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014c881f -[NSObject
performSelector:withObject:] + 70
14 QuartzCore 0x03aed72a -[CALayer
layoutSublayers] + 148
15 QuartzCore 0x03ae1514
_ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03aed675 -[CALayer
layoutIfNeeded] + 160
17 UIKit 0x0034eca3 -[UIViewController
window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x0026dd27 -[UIWindow
_setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:]
+ 5212
19 UIKit 0x0026c8c6 -[UIWindow
_setRotatableClient:toOrientation:updateStatusBar:duration:force:] +
82
20 UIKit 0x0026c798 -[UIWindow
_setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x0026c820 -[UIWindow
_setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x0026b8ba __57-[UIWindow
_updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x0026b81c -[UIWindow
_updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x0026c573 -[UIWindow
setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x0026fb66 -[UIWindow
setDelegate:] + 449
26 UIKit 0x00340dc7 -[UIViewController
_tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x002657cc -[UIWindow
addRootViewControllerViewIfPossible] + 609
28 UIKit 0x00265947 -[UIWindow
_setHidden:forced:] + 312
29 UIKit 0x00265bdd -[UIWindow
_orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027044a -[UIWindow
makeKeyAndVisible] + 65
31 UIKit 0x002238e0 -[UIApplication
_callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x00227fb8 -[UIApplication
_runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
+ 824
33 UIKit 0x0023c42c -[UIApplication
handleEvent:withNewEvent:] + 3447
34 UIKit 0x0023c999 -[UIApplication
sendEvent:] + 85
35 UIKit 0x00229c35
_UIApplicationHandleEvent + 736
36 GraphicsServices 0x036862eb
_PurpleEventCallback + 776
37 GraphicsServices 0x03685df6 PurpleEventCallback
+ 46
38 CoreFoundation 0x016aedd5
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016aeb0b
__CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016d97ec __CFRunLoopRun + 2156
41 CoreFoundation 0x016d8b33
CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016d894b CFRunLoopRunInMode
+ 123
43 UIKit 0x002276ed -[UIApplication
_run] + 840
44 UIKit 0x0022994b UIApplicationMain +
1225
45 Checklists 0x00001b7d main + 141
46 libdyld.dylib 0x01d6f725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Kind regards
Currently following a checklists tutorial built with io6 in mind. I'm
using xcode 5, ios7 sdk. The tutorial hasn't been updated for IOS7 but I
didn't want to stop my learning so decided to go ahead and work with the
outdated tutorial and hopefully use it as a learning experience. Using
reading of official Apple docs and extensive googling as my guide along
the way.
Very early I've run into an issue already and not sure what is wrong. I
noticed that the autocomplete had part of the methods below crossed out (a
deprecation maybe?). The issue is definitely coming from the code below
because once I remove it the simulator loads the app fine.
Code causing crash:
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"ChecklistItem"];
return cell;
}
Here is the stack trace:
2013-09-28 20:51:26.208 Checklists[47289:a0b] *** Assertion failure in
-[UITableView _configureCellForDisplay:forIndexPath:],
/SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:6235
2013-09-28 20:51:26.218 Checklists[47289:a0b] *** Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason:
'UITableView dataSource must return a cell from
tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0 CoreFoundation 0x017335e4
__exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b68b6
objc_exception_throw + 44
2 CoreFoundation 0x01733448 +[NSException
raise:format:arguments:] + 136
3 Foundation 0x0109723e
-[NSAssertionHandler
handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x00311ae5 __53-[UITableView
_configureCellForDisplay:forIndexPath:]_block_invoke + 426
5 UIKit 0x0028af5f +[UIView(Animation)
performWithoutAnimation:] + 82
6 UIKit 0x0028afa8 +[UIView(Animation)
_performWithoutAnimation:] + 40
7 UIKit 0x00311936 -[UITableView
_configureCellForDisplay:forIndexPath:] + 108
8 UIKit 0x00317d4d -[UITableView
_createPreparedCellForGlobalRow:withIndexPath:] + 442
9 UIKit 0x00317e03 -[UITableView
_createPreparedCellForGlobalRow:] + 69
10 UIKit 0x002fc124 -[UITableView
_updateVisibleCellsNow:] + 2378
11 UIKit 0x0030f5a5 -[UITableView
layoutSubviews] + 213
12 UIKit 0x00293dd7
-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014c881f -[NSObject
performSelector:withObject:] + 70
14 QuartzCore 0x03aed72a -[CALayer
layoutSublayers] + 148
15 QuartzCore 0x03ae1514
_ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03aed675 -[CALayer
layoutIfNeeded] + 160
17 UIKit 0x0034eca3 -[UIViewController
window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x0026dd27 -[UIWindow
_setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:]
+ 5212
19 UIKit 0x0026c8c6 -[UIWindow
_setRotatableClient:toOrientation:updateStatusBar:duration:force:] +
82
20 UIKit 0x0026c798 -[UIWindow
_setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x0026c820 -[UIWindow
_setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x0026b8ba __57-[UIWindow
_updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x0026b81c -[UIWindow
_updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x0026c573 -[UIWindow
setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x0026fb66 -[UIWindow
setDelegate:] + 449
26 UIKit 0x00340dc7 -[UIViewController
_tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x002657cc -[UIWindow
addRootViewControllerViewIfPossible] + 609
28 UIKit 0x00265947 -[UIWindow
_setHidden:forced:] + 312
29 UIKit 0x00265bdd -[UIWindow
_orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027044a -[UIWindow
makeKeyAndVisible] + 65
31 UIKit 0x002238e0 -[UIApplication
_callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x00227fb8 -[UIApplication
_runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
+ 824
33 UIKit 0x0023c42c -[UIApplication
handleEvent:withNewEvent:] + 3447
34 UIKit 0x0023c999 -[UIApplication
sendEvent:] + 85
35 UIKit 0x00229c35
_UIApplicationHandleEvent + 736
36 GraphicsServices 0x036862eb
_PurpleEventCallback + 776
37 GraphicsServices 0x03685df6 PurpleEventCallback
+ 46
38 CoreFoundation 0x016aedd5
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016aeb0b
__CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016d97ec __CFRunLoopRun + 2156
41 CoreFoundation 0x016d8b33
CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016d894b CFRunLoopRunInMode
+ 123
43 UIKit 0x002276ed -[UIApplication
_run] + 840
44 UIKit 0x0022994b UIApplicationMain +
1225
45 Checklists 0x00001b7d main + 141
46 libdyld.dylib 0x01d6f725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Kind regards
Objective-C UICollectionView Scroll Up/Down
Objective-C UICollectionView Scroll Up/Down
Does anyone know, what method for UICollectionView, while scrolling
Up/Down. I need to change UICollectionView's Header while scrolling down.I
am doing own calendar View.
I have following method that creates header view for section
- (UICollectionReusableView *)collectionView:(UICollectionView
*)collectionView viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath
{
ASCalendarHeaderView *calHeader = [self.calCollectView
dequeueReusableSupplementaryViewOfKind:kind
withReuseIdentifier:@"CalendarHeader" forIndexPath:indexPath];
calHeader.MonthYearLabel.text = [calendar
getCurrentMonthYear:calendar.today];
[calHeader setNeedsDisplay];
calHeader.MonthYearLabel.textAlignment = NSTextAlignmentRight;
if (indexPath.section){
[calendar getNextMonth:calendar.today];
NSLog(@"Some Text");
}
return calHeader;
}
But it increment month while I am scrolling up. Is there is method that
mean while scrolling up and while scrolling down separately?
Thanks
Does anyone know, what method for UICollectionView, while scrolling
Up/Down. I need to change UICollectionView's Header while scrolling down.I
am doing own calendar View.
I have following method that creates header view for section
- (UICollectionReusableView *)collectionView:(UICollectionView
*)collectionView viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath
{
ASCalendarHeaderView *calHeader = [self.calCollectView
dequeueReusableSupplementaryViewOfKind:kind
withReuseIdentifier:@"CalendarHeader" forIndexPath:indexPath];
calHeader.MonthYearLabel.text = [calendar
getCurrentMonthYear:calendar.today];
[calHeader setNeedsDisplay];
calHeader.MonthYearLabel.textAlignment = NSTextAlignmentRight;
if (indexPath.section){
[calendar getNextMonth:calendar.today];
NSLog(@"Some Text");
}
return calHeader;
}
But it increment month while I am scrolling up. Is there is method that
mean while scrolling up and while scrolling down separately?
Thanks
#EANF#
#EANF#
This is frustrating. I searched about it a lot but none of the results
help me. I tried subprocess but I still cant get it to work. Basically I
want to get this line to work:
appName = "ap01"
optna = "-server"
optnb = "-filename=c:/test.VS"
optnc = "-display=1"
os.system('start "VSM" "C:/bin/" {appName, optna, optnb, optnc} ')
In CMD I would simply type
CD C:/bin/
press enter and then:
ap01 -server -filename=C:/test.VS -display=1
This is frustrating. I searched about it a lot but none of the results
help me. I tried subprocess but I still cant get it to work. Basically I
want to get this line to work:
appName = "ap01"
optna = "-server"
optnb = "-filename=c:/test.VS"
optnc = "-display=1"
os.system('start "VSM" "C:/bin/" {appName, optna, optnb, optnc} ')
In CMD I would simply type
CD C:/bin/
press enter and then:
ap01 -server -filename=C:/test.VS -display=1
Friday, 27 September 2013
About the EX1-9 of K&R
About the EX1-9 of K&R
Here's the text of Exercise 1-9 from the book 'The C programming language'
by Ritchie&Kernighan:
Write a program to copy its input to its output, replacing each string of
one or more blanks by a single blank.
To me the simplest way of solving that problem is writing
int single_byte = getchar();
while (single_byte != EOF) {
putchar(single_byte);
if (single_byte == ' ')
while ((single_byte = getchar()) == ' ')
;
else
single_byte = getchar();
}
though I was told (last night in the #c channel of irc.freenode.net) it
would be more readable getting rid of the nested while by implementing a
comparison between the last character saved and the one just read. What I
thought is kind of this:
int current_byte = getchar();
if (current_byte == EOF)
return 1;
putchar(current_byte);
int previous_byte = current_byte;
while ((current_byte = getchar()) != EOF) {
if (current_byte == ' ' && previous_byte == ' ')
;
else
putchar(current_byte);
previous_byte = current_byte;
}
that does not satisfy me at all: starting from the first if-statement (for
the case when there's nothing to read). Additionally I wish I could push
the last two lines before the while inside the loop; the less I should
distinguish the beginning from the rest of the execution, the happier I am
!
Here's the text of Exercise 1-9 from the book 'The C programming language'
by Ritchie&Kernighan:
Write a program to copy its input to its output, replacing each string of
one or more blanks by a single blank.
To me the simplest way of solving that problem is writing
int single_byte = getchar();
while (single_byte != EOF) {
putchar(single_byte);
if (single_byte == ' ')
while ((single_byte = getchar()) == ' ')
;
else
single_byte = getchar();
}
though I was told (last night in the #c channel of irc.freenode.net) it
would be more readable getting rid of the nested while by implementing a
comparison between the last character saved and the one just read. What I
thought is kind of this:
int current_byte = getchar();
if (current_byte == EOF)
return 1;
putchar(current_byte);
int previous_byte = current_byte;
while ((current_byte = getchar()) != EOF) {
if (current_byte == ' ' && previous_byte == ' ')
;
else
putchar(current_byte);
previous_byte = current_byte;
}
that does not satisfy me at all: starting from the first if-statement (for
the case when there's nothing to read). Additionally I wish I could push
the last two lines before the while inside the loop; the less I should
distinguish the beginning from the rest of the execution, the happier I am
!
Swap Class of Element
Swap Class of Element
I have the following code:
<a href="#" class="more">text</a>
How can I toggle the class between "more" and "less" when clicked?
$('a').click(function (e) {
e.preventDefault();
var $this = $(this);
$this.toggleClass('more', 'less');
});
But I get the class changing from "more" to "" and not to less.
Thank You, Miguel
I have the following code:
<a href="#" class="more">text</a>
How can I toggle the class between "more" and "less" when clicked?
$('a').click(function (e) {
e.preventDefault();
var $this = $(this);
$this.toggleClass('more', 'less');
});
But I get the class changing from "more" to "" and not to less.
Thank You, Miguel
(CodeIgniter) Unable to add to Cart Class
(CodeIgniter) Unable to add to Cart Class
I've just started playing around with the shopping cart class for
CodeIgniter (version 2.1.4) and I've been following tutorials that help
explain it. But for some reason I am unable to successfully add a a simple
array to the cart.
Here is my implementation of the cart class:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cart extends CI_Controller {
public function __construct() {
parent:: __construct();
}
public function index() {
$nav["navigation"] = $this->getCategory->getCategories();
$this->load->view("header");
$this->load->view("scripts");
$this->load->view("nav", $nav);
$this->load->view("cart");
$this->load->view("footer");
}
function add() {
$data = array(
"id" => "42",
"name" => "pants",
"quantity" => 1,
"price" => 19.99,
"options" => array("size" => "medium")
);
$this->cart->insert($data);
var_dump($this->cart->contents()); //This should output the array!
}
function show() {
$cart = $this->cart->contents();
echo "<pre>" . print_r($cart) . "</pre>"; //Nothing here either!
}
function update() {
$this->cart->update($data);
redirect(base_url()."cart");
}
function total() {
echo $this->cart->total();
}
function remove() {
$this->cart->update($data);
}
function destroy() {
$this->cart->destroy();
}
}
But if I go to the add function the var_dump just displays "array(0) { }".
Same result if I navigate to the show function.
Here is my autoload config showing that I have autoloaded the cart library
has been loaded:
$autoload['libraries'] = array("database", "session", "cart");
$autoload['helper'] = array("html", "url", "form");
I know it's something really simple and obvious I'm missing, but right now
I'm just left baffled. Any suggestions?
I've just started playing around with the shopping cart class for
CodeIgniter (version 2.1.4) and I've been following tutorials that help
explain it. But for some reason I am unable to successfully add a a simple
array to the cart.
Here is my implementation of the cart class:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cart extends CI_Controller {
public function __construct() {
parent:: __construct();
}
public function index() {
$nav["navigation"] = $this->getCategory->getCategories();
$this->load->view("header");
$this->load->view("scripts");
$this->load->view("nav", $nav);
$this->load->view("cart");
$this->load->view("footer");
}
function add() {
$data = array(
"id" => "42",
"name" => "pants",
"quantity" => 1,
"price" => 19.99,
"options" => array("size" => "medium")
);
$this->cart->insert($data);
var_dump($this->cart->contents()); //This should output the array!
}
function show() {
$cart = $this->cart->contents();
echo "<pre>" . print_r($cart) . "</pre>"; //Nothing here either!
}
function update() {
$this->cart->update($data);
redirect(base_url()."cart");
}
function total() {
echo $this->cart->total();
}
function remove() {
$this->cart->update($data);
}
function destroy() {
$this->cart->destroy();
}
}
But if I go to the add function the var_dump just displays "array(0) { }".
Same result if I navigate to the show function.
Here is my autoload config showing that I have autoloaded the cart library
has been loaded:
$autoload['libraries'] = array("database", "session", "cart");
$autoload['helper'] = array("html", "url", "form");
I know it's something really simple and obvious I'm missing, but right now
I'm just left baffled. Any suggestions?
how the javascript compare the number and string?
how the javascript compare the number and string?
I know the meaning of ===, it will check whether the operand is identical
or notC so 1 === '1' will result false, but 1 == '1' result true, but
typeof 1 is number and typeof '1' is string, so how javascript compare 1
== '1', are there any converting, and how?
I know the meaning of ===, it will check whether the operand is identical
or notC so 1 === '1' will result false, but 1 == '1' result true, but
typeof 1 is number and typeof '1' is string, so how javascript compare 1
== '1', are there any converting, and how?
MVC3 Razor View Multi Select Dropdown
MVC3 Razor View Multi Select Dropdown
I want to create a multiselect dropdown (all options having checkbox to
select) in MVC3 razor view (cshtml).
I have searched it a lot and everywhere I found recommendations to use
Jquery plugins like chozen etc. Due to some constraints, I cannot use
external tools.
I want to create a multiselect dropdown (all options having checkbox to
select) in MVC3 razor view (cshtml).
I have searched it a lot and everywhere I found recommendations to use
Jquery plugins like chozen etc. Due to some constraints, I cannot use
external tools.
Thursday, 26 September 2013
IOS MDM-Managed Settings Command return CommandFormatError
IOS MDM-Managed Settings Command return CommandFormatError
I receive "CommandFormatError" on Managed Settings commands.
That's what I'm sending as a Settings command:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CommandUUID</key>
<string>123456</string>
<key>Command</key>
<dict>
<key>RequestType</key>
<string>Settings</string>
<key>Settings</key>
<array>
<dict>
<key>Item</key>
<string>VoiceRoaming</string>
<key>Enabled</key>
<true/>
</dict>
</array>
</dict>
</dict>
</plist>
Thank you in advance!
I receive "CommandFormatError" on Managed Settings commands.
That's what I'm sending as a Settings command:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CommandUUID</key>
<string>123456</string>
<key>Command</key>
<dict>
<key>RequestType</key>
<string>Settings</string>
<key>Settings</key>
<array>
<dict>
<key>Item</key>
<string>VoiceRoaming</string>
<key>Enabled</key>
<true/>
</dict>
</array>
</dict>
</dict>
</plist>
Thank you in advance!
Wednesday, 25 September 2013
How to parse a telephone number from calendar Event.Description to textbox in android?
How to parse a telephone number from calendar Event.Description to textbox
in android?
I am using a calendar and the event description consists of some telephone
numbers how can i parse the numbers and put it in the textbox.Is there any
API for that in android?
in android?
I am using a calendar and the event description consists of some telephone
numbers how can i parse the numbers and put it in the textbox.Is there any
API for that in android?
Thursday, 19 September 2013
Left-floated div place below another div
Left-floated div place below another div
I have two divs whereas (div 1) is floated left while (div 2) is floated
right. I am creating a responsive layout where when the viewport changes,
(div 1) will go under (div 2). I created a simple image via MS Paint for
an easier illustration and also some code. Also, both contain dynamic
content so their heights must not be fixed.
No javascript (if possible) just plain CSS. I only know how to put div 2
under div 1 but not the other way around.
Does anyone know how I could achieve this?
HTML:
<div id="div1" style="float: left;">
//dynamic content
</div>
<div id="div2" style="float: right;">
//dynamic content
</div>
I have two divs whereas (div 1) is floated left while (div 2) is floated
right. I am creating a responsive layout where when the viewport changes,
(div 1) will go under (div 2). I created a simple image via MS Paint for
an easier illustration and also some code. Also, both contain dynamic
content so their heights must not be fixed.
No javascript (if possible) just plain CSS. I only know how to put div 2
under div 1 but not the other way around.
Does anyone know how I could achieve this?
HTML:
<div id="div1" style="float: left;">
//dynamic content
</div>
<div id="div2" style="float: right;">
//dynamic content
</div>
attempt to reopen an already-closed object: sqlitequery
attempt to reopen an already-closed object: sqlitequery
So essentially I am querying the DB twice. I don't understand where this
error is really coming from because I am not closing the DB anywhere. The
code that returns the error runs like this. I've checked around and I just
having seen a case like mine.
BeaconHandler pullAllDB = new BeaconHandler(this);
try {
List<Beacon> beaconsShown = pullAllDB.getAllBeacons();
for (final Beacon bn : beaconsShown) {
try {
int messageCount = pullAllDB.getMessageCount();
Log.d("Message", messageCount + " Messages Found");
if (messageCount > 0) {
//Do Something
} else {
// Do Nothing
}
}
catch (Exception e) {
e.getStackTrace();
Log.e("Message", e.getMessage());
}
}
}
And the code doing the queries...
public int getBeaconsCount() {
String countQuery = "SELECT * FROM " + TABLE_BASIC_BEACON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
cursor.close();
// return count
return cursor.getCount();
}
public int getMessageCount() {
String mcountQuery = "SELECT * FROM " + MESSAGE_BEACON;
SQLiteDatabase mdb = this.getReadableDatabase();
Cursor mcursor = mdb.rawQuery(mcountQuery, null);
mcursor.close();
// return count
return mcursor.getCount();
}
So essentially I am querying the DB twice. I don't understand where this
error is really coming from because I am not closing the DB anywhere. The
code that returns the error runs like this. I've checked around and I just
having seen a case like mine.
BeaconHandler pullAllDB = new BeaconHandler(this);
try {
List<Beacon> beaconsShown = pullAllDB.getAllBeacons();
for (final Beacon bn : beaconsShown) {
try {
int messageCount = pullAllDB.getMessageCount();
Log.d("Message", messageCount + " Messages Found");
if (messageCount > 0) {
//Do Something
} else {
// Do Nothing
}
}
catch (Exception e) {
e.getStackTrace();
Log.e("Message", e.getMessage());
}
}
}
And the code doing the queries...
public int getBeaconsCount() {
String countQuery = "SELECT * FROM " + TABLE_BASIC_BEACON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
cursor.close();
// return count
return cursor.getCount();
}
public int getMessageCount() {
String mcountQuery = "SELECT * FROM " + MESSAGE_BEACON;
SQLiteDatabase mdb = this.getReadableDatabase();
Cursor mcursor = mdb.rawQuery(mcountQuery, null);
mcursor.close();
// return count
return mcursor.getCount();
}
How do I check if an email field is 1) empty and 2) contains a specific email address with jquery?
How do I check if an email field is 1) empty and 2) contains a specific
email address with jquery?
Not sure why my alerts aren't firing, but what I eventually would like to
do is enable the submit button when this field is not empty and contains a
specific email address, such as "@something.com"
First things first, I'm simply trying to check if the field is empty on
the change event.
HTML
<input type="email" id="email" placeholder="lauren@something.com">
JS
$("#email").change(function(){
if (this.is(':empty')) {
alert('empty');
} else {
alert('not empty');
}
});
email address with jquery?
Not sure why my alerts aren't firing, but what I eventually would like to
do is enable the submit button when this field is not empty and contains a
specific email address, such as "@something.com"
First things first, I'm simply trying to check if the field is empty on
the change event.
HTML
<input type="email" id="email" placeholder="lauren@something.com">
JS
$("#email").change(function(){
if (this.is(':empty')) {
alert('empty');
} else {
alert('not empty');
}
});
Python string slice step?
Python string slice step?
I want to convert python codes to java. But I do not understand slicing
step parameter.
Example:
x = "Hello World !"
x[6:2:-1]
And what is the result x[6:2:-1] ?
I want to convert python codes to java. But I do not understand slicing
step parameter.
Example:
x = "Hello World !"
x[6:2:-1]
And what is the result x[6:2:-1] ?
MySQL: my.ini not read
MySQL: my.ini not read
I have MySQL 5.6 installed on Windows 7 64 Bit and I can't seem to get it
to read my my.ini file. I've put the file into the base installation
directory, the Windows directory and C:\, but it doesn't look like it's
being read, even though all paths are listed here:
http://dev.mysql.com/doc/refman/5.1/en/option-files.html
My my.ini file doesn't do much, I just took the my-default.ini as a base
and added [mysqld] max_allowed_packet=100000000 because that default limit
of 4MB is bad for BLOBs.
When I start mysql.exe and check the variable I find that it's still at
4MB, even after restarting the server (both via the services menu in the
control panel and via mysqld -shutdown + mysqld -startup) and restarting
Windows.
I have Windows 7, 64 bit. Can anyone help me, please?
Thanks in advance!
Alex
I have MySQL 5.6 installed on Windows 7 64 Bit and I can't seem to get it
to read my my.ini file. I've put the file into the base installation
directory, the Windows directory and C:\, but it doesn't look like it's
being read, even though all paths are listed here:
http://dev.mysql.com/doc/refman/5.1/en/option-files.html
My my.ini file doesn't do much, I just took the my-default.ini as a base
and added [mysqld] max_allowed_packet=100000000 because that default limit
of 4MB is bad for BLOBs.
When I start mysql.exe and check the variable I find that it's still at
4MB, even after restarting the server (both via the services menu in the
control panel and via mysqld -shutdown + mysqld -startup) and restarting
Windows.
I have Windows 7, 64 bit. Can anyone help me, please?
Thanks in advance!
Alex
How to do not stop vribating when screen off
How to do not stop vribating when screen off
I have an application which vibrate when I press a button and I don't want
the vibrations stop when I turn off the screen.
Is it possible and if yes, how to do it ?
Thank you.
I have an application which vibrate when I press a button and I don't want
the vibrations stop when I turn off the screen.
Is it possible and if yes, how to do it ?
Thank you.
why am not able to add a bitmap to the bitmap arraylist
why am not able to add a bitmap to the bitmap arraylist
why am not able to add a bitmap in the bitmap array list inside asynktask.
public static class YourMoves_Players extends AsyncTask<String, String,
String> {
// static String yourmove_players[];
@Override
protected String doInBackground(String... args) {
boolean failure = false;
// TODO Auto-generated method stub
// Check for success tag
int success;
Log.d("login.on create","YOURMOVE_PLAYERS Background");
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("playerid", fb_id));//player_id
Log.d("request!", "starting");
//Posting user data to script
JSONObject json = jsonParser.makeHttpRequest(
GETYOURMOVE_URL, "POST", params);
if(json == null)
{
Log.d("json","json returning null");
return null;
}
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
products = json.getJSONArray(TAG_PRODUCTS);
Log.d("Notification","BEFORE FOR LOOP");
Log.d("",products.length()+" LENGTH");
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
String yourmove_pid = c.getString(TAG_YOURMOVE_ID);
String player_name = c.getString(TAG_YOURMOVE_NAME);
// yourmove_pic.add(Get_FB_Image.getFBImage(yourmove_pid));
Players player=new Players(yourmove_pid,player_name);
yourmove_list.add(player);
yourmove_id.add(yourmove_pid);
yourmove.add(player_name);
Log.d("Vs_facebook","going to add bitmap facebook
image");
yourmove_pic.add(Get_FB_Image.getFBImage(yourmove_pid));
Log.d("Vs_facebook"," facebook image added");
Log.d("User Created!", json.toString()+"CONGRETS");
}
Log.d("","AFTER FOR LOOP yourmove_id "+yourmove_id);
return json.getString(TAG_MESSAGE);
}else{
Log.d("Login Failure!", "SUCCESS FAILED");
return json.getString(TAG_MESSAGE);
}
} catch (JSONException e) {
e.printStackTrace();
}
catch(Exception e){}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
}
"yourmove_pic" is a bitmap array list and
"Get_FB_Image.getFBImage(yourmove_pid)" is the method from where am
getting the facebook profile image of a user. but my app get stuck before
executing this line . am getting the log message that i am printing before
executing this line.
so what is the problem please help
my Logcat message ----->
09-19 10:21:48.999: I/Choreographer(2115): Skipped 77 frames! The
application may be doing too much work on its main thread.
09-19 10:21:49.300: I/Choreographer(2115): Skipped 194 frames! The
application may be doing too much work on its main thread.
09-19 10:21:49.350: D/Vs_facebook(2115): inside on start
09-19 10:21:49.390: D/(2115): Vs_FACEBOOK ON RESUME BEFORE ShowList
09-19 10:21:52.509: D/login.on create(2115): YOURMOVE_PLAYERS Background
09-19 10:21:52.560: D/request!(2115): starting
09-19 10:21:54.980: D/Notification(2115): BEFORE FOR LOOP
09-19 10:21:54.980: D/(2115): 4 LENGTH
09-19 10:21:55.000: D/Vs_facebook(2115): going to add bitmap facebook image
why am not able to add a bitmap in the bitmap array list inside asynktask.
public static class YourMoves_Players extends AsyncTask<String, String,
String> {
// static String yourmove_players[];
@Override
protected String doInBackground(String... args) {
boolean failure = false;
// TODO Auto-generated method stub
// Check for success tag
int success;
Log.d("login.on create","YOURMOVE_PLAYERS Background");
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("playerid", fb_id));//player_id
Log.d("request!", "starting");
//Posting user data to script
JSONObject json = jsonParser.makeHttpRequest(
GETYOURMOVE_URL, "POST", params);
if(json == null)
{
Log.d("json","json returning null");
return null;
}
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
products = json.getJSONArray(TAG_PRODUCTS);
Log.d("Notification","BEFORE FOR LOOP");
Log.d("",products.length()+" LENGTH");
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
String yourmove_pid = c.getString(TAG_YOURMOVE_ID);
String player_name = c.getString(TAG_YOURMOVE_NAME);
// yourmove_pic.add(Get_FB_Image.getFBImage(yourmove_pid));
Players player=new Players(yourmove_pid,player_name);
yourmove_list.add(player);
yourmove_id.add(yourmove_pid);
yourmove.add(player_name);
Log.d("Vs_facebook","going to add bitmap facebook
image");
yourmove_pic.add(Get_FB_Image.getFBImage(yourmove_pid));
Log.d("Vs_facebook"," facebook image added");
Log.d("User Created!", json.toString()+"CONGRETS");
}
Log.d("","AFTER FOR LOOP yourmove_id "+yourmove_id);
return json.getString(TAG_MESSAGE);
}else{
Log.d("Login Failure!", "SUCCESS FAILED");
return json.getString(TAG_MESSAGE);
}
} catch (JSONException e) {
e.printStackTrace();
}
catch(Exception e){}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
}
"yourmove_pic" is a bitmap array list and
"Get_FB_Image.getFBImage(yourmove_pid)" is the method from where am
getting the facebook profile image of a user. but my app get stuck before
executing this line . am getting the log message that i am printing before
executing this line.
so what is the problem please help
my Logcat message ----->
09-19 10:21:48.999: I/Choreographer(2115): Skipped 77 frames! The
application may be doing too much work on its main thread.
09-19 10:21:49.300: I/Choreographer(2115): Skipped 194 frames! The
application may be doing too much work on its main thread.
09-19 10:21:49.350: D/Vs_facebook(2115): inside on start
09-19 10:21:49.390: D/(2115): Vs_FACEBOOK ON RESUME BEFORE ShowList
09-19 10:21:52.509: D/login.on create(2115): YOURMOVE_PLAYERS Background
09-19 10:21:52.560: D/request!(2115): starting
09-19 10:21:54.980: D/Notification(2115): BEFORE FOR LOOP
09-19 10:21:54.980: D/(2115): 4 LENGTH
09-19 10:21:55.000: D/Vs_facebook(2115): going to add bitmap facebook image
Concatinating values of a matching string in an arrray
Concatinating values of a matching string in an arrray
I have a string array[2] as follows:
1st Array 2nd Aray
"100101" "Testing123"
"100102" "Apple123"
"100101" "Dog123"
"100104" "Cat123"
"100101" "Animal123"
I would like to concatenate all elements of the 2nd array if the elements
in the first array match.
For example elements of the first array that match are "100101", "100101"
and "100101". So a string with the concatenated values of the respective
2nd array would be as follows:
"Testing123 Dog123 Animal123"
How could this be achieved elegantly?
I have a string array[2] as follows:
1st Array 2nd Aray
"100101" "Testing123"
"100102" "Apple123"
"100101" "Dog123"
"100104" "Cat123"
"100101" "Animal123"
I would like to concatenate all elements of the 2nd array if the elements
in the first array match.
For example elements of the first array that match are "100101", "100101"
and "100101". So a string with the concatenated values of the respective
2nd array would be as follows:
"Testing123 Dog123 Animal123"
How could this be achieved elegantly?
Wednesday, 18 September 2013
Can we create iTunes or iExplorer like application?
Can we create iTunes or iExplorer like application?
Now I'm trying to create an application; using that desktop application we
can sync the iOS device and we can share the document with PC? Is it
possible?Can we create iTunes or iExplorer like like application?Is there
any certificate issue?
Now I'm trying to create an application; using that desktop application we
can sync the iOS device and we can share the document with PC? Is it
possible?Can we create iTunes or iExplorer like like application?Is there
any certificate issue?
SQlite DB search where
SQlite DB search where
Edittexte yazdýðým isime göre veritabanýnda nasýl arama yapabilirim.
sample:phone book application
my code;
SQLiteDatabase vt = VtArac.getReadableDatabase(); Cursor VTYeri =
vt.query(DatabaseHelper.VT_TABLO, new String[]{ "Id", "banka", "sira",
"kod", "aktif", "rea", "kap", "Ryzde", "Kyzde"}, "Id" + "=" + "1", null,
null, null,null, null); startManagingCursor(VTYeri);
while(VTYeri.moveToNext()) { String Id_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("Id")));
IDDD.setText(Id_Degiskeni.toString()); String banka_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("banka")));
editText1.setText(banka_Degiskeni.toString()); String sira_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("sira")));
editText2.setText(sira_Degiskeni.toString()); String kod_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("kod")));
editText3.setText(kod_Degiskeni.toString()); String aktif_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("aktif")));
aktif.setText(aktif_Degiskeni.toString()); String rea_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("rea")));
reaktif.setText(rea_Degiskeni.toString()); String kap_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("kap")));
kapasitif.setText(kap_Degiskeni.toString()); String Ryzde_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("Ryzde")));
Ryuzde.setText(Ryzde_Degiskeni.toString()); String Kyzde_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("Kyzde")));
Kyuzde.setText(Kyzde_Degiskeni.toString()); } } });
Edittexte yazdýðým isime göre veritabanýnda nasýl arama yapabilirim.
sample:phone book application
my code;
SQLiteDatabase vt = VtArac.getReadableDatabase(); Cursor VTYeri =
vt.query(DatabaseHelper.VT_TABLO, new String[]{ "Id", "banka", "sira",
"kod", "aktif", "rea", "kap", "Ryzde", "Kyzde"}, "Id" + "=" + "1", null,
null, null,null, null); startManagingCursor(VTYeri);
while(VTYeri.moveToNext()) { String Id_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("Id")));
IDDD.setText(Id_Degiskeni.toString()); String banka_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("banka")));
editText1.setText(banka_Degiskeni.toString()); String sira_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("sira")));
editText2.setText(sira_Degiskeni.toString()); String kod_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("kod")));
editText3.setText(kod_Degiskeni.toString()); String aktif_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("aktif")));
aktif.setText(aktif_Degiskeni.toString()); String rea_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("rea")));
reaktif.setText(rea_Degiskeni.toString()); String kap_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("kap")));
kapasitif.setText(kap_Degiskeni.toString()); String Ryzde_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("Ryzde")));
Ryuzde.setText(Ryzde_Degiskeni.toString()); String Kyzde_Degiskeni =
VTYeri.getString((VTYeri.getColumnIndex("Kyzde")));
Kyuzde.setText(Kyzde_Degiskeni.toString()); } } });
filtering a listbox using a textbox in ms access 2010
filtering a listbox using a textbox in ms access 2010
I would like to filter a listbox using a textbox in MS Access 2010. Can
anyone show me how to fix what I have below so that the textbox input
actually filters the listbox?
I have a listbox named lstbxClients whose contents I want to filter using
input from a textbox called txtFilterClients. The rowsource property of
lstbxClients is set to:
SELECT Clients.ClientNumber, Clients.FullName FROM Clients ORDER BY
Clients.[FullName];
The image below shows the layout, along with the property sheet and
expression builder open to illustrate the expression that I added to the
On Change event of txtFilterClients:
I would like to filter a listbox using a textbox in MS Access 2010. Can
anyone show me how to fix what I have below so that the textbox input
actually filters the listbox?
I have a listbox named lstbxClients whose contents I want to filter using
input from a textbox called txtFilterClients. The rowsource property of
lstbxClients is set to:
SELECT Clients.ClientNumber, Clients.FullName FROM Clients ORDER BY
Clients.[FullName];
The image below shows the layout, along with the property sheet and
expression builder open to illustrate the expression that I added to the
On Change event of txtFilterClients:
(trying to define a S3 function using UseMethod)
(trying to define a S3 function using UseMethod)
I am new to the programming R. I defined a function called liw.mstreeClass
and I defined as below, but when I run the program I am keep getting the
following errors:
# define method: lcosts(generic dispatch)
liw.mstreeClass <- function(nb, data, method, p) UseMethod("nbcosts"){
Error: unexpected '{' in "liw.mstreeClass <- function(nb, data, method, p)
UseMethod("nbcosts"){"
if(method=="penrose") { liw <-
mat2listw(penroseDis.mstreeClass((scale(data))))
return(liw)}
Error: object 'method' not found } Error: unexpected '}' in " }"
could someone help me? thanks :)
I am new to the programming R. I defined a function called liw.mstreeClass
and I defined as below, but when I run the program I am keep getting the
following errors:
# define method: lcosts(generic dispatch)
liw.mstreeClass <- function(nb, data, method, p) UseMethod("nbcosts"){
Error: unexpected '{' in "liw.mstreeClass <- function(nb, data, method, p)
UseMethod("nbcosts"){"
if(method=="penrose") { liw <-
mat2listw(penroseDis.mstreeClass((scale(data))))
return(liw)}
Error: object 'method' not found } Error: unexpected '}' in " }"
could someone help me? thanks :)
Bootstrap 3 button-group and input-group in one row
Bootstrap 3 button-group and input-group in one row
if you have a look at the following example, you can see that the
input-group is bwloe the button-group:
http://bootply.com/81723
I already tried putting both groups into floating divs, but the browsers
still break the row. I noticed that ".btn-group, .btn-group-vertical"
contain a "display: inline-block". After commenting this line out, the row
doesn't break, but i don't have a space between both div (although I
thought to get one by "padding-right: 16px")
if you have a look at the following example, you can see that the
input-group is bwloe the button-group:
http://bootply.com/81723
I already tried putting both groups into floating divs, but the browsers
still break the row. I noticed that ".btn-group, .btn-group-vertical"
contain a "display: inline-block". After commenting this line out, the row
doesn't break, but i don't have a space between both div (although I
thought to get one by "padding-right: 16px")
Oracle return custom type as SQL rows in package
Oracle return custom type as SQL rows in package
I'm aiming to define a custom type for an employee (ID and name), and then
a custom type for a table of employees. I have created a function within a
package that returns the table of employees type. All of this compiles
fine.
The problem is when I try to call the function and retrieve the results as
SQL rows, Oracle produces the error:
ORA-00902: invalid datatype
Package specification:
type t_employee is record
(
id number,
name varchar2(300),
);
type t_employees is table of t_employee index by pls_integer;
function get_employees(input1 varchar2) return t_employees;
Package body:
function get_employees(input1 varchar2)
return t_employees
is
employee_list t_employees;
begin
employee_list(1).id := 123;
employee_list(1).name := 'Stan';
employee_list(2).id := 456;
employee_list(2).name := 'Jan';
return employee_list;
end get_employees;
I call it through the apex SQL Workshop like so:
select * from table(my_pkg.get_employees('some input'))
This then gives the invalid datatype error. How can I return this custom
type as SQL rows (in the same way as if I was querying a standard table)?
I'm aiming to define a custom type for an employee (ID and name), and then
a custom type for a table of employees. I have created a function within a
package that returns the table of employees type. All of this compiles
fine.
The problem is when I try to call the function and retrieve the results as
SQL rows, Oracle produces the error:
ORA-00902: invalid datatype
Package specification:
type t_employee is record
(
id number,
name varchar2(300),
);
type t_employees is table of t_employee index by pls_integer;
function get_employees(input1 varchar2) return t_employees;
Package body:
function get_employees(input1 varchar2)
return t_employees
is
employee_list t_employees;
begin
employee_list(1).id := 123;
employee_list(1).name := 'Stan';
employee_list(2).id := 456;
employee_list(2).name := 'Jan';
return employee_list;
end get_employees;
I call it through the apex SQL Workshop like so:
select * from table(my_pkg.get_employees('some input'))
This then gives the invalid datatype error. How can I return this custom
type as SQL rows (in the same way as if I was querying a standard table)?
Tuesday, 17 September 2013
pagination not working after doing filter inKendo grid
pagination not working after doing filter inKendo grid
I am having an mvc application and my view is .cshtml. I am making a Kendo
grid by using DataSource with server binding , I have made my own
pagination for setting the page size . I ran into one issue that when i
filtered the data and then done my own pagination then it does not work as
in Kendo grid in url there comes Grid-page-size which set first times and
it never changed .
How can i solve this ? It will be appreciable if anyone solved this problem?
Here is my code for grid :-
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.info).Title("Info").Width("150px");
columns.Bound(o => o.name).Title("Name").Width("90px");
columns.Bound(o => o.address).Title("Address").Width("100px");
columns.Bound(o => o.city).Title("City").Width("85px");
columns.Bound(o => o.state).Title("State").Width("90px");
})
.DataSource(dataSource => dataSource.Server()
.PageSize(Convert.ToInt16(ViewData["PageSize"]))
).Pageable(pager => pager
.Refresh(true)
.Numeric(true)
).Scrollable(scrolling => scrolling.Height("*"))
.Sortable()
.Resizable(resizing => resizing.Columns(true))
.Filterable(filtering => filtering.Enabled(true))
.ColumnMenu()
)
I am having an mvc application and my view is .cshtml. I am making a Kendo
grid by using DataSource with server binding , I have made my own
pagination for setting the page size . I ran into one issue that when i
filtered the data and then done my own pagination then it does not work as
in Kendo grid in url there comes Grid-page-size which set first times and
it never changed .
How can i solve this ? It will be appreciable if anyone solved this problem?
Here is my code for grid :-
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.info).Title("Info").Width("150px");
columns.Bound(o => o.name).Title("Name").Width("90px");
columns.Bound(o => o.address).Title("Address").Width("100px");
columns.Bound(o => o.city).Title("City").Width("85px");
columns.Bound(o => o.state).Title("State").Width("90px");
})
.DataSource(dataSource => dataSource.Server()
.PageSize(Convert.ToInt16(ViewData["PageSize"]))
).Pageable(pager => pager
.Refresh(true)
.Numeric(true)
).Scrollable(scrolling => scrolling.Height("*"))
.Sortable()
.Resizable(resizing => resizing.Columns(true))
.Filterable(filtering => filtering.Enabled(true))
.ColumnMenu()
)
how to change to a new activity from a button click inside a fragmenttab
how to change to a new activity from a button click inside a fragmenttab
Hi i'm working on a app that has swipe tabs inside the tabs there is
buttons so for example fragmenttab1 has Algabra button i want it when the
user clicks this button it takes them to AlgabraHome.class i have no idea
how to do this any help would be amazing!
fragmanttab1.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/algabra"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="56dp"
android:text="Algabra" />
<Button
android:id="@+id/geomtery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/algabra"
android:layout_below="@+id/algabra"
android:layout_marginTop="75dp"
android:text="geomtery" />
</RelativeLayout>
FragmentTab1.java
package com.androidbegin.absviewpagertutorial;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment;
public class FragmentTab1 extends SherlockFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Get the view from fragmenttab1.xml
View view = inflater.inflate(R.layout.fragmenttab1, container,
false);
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
setUserVisibleHint(true);
}
}
if you need anything else please let me know
i'm new to android development and am learning so no non helpful comments
please :)
Thanks
Hi i'm working on a app that has swipe tabs inside the tabs there is
buttons so for example fragmenttab1 has Algabra button i want it when the
user clicks this button it takes them to AlgabraHome.class i have no idea
how to do this any help would be amazing!
fragmanttab1.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/algabra"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="56dp"
android:text="Algabra" />
<Button
android:id="@+id/geomtery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/algabra"
android:layout_below="@+id/algabra"
android:layout_marginTop="75dp"
android:text="geomtery" />
</RelativeLayout>
FragmentTab1.java
package com.androidbegin.absviewpagertutorial;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment;
public class FragmentTab1 extends SherlockFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Get the view from fragmenttab1.xml
View view = inflater.inflate(R.layout.fragmenttab1, container,
false);
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
setUserVisibleHint(true);
}
}
if you need anything else please let me know
i'm new to android development and am learning so no non helpful comments
please :)
Thanks
on ajax the echo function is not working
on ajax the echo function is not working
I got problem in output of ajax, its not working but when i play it
seperate on new page it works. I did noConflict and other things but not
working still please help..
this is what i want to echo when ajax call -
<link href="http://xoxco.com/projects/code/tagsinput/jquery.tagsinput.css"
rel="stylesheet" type="text/css">
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
var dam123 = jQuery.noConflict();
</script>
<script type="text/javascript"
src="http://xoxco.com/projects/code/tagsinput/jquery.tagsinput.js"></script>
<script type="text/javascript">
var dam123 = jQuery.noConflict();
</script>
<script type="text/javascript">
dam123(function() {
dam123("#tags_1").tagsInput({
// my parameters here
});
});
</script>
<body onload="javascript://dam123();">
<input id="tags_1" value="alpha,beta,gamma" />
I got problem in output of ajax, its not working but when i play it
seperate on new page it works. I did noConflict and other things but not
working still please help..
this is what i want to echo when ajax call -
<link href="http://xoxco.com/projects/code/tagsinput/jquery.tagsinput.css"
rel="stylesheet" type="text/css">
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
var dam123 = jQuery.noConflict();
</script>
<script type="text/javascript"
src="http://xoxco.com/projects/code/tagsinput/jquery.tagsinput.js"></script>
<script type="text/javascript">
var dam123 = jQuery.noConflict();
</script>
<script type="text/javascript">
dam123(function() {
dam123("#tags_1").tagsInput({
// my parameters here
});
});
</script>
<body onload="javascript://dam123();">
<input id="tags_1" value="alpha,beta,gamma" />
neo4j cypher index query
neo4j cypher index query
I was used to use node_auto_index( condition ) to search for nodes using
indexes, but now i used batch-import (
https://github.com/jexp/batch-import/ ) and it created indexes with
specific names ( type, code, etc ). So, how to do a cypher query using
indexes on multiple properties ?
old query example :
START n = node : node_auto_index( 'type: NODE_TYPE AND code: NODE_CODE' )
RETURN n;
how to do the 'same' query but without node_auto_index and specific index
names ?
START n = node : type( "type = NODE_TYPE" ) RETURN n;
I was used to use node_auto_index( condition ) to search for nodes using
indexes, but now i used batch-import (
https://github.com/jexp/batch-import/ ) and it created indexes with
specific names ( type, code, etc ). So, how to do a cypher query using
indexes on multiple properties ?
old query example :
START n = node : node_auto_index( 'type: NODE_TYPE AND code: NODE_CODE' )
RETURN n;
how to do the 'same' query but without node_auto_index and specific index
names ?
START n = node : type( "type = NODE_TYPE" ) RETURN n;
How to output currency symbols with Prawn?
How to output currency symbols with Prawn?
I am trying to output currency symbols in Prawn with a helper method like
this:
def price(number)
@view.number_to_currency(number, :unit => "€")
end
I then use it like this:
price(@invoice.total)
Unfortunately it's not working and instead of I get € in my PDF
documents.
(The same number_to_currency function works great outside of Prawn by the
way.)
Can anybody help?
I am trying to output currency symbols in Prawn with a helper method like
this:
def price(number)
@view.number_to_currency(number, :unit => "€")
end
I then use it like this:
price(@invoice.total)
Unfortunately it's not working and instead of I get € in my PDF
documents.
(The same number_to_currency function works great outside of Prawn by the
way.)
Can anybody help?
MATLAB/Octave - Problems with mesh plot
MATLAB/Octave - Problems with mesh plot
I am trying to mesh the following function in Octave:
function C = istep(x)
A = x < 0.75
B = x > 0.25
C = A & B
endfunction
D = rand(10);
mesh(istep(D));
using 10x10 (random) matrix as an input. The mesh function however fails
and fires
invalid value for array property "zdata"
Note: Meshing D itself works fine. The function istep also returns 10x10
"matrix" with expected values. I suspect the error lies in the fact that
the internal format of the output is not treated as a matrix, but rather
as a data "array" or something more abstract. I am not sure how to change
it however.
Also, multiplying the output by eye(size(D)) solves the issue and allows
to plot the matrix (i suspect it casts the output to matrix
automatically). I do not find this very elegant though and would like to
avoid it if possible.
Edit: spy() works fine directly on the output, without need of
multiplication by eye()
Question: What shall I change in the code so I am able to plot the matrix
istep(D)?
I am trying to mesh the following function in Octave:
function C = istep(x)
A = x < 0.75
B = x > 0.25
C = A & B
endfunction
D = rand(10);
mesh(istep(D));
using 10x10 (random) matrix as an input. The mesh function however fails
and fires
invalid value for array property "zdata"
Note: Meshing D itself works fine. The function istep also returns 10x10
"matrix" with expected values. I suspect the error lies in the fact that
the internal format of the output is not treated as a matrix, but rather
as a data "array" or something more abstract. I am not sure how to change
it however.
Also, multiplying the output by eye(size(D)) solves the issue and allows
to plot the matrix (i suspect it casts the output to matrix
automatically). I do not find this very elegant though and would like to
avoid it if possible.
Edit: spy() works fine directly on the output, without need of
multiplication by eye()
Question: What shall I change in the code so I am able to plot the matrix
istep(D)?
Sunday, 15 September 2013
Optimal number of database connections (node-mysql)
Optimal number of database connections (node-mysql)
By default, node-mysql limits the maximum number of mysql connections in a
connection pool to 10.
Is there an optimal number of connections I should set it to? ( is there a
number beyond which performance degrades, instead of increasing? )
Thanks
By default, node-mysql limits the maximum number of mysql connections in a
connection pool to 10.
Is there an optimal number of connections I should set it to? ( is there a
number beyond which performance degrades, instead of increasing? )
Thanks
Google Script for Spreadsheet - how can I prompt the user to select a range?
Google Script for Spreadsheet - how can I prompt the user to select a range?
I've been doing a lot of work with Google Script to automate some peer
evaluation processes.
One result is a spreadsheet with a lot of review data that I need to sort,
group and summarize. The script is working fine for the hard-coded sort
column.
But I really want to be able to sort on different columns at different
times, and I'd like the sort/group/summarize script to prompt the user to
select the sort/group column at runtime.
I've explored the UI stuff a bit, but I haven't seen how to prompt the
user to select a range (or column or anything else) on the sheet.
Thanks in advance.
I've been doing a lot of work with Google Script to automate some peer
evaluation processes.
One result is a spreadsheet with a lot of review data that I need to sort,
group and summarize. The script is working fine for the hard-coded sort
column.
But I really want to be able to sort on different columns at different
times, and I'd like the sort/group/summarize script to prompt the user to
select the sort/group column at runtime.
I've explored the UI stuff a bit, but I haven't seen how to prompt the
user to select a range (or column or anything else) on the sheet.
Thanks in advance.
Yii url rewriting is not working for Multi Language Website
Yii url rewriting is not working for Multi Language Website
I am creating a website in two languages i.e. English and French. so i am
using this approach to make it possible.
SEO-conform-multilingual-urls-language-selector-widget
Everything is working fine by using this but url rwrite.
I have tried all of these below mentioned one by one but had no luck to
get desired one.
'<language:(en|es)>/our-services'=>'services/index' and
'<language:(en|es)>/<controller:services>/<action:index>/*'=>'<controller>',
and
'our-services' => 'services/index'
i am calling index function of service controller in navigation bar as
$this->createUrl('/services/index')
and i have already tried it by removing first slash before services and
also by adding last slash after index but no luck.
I need to customize my url for any language i use. yeah for sure url will
be same for both language but the content of pages will be differ as per
language( text is working fine for each language as
`Yii::t('file_name','array_key_name'))
Please help me ASAP
I am creating a website in two languages i.e. English and French. so i am
using this approach to make it possible.
SEO-conform-multilingual-urls-language-selector-widget
Everything is working fine by using this but url rwrite.
I have tried all of these below mentioned one by one but had no luck to
get desired one.
'<language:(en|es)>/our-services'=>'services/index' and
'<language:(en|es)>/<controller:services>/<action:index>/*'=>'<controller>',
and
'our-services' => 'services/index'
i am calling index function of service controller in navigation bar as
$this->createUrl('/services/index')
and i have already tried it by removing first slash before services and
also by adding last slash after index but no luck.
I need to customize my url for any language i use. yeah for sure url will
be same for both language but the content of pages will be differ as per
language( text is working fine for each language as
`Yii::t('file_name','array_key_name'))
Please help me ASAP
Trigger image transition by hovering over a text link
Trigger image transition by hovering over a text link
OK, I'm a complete rookie and have gleemed the coding I have so far from
various resources online and adapted it to suit my needs, so be gentle :P
Basically, I have a nice CSS transition happening when hovering over an
image. However, I want to put a text link beneath said image, that will
trigger the same image transition when you hover over the text link. Is
this possible? I've been searching for a result for some time now and
still not cracked this one!
CSS
a.home:link {color:#040404; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
a.home:visited {color:#040404; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
a.home:hover {color:#E5712C; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
a.home:active {color:#5F5F5F; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
#crossfade
{
position: relative;
width: 200px;
height: 200px;
border: solid 2px #5f5f5f;
border-radius: 8px;
box-shadow: 0px 10px 5px #888888;
}
#crossfade img
{
position:absolute;
left:0;
opacity: 1;
-webkit-transition: opacity 0.8s ease-in-out;
-moz-transition: opacity 0.8s ease-in-out;
-o-transition: opacity 0.8s ease-in-out;
-ms-transition: opacity 0.8s ease-in-out;
transition: opacity 0.8s ease-in-out;
}
#crossfade img.top:hover {
opacity:0;
}
HTML
<div id="crossfade">
<img class="bottom"
src="http://www.officialdrivingtheory.co.uk/wp-content/uploads/TheoryTest-question.jpg"><a
href="http://www.livingthai.org/wp-content/uploads/2011/10/How-to-test-your-Thai-Language-ability.jpg"</a>
<img class="top"
src="http://www.dandybooksellers.com/acatalog/PracticalTest.jpg"/><a
href="http://www.livingthai.org/wp-content/uploads/2011/10/How-to-test-your-Thai-Language-ability.jpg"</a>
</div></br>
<a class ="home"
href="http://www.livingthai.org/wp-content/uploads/2011/10/How-to-test-your-Thai-Language-ability.jpg">TESTING</a>
You can see what I'm trying to do here: http://jsfiddle.net/WxVE4/1/
I've just used placeholder images and links for now as my site isn't
published yet.
Oh, and if anyone can tell me how to align the text link nice and
centrally beneath the image then that's extra brownie points :D
OK, I'm a complete rookie and have gleemed the coding I have so far from
various resources online and adapted it to suit my needs, so be gentle :P
Basically, I have a nice CSS transition happening when hovering over an
image. However, I want to put a text link beneath said image, that will
trigger the same image transition when you hover over the text link. Is
this possible? I've been searching for a result for some time now and
still not cracked this one!
CSS
a.home:link {color:#040404; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
a.home:visited {color:#040404; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
a.home:hover {color:#E5712C; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
a.home:active {color:#5F5F5F; text-decoration:none; font-weight:bold;
font-family:"Lucida Console", Monaco, monospace; font-size:18px;}
#crossfade
{
position: relative;
width: 200px;
height: 200px;
border: solid 2px #5f5f5f;
border-radius: 8px;
box-shadow: 0px 10px 5px #888888;
}
#crossfade img
{
position:absolute;
left:0;
opacity: 1;
-webkit-transition: opacity 0.8s ease-in-out;
-moz-transition: opacity 0.8s ease-in-out;
-o-transition: opacity 0.8s ease-in-out;
-ms-transition: opacity 0.8s ease-in-out;
transition: opacity 0.8s ease-in-out;
}
#crossfade img.top:hover {
opacity:0;
}
HTML
<div id="crossfade">
<img class="bottom"
src="http://www.officialdrivingtheory.co.uk/wp-content/uploads/TheoryTest-question.jpg"><a
href="http://www.livingthai.org/wp-content/uploads/2011/10/How-to-test-your-Thai-Language-ability.jpg"</a>
<img class="top"
src="http://www.dandybooksellers.com/acatalog/PracticalTest.jpg"/><a
href="http://www.livingthai.org/wp-content/uploads/2011/10/How-to-test-your-Thai-Language-ability.jpg"</a>
</div></br>
<a class ="home"
href="http://www.livingthai.org/wp-content/uploads/2011/10/How-to-test-your-Thai-Language-ability.jpg">TESTING</a>
You can see what I'm trying to do here: http://jsfiddle.net/WxVE4/1/
I've just used placeholder images and links for now as my site isn't
published yet.
Oh, and if anyone can tell me how to align the text link nice and
centrally beneath the image then that's extra brownie points :D
Comments only posting to most recent status update
Comments only posting to most recent status update
The news feed on the sites dashboard I'm working on has multiple items
from different users; and can also be commented on. However, whenever you
write a comment under each post, it only posts to the post at the top of
the feed (the most recent one). Comments are posted instantly by pressing
the enter key, which then runs this JS code which is on the index.php
page.
$(function(){
$('#comment_body').live( 'keypress' , function (e) {
var boxVal = $(this).val();
var sendTo = $('#to_id').val();
if ( e.keyCode == '13' ) {
e.preventDefault();
$.post( 'instantcom.php' , { 'comment_body' : boxVal ,
'activity_id' : sendTo } , function () {
// reload data or just leave blank
} );
$('#comment_body').val('');
}
} );
});
Then, the HTML for the comment box on each post is as follows:
<p align="center" style="height:45px;">
<input type="text" name="comment_body" id="comment_body"
style="margin-top:12px;border:1px solid blue
!important;width:329px;height:21px;" />
<span class=" glyphicons-icon camera"
style="position:relative;bottom:50px;left:155px;"></span></p>
<input name="type" type="hidden" value="a" />
<input name="activity_id" id="to_id" type="hidden" value="' . $act_item_id
. '" />
The ' . $act_item_id . ' is just a PHP variable which contains the unique
ID of the status update.
So then, any ideas as to why comments are only posting to the most recent
posts instead of the ones they're meant to post to?
The news feed on the sites dashboard I'm working on has multiple items
from different users; and can also be commented on. However, whenever you
write a comment under each post, it only posts to the post at the top of
the feed (the most recent one). Comments are posted instantly by pressing
the enter key, which then runs this JS code which is on the index.php
page.
$(function(){
$('#comment_body').live( 'keypress' , function (e) {
var boxVal = $(this).val();
var sendTo = $('#to_id').val();
if ( e.keyCode == '13' ) {
e.preventDefault();
$.post( 'instantcom.php' , { 'comment_body' : boxVal ,
'activity_id' : sendTo } , function () {
// reload data or just leave blank
} );
$('#comment_body').val('');
}
} );
});
Then, the HTML for the comment box on each post is as follows:
<p align="center" style="height:45px;">
<input type="text" name="comment_body" id="comment_body"
style="margin-top:12px;border:1px solid blue
!important;width:329px;height:21px;" />
<span class=" glyphicons-icon camera"
style="position:relative;bottom:50px;left:155px;"></span></p>
<input name="type" type="hidden" value="a" />
<input name="activity_id" id="to_id" type="hidden" value="' . $act_item_id
. '" />
The ' . $act_item_id . ' is just a PHP variable which contains the unique
ID of the status update.
So then, any ideas as to why comments are only posting to the most recent
posts instead of the ones they're meant to post to?
Styling your action bar android
Styling your action bar android
The general action bar in android is quite dull is there any way of
editing this bar in terms of colour, style and the position of icons
rather than having icons arranged right to left can you have a single icon
in the middle this is just an equiry about how far can you customize the
action bar or will you just have to nest images in layouts ?
The general action bar in android is quite dull is there any way of
editing this bar in terms of colour, style and the position of icons
rather than having icons arranged right to left can you have a single icon
in the middle this is just an equiry about how far can you customize the
action bar or will you just have to nest images in layouts ?
Content is half hidden underneath fixed header, despite changing 'top' margin
Content is half hidden underneath fixed header, despite changing 'top' margin
I have recently altered my header to stay fixed. The header is perfect,
but it hides half of the content. I have tried changing the content's
'top' settings but it does not alter the result.
THE HTML:
<div class="gridContainer clearfix">
<div id="LayoutDiv1">We are here to help</div>
<form action="website.php" method="POST">
<div id="LayoutDiv3"> Names:
<input type="text" name="user"/>
Gender<FONT COLOR="#FF0000">*</FONT>
<select name="Gender[]" double="double">
<option value="Female">Female</option>
<option value="Male">Male</option>
</select>
</div>
<div id="Components"></div>
<div id="Food"><h1>Dietary conditions:</h1>
Gluten Free
<input type="checkbox" name="GlutenFree" value="Yes" />
<br>
Diary Free
<input type="checkbox" name="DairyFree" value="Yes" />
<br>
No Softdrink
<input type="checkbox" name="NoSoftDrink" value="Yes" />
<br>
Halal
<input type="checkbox" name="Halal" value="Yes" />
<br>
Vegetarian
<input type="checkbox" name="Vegetarian" value="Yes" />
<br>
No Nuts
<input type="checkbox" name="NoNuts" value="Yes" />
<br>
Other
<input type="checkbox" name="Other" value="Yes" /></div>
THE CSS:
#LayoutDiv1 {
position: fixed;
height: 75px;
top: 0;
width: 100%;
z-index: 10000;
background:#FFF
}
#LayoutDiv3 {
position: fixed;
height: 30px;
top: 75px;
width: 100%;
z-index: 10002;
background:#FFF
}
#Components {
top: 2000px; //Has no effect, and either does changing the 'top' setting
for each div
within 'components.
}
Thankyou
I have recently altered my header to stay fixed. The header is perfect,
but it hides half of the content. I have tried changing the content's
'top' settings but it does not alter the result.
THE HTML:
<div class="gridContainer clearfix">
<div id="LayoutDiv1">We are here to help</div>
<form action="website.php" method="POST">
<div id="LayoutDiv3"> Names:
<input type="text" name="user"/>
Gender<FONT COLOR="#FF0000">*</FONT>
<select name="Gender[]" double="double">
<option value="Female">Female</option>
<option value="Male">Male</option>
</select>
</div>
<div id="Components"></div>
<div id="Food"><h1>Dietary conditions:</h1>
Gluten Free
<input type="checkbox" name="GlutenFree" value="Yes" />
<br>
Diary Free
<input type="checkbox" name="DairyFree" value="Yes" />
<br>
No Softdrink
<input type="checkbox" name="NoSoftDrink" value="Yes" />
<br>
Halal
<input type="checkbox" name="Halal" value="Yes" />
<br>
Vegetarian
<input type="checkbox" name="Vegetarian" value="Yes" />
<br>
No Nuts
<input type="checkbox" name="NoNuts" value="Yes" />
<br>
Other
<input type="checkbox" name="Other" value="Yes" /></div>
THE CSS:
#LayoutDiv1 {
position: fixed;
height: 75px;
top: 0;
width: 100%;
z-index: 10000;
background:#FFF
}
#LayoutDiv3 {
position: fixed;
height: 30px;
top: 75px;
width: 100%;
z-index: 10002;
background:#FFF
}
#Components {
top: 2000px; //Has no effect, and either does changing the 'top' setting
for each div
within 'components.
}
Thankyou
Saturday, 14 September 2013
Import External Libraries in pycharm
Import External Libraries in pycharm
Hi how do I add external libraries to my python project in python? I
already included the python interpreter but I can't find any option to
include additional libraries. Iam using pycharm 2.7.3 on my Mac Thanks for
the help
Hi how do I add external libraries to my python project in python? I
already included the python interpreter but I can't find any option to
include additional libraries. Iam using pycharm 2.7.3 on my Mac Thanks for
the help
Can JQuery and Javascript be used in the same .js file?
Can JQuery and Javascript be used in the same .js file?
I'm trying to create a messaging system that uses ajax that doesn't have
to reload when the message is submitted. I have a .js file that uses an
onclick to open the form to insert your message and then a differant
function to submit the form. Is this not working because I am doing
something wrong or because you cant use JQuery and Javascript in the same
file.
Here is my code:
//I have a button that calls this function with an onclick in my HTML file
function createMessage() {
var form = document.createElement("form");
form.name = "form_input";
form.method = "POST";
form.action = "messages.php";
//I also have a container div in my HTML
container.appendChild(form);
var textarea = document.createElement("textarea");
textarea.name = "message_input";
textarea.action = "messages.php"
textarea.method = "POST";
textarea.cols = 84;
textarea.rows = 16;
textarea.id = "message_input";
form.appendChild(textarea);
var div = document.createElement("div");
div.id = "second_picture";
container.appendChild(div);
var submit = document.createElement("button");
submit.innerHTML = 'Send';
submit.id = 'send_message';
submit.name = 'submit';
form.appendChild(submit);
submit.onclick = submitMessage;
};
function submitMessage() {
$(function() {
$("#send_message").click(function() {
var message = $("input#message_input").val();
var dataString = 'message_input='+ message;
$.ajax({
type: "POST",
url: "messages.php",
data: dataString,
success: function() {
alert('Ok.');
}
});
return false;
});
});
};
I'm trying to create a messaging system that uses ajax that doesn't have
to reload when the message is submitted. I have a .js file that uses an
onclick to open the form to insert your message and then a differant
function to submit the form. Is this not working because I am doing
something wrong or because you cant use JQuery and Javascript in the same
file.
Here is my code:
//I have a button that calls this function with an onclick in my HTML file
function createMessage() {
var form = document.createElement("form");
form.name = "form_input";
form.method = "POST";
form.action = "messages.php";
//I also have a container div in my HTML
container.appendChild(form);
var textarea = document.createElement("textarea");
textarea.name = "message_input";
textarea.action = "messages.php"
textarea.method = "POST";
textarea.cols = 84;
textarea.rows = 16;
textarea.id = "message_input";
form.appendChild(textarea);
var div = document.createElement("div");
div.id = "second_picture";
container.appendChild(div);
var submit = document.createElement("button");
submit.innerHTML = 'Send';
submit.id = 'send_message';
submit.name = 'submit';
form.appendChild(submit);
submit.onclick = submitMessage;
};
function submitMessage() {
$(function() {
$("#send_message").click(function() {
var message = $("input#message_input").val();
var dataString = 'message_input='+ message;
$.ajax({
type: "POST",
url: "messages.php",
data: dataString,
success: function() {
alert('Ok.');
}
});
return false;
});
});
};
How does one read JavaScript API like Mongoose
How does one read JavaScript API like Mongoose
I'm a java developer. I really like to learn javascript. I'm finding it
very difficult to pick-up a library and just learn/use it for two reasons:
1) There is no decent auto-complete. I've tried, eclipse, vjet, nodeclipse
and webstorm...each has its own frustrating set of issues. Maybe the
language is such that, autocomplete is super-difficult. 2) The API
documentation is extremely confusing. I guess it is because I'm new to
JavaScript.
For example, I wanted to figure what the callback function in
mongoose.connect method does and how to declare it. So I checked the api
doc. All it says is that the callback is a function...it doesn't say how
many params it takes, what the values of the params are under various
invocation scenarios...etc.
I feel like I'm missing something...
How does one go about reading these docs?
I'm a java developer. I really like to learn javascript. I'm finding it
very difficult to pick-up a library and just learn/use it for two reasons:
1) There is no decent auto-complete. I've tried, eclipse, vjet, nodeclipse
and webstorm...each has its own frustrating set of issues. Maybe the
language is such that, autocomplete is super-difficult. 2) The API
documentation is extremely confusing. I guess it is because I'm new to
JavaScript.
For example, I wanted to figure what the callback function in
mongoose.connect method does and how to declare it. So I checked the api
doc. All it says is that the callback is a function...it doesn't say how
many params it takes, what the values of the params are under various
invocation scenarios...etc.
I feel like I'm missing something...
How does one go about reading these docs?
Private methods vs Lambda in C++
Private methods vs Lambda in C++
My question refers to:
Using a lambda expression versus a private method
Now that lambda functors are part of C++, they could be used to unclutter
a class' interface. How does lambda use vs private method use compare in
C++? Do there exist better alternatives to unclutter class interfaces?
My question refers to:
Using a lambda expression versus a private method
Now that lambda functors are part of C++, they could be used to unclutter
a class' interface. How does lambda use vs private method use compare in
C++? Do there exist better alternatives to unclutter class interfaces?
Missing before statement
Missing before statement
I have the following piece of code that I would like to style:
var dateString = val.date; // this display my blog post date e.g.
"2013-09-02 15:04:50"
var split = dateString.split(' ');
output += '<div class="postxt">' (split[0] +" at "+ split[1]) '</div>';
How can I add a span or a div for both split0 & split1
Thanks
I have the following piece of code that I would like to style:
var dateString = val.date; // this display my blog post date e.g.
"2013-09-02 15:04:50"
var split = dateString.split(' ');
output += '<div class="postxt">' (split[0] +" at "+ split[1]) '</div>';
How can I add a span or a div for both split0 & split1
Thanks
View calendar post with fancybox
View calendar post with fancybox
I'm making a planning function for my cms. When you click on an post in
the calendar, I'd like it to show up in a popup like FancyBox. My question
is, what is the best way to do that, so that when you click on a post it
shows that post's content, witch comes from a database?
I'm making a planning function for my cms. When you click on an post in
the calendar, I'd like it to show up in a popup like FancyBox. My question
is, what is the best way to do that, so that when you click on a post it
shows that post's content, witch comes from a database?
ontouch method is null pointer exception my application touch in start button
ontouch method is null pointer exception my application touch in start button
class is RadarSceen then method ontouch method is crash is null pointer
exception and this method use start radar and stop radar.then
localRotateAnimation.setDuration(3000L) crash is null pointer exception
public class RadarScreen extends Activity implements View.OnTouchListener {
private static final String APP_TAG = "com.example.ghostsam";
private CountDownTimer countdownHideGhost = null;
private CountDownTimer countdownShowGhost = null;
private DisplayMetrics getDisplay = new DisplayMetrics();
private int getDisplayHeight;
private float getDisplayScale;
private int getDisplayWidth;
private Boolean hideGhosts = Boolean.valueOf(false);
private ImageView ivLogo = null;
private ImageView ivRadar = null;
private ImageView ivRadarGhosts = null;
private ImageView ivSignalButton = null;
private Typeface layoutFontFace;
private Boolean radarRun = Boolean.valueOf(false);
// private RotateAnimation rotateAnimation ;
private RotateAnimation localRotateAnimation;
private boolean settingsGeneralVibrate = true;
private Boolean showGhosts = Boolean.valueOf(false);
private int showGhostsZufallszahl = 0;
private Vibrator vib = null;
public Bitmap drawButton(String paramString1, String paramString2) {
Bitmap localBitmap = Bitmap
.createBitmap(this.getDisplayWidth - (int) (70.0F *
this.getDisplayScale),
(int) (52.0F * this.getDisplayScale),
Bitmap.Config.ARGB_8888);
Canvas localCanvas = new Canvas(localBitmap);
Paint localPaint = new Paint();
localPaint.setTypeface(this.layoutFontFace);
localPaint.setTextAlign(Paint.Align.CENTER);
localPaint.setAntiAlias(true);
localPaint.setColor(Color.parseColor(paramString2));
localCanvas.drawRoundRect(
new RectF(0.0F, 0.0F, localBitmap.getWidth(),
localBitmap.getHeight()), 12.0F,
12.0F, localPaint);
localPaint.setColor(Color.parseColor("#000000"));
localCanvas.drawRoundRect(new RectF(2.0F, 2.0F, -2 +
localBitmap.getWidth(),
-2 + localBitmap.getHeight()), 12.0F, 12.0F, localPaint);
localPaint.setColor(Color.parseColor(paramString2));
localPaint.setAlpha(200);
localPaint.setTextSize(32.0F * this.getDisplayScale);
localPaint.setTextScaleX(1.75F);
localPaint.setFakeBoldText(true);
localCanvas.drawText(paramString1, localBitmap.getWidth() / 2,
36.0F * this.getDisplayScale, localPaint);
return localBitmap;
}
public Bitmap drawRadar(Boolean paramBoolean) {
Bitmap localBitmap = Bitmap
.createBitmap(-50 + this.getDisplayWidth, -50 +
this.getDisplayWidth,
Bitmap.Config.ARGB_8888);
Canvas localCanvas = new Canvas(localBitmap);
Paint localPaint = new Paint();
int i = (int) ((localBitmap.getWidth() - 10.0F *
this.getDisplayScale) / 2.0F
+ 5.0F * this.getDisplayScale);
int j = (int) (i - 5.0F * this.getDisplayScale);
localPaint.setAntiAlias(true);
localPaint.setColor(Color.parseColor("#FFFFFF"));
localPaint.setStyle(Paint.Style.STROKE);
localPaint.setStrokeWidth(3.0F * this.getDisplayScale);
localPaint.setAlpha(75);
for (int k = 0; ; k++) {
if (k > 4) {
localPaint.setAlpha(100);
localPaint.setStyle(Paint.Style.FILL);
localPaint.setShader(new SweepGradient(i, i, 0, -16711936));
if (paramBoolean.booleanValue()) {
RectF localRectF = new RectF();
localRectF.set(i - j, i - j, i + j, i + j);
localCanvas.drawArc(localRectF, 0.0F, 360.0F, true,
localPaint);
}
localPaint.setShader(null);
localPaint.setAlpha(255);
localPaint.setColor(Color.parseColor("#810003"));
localPaint.setStyle(Paint.Style.FILL);
localPaint.setStrokeWidth(0.0F);
localCanvas.drawCircle(i, i, 10.0F * this.getDisplayScale,
localPaint);
return localBitmap;
}
localCanvas.drawCircle(i, i, j - k * 40 *
this.getDisplayScale, localPaint);
}
}
public Bitmap drawRadarGhosts(Boolean paramBoolean) {
Bitmap localBitmap = Bitmap
.createBitmap(-50 + this.getDisplayWidth, -50 +
this.getDisplayWidth,
Bitmap.Config.ARGB_8888);
Canvas localCanvas = new Canvas(localBitmap);
Paint localPaint = new Paint();
if (paramBoolean.booleanValue()) {
int i = (int) ((localBitmap.getWidth() - 10.0F *
this.getDisplayScale) / 2.0F
+ 5.0F * this.getDisplayScale);
int j = (int) (i - 5.0F * this.getDisplayScale);
localPaint.setAntiAlias(true);
localPaint.setAlpha(255);
Random localRandom = new Random();
localPaint.setAlpha(150);
int k = localRandom.nextInt(180);
int m = localRandom.nextInt(j);
int n = i + (int) (Math.cos(3.141592653589793D * k / 180.0D) *
m);
int i1 = i + (int) (Math.sin(3.141592653589793D * k / 180.0D)
* m);
localPaint.setColor(-16711936);
localPaint.setShader(
new RadialGradient(n, i1, 22.0F *
this.getDisplayScale, -16711936, 0,
TileMode.CLAMP));
localCanvas.drawCircle(n, i1, 15.0F * this.getDisplayScale,
localPaint);
if (localRandom.nextInt(50) < 5) {
int i6 = localRandom.nextInt(180);
int i7 = localRandom.nextInt(j);
int i8 = i + (int) (Math.cos(3.141592653589793D * i6 /
180.0D) * i7);
int i9 = i + (int) (Math.sin(3.141592653589793D * i6 /
180.0D) * i7);
localPaint.setShader(
new RadialGradient(i8, i9, 22.0F *
this.getDisplayScale, -16711936, 0,
TileMode.CLAMP));
localCanvas.drawCircle(i8, i9, 15.0F *
this.getDisplayScale, localPaint);
}
if (localRandom.nextInt(75) < 5) {
int i2 = localRandom.nextInt(180);
int i3 = localRandom.nextInt(j);
int i4 = i + (int) (Math.cos(3.141592653589793D * i2 /
180.0D) * i3);
int i5 = i + (int) (Math.sin(3.141592653589793D * i2 /
180.0D) * i3);
localPaint.setShader(
new RadialGradient(i4, i5, 22.0F *
this.getDisplayScale, -16711936, 0,
TileMode.CLAMP));
localCanvas.drawCircle(i4, i5, 15.0F *
this.getDisplayScale, localPaint);
}
}
return localBitmap;
}
public void onCreate(Bundle paramBundle) {
Log.i("com.example.ghostsam", "onStart RadarScreen");
requestWindowFeature(1);
getWindow().setFlags(1024, 1024);
super.onCreate(paramBundle);
setContentView(R.layout.radarscreen);
SharedPreferences localSharedPreferences =
getSharedPreferences("app_prefs", 0);
int i = localSharedPreferences.getInt("appStartCounter", 0);
int j = localSharedPreferences.getInt("appStartFirst", 0);
int k = i + 1;
SharedPreferences.Editor localEditor = localSharedPreferences.edit();
localEditor.putInt("appStartCounter", k);
if (j <= 0) {
localEditor.putInt("appStartFirst", (int)
(System.currentTimeMillis() / 1000L));
}
localEditor.commit();
if ((k == 5) || (k == 10) || (k == 25)) {
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setIcon(17301543);
Resources localResources1 = getResources();
Object[] arrayOfObject1 = new Object[1];
arrayOfObject1[0] = "name";
localBuilder.setTitle(localResources1.getString(R.string.app_name,
arrayOfObject1));
Resources localResources2 = getResources();
Object[] arrayOfObject2 = new Object[1];
arrayOfObject2[0] = "name";
localBuilder.setMessage(localResources2
.getString(R.string.dialog_ratemarket_question,
arrayOfObject2));
Resources localResources3 = getResources();
Object[] arrayOfObject3 = new Object[1];
arrayOfObject3[0] = "name";
localBuilder.setPositiveButton(
localResources3.getString(R.string.dialog_button_yes,
arrayOfObject3),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface
paramDialogInterface,
int paramInt) {
Resources localResources =
RadarScreen.this.getResources();
Object[] arrayOfObject = new Object[1];
arrayOfObject[0] = "name";
Intent localIntent = new
Intent("android.intent.action.VIEW",
Uri.parse(localResources.getString(R.string.app_marketlink,
arrayOfObject)));
RadarScreen.this.startActivity(localIntent);
paramDialogInterface.dismiss();
}
});
Resources localResources4 = getResources();
Object[] arrayOfObject4 = new Object[1];
arrayOfObject4[0] = "name";
localBuilder.setNegativeButton(
localResources4.getString(R.string.dialog_button_no,
arrayOfObject4),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface
paramDialogInterface,
int paramInt) {
paramDialogInterface.dismiss();
}
});
localBuilder.create().show();
}
}
public boolean onCreateOptionsMenu(Menu paramMenu) {
getMenuInflater().inflate(R.menu.radarscreen, paramMenu);
return true;
}
public void onError(Exception paramException) {
}
public void onIllegalHttpStatusCode(int paramInt, String paramString) {
}
public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent) {
if (paramInt == 4) {
quitApp();
}
for (int i = 1; ; i = 0) {
return true;
}
}
@SuppressLint("NewApi")
public boolean onOptionsItemSelected(MenuItem paramMenuItem) {
switch (paramMenuItem.getItemId()) {
default:
break;
case R.id.radarscreen_menu_moreapps:
Resources localResources2 = getResources();
Object[] arrayOfObject2 = new Object[1];
arrayOfObject2[0] = "name";
startActivity(new Intent("android.intent.action.VIEW",
Uri.parse(localResources2
.getString(R.string.app_marketdeveloperlink,
arrayOfObject2))));
break;
case R.id.radarscreen_menu_rateapp:
Resources localResources1 = getResources();
Object[] arrayOfObject1 = new Object[1];
arrayOfObject1[0] = "name";
startActivity(new Intent("android.intent.action.VIEW",
Uri.parse(
localResources1.getString(R.string.app_marketlink,
arrayOfObject1))));
break;
case R.id.radarscreen_menu_about:
startActivity(new Intent(this, About.class));
break;
case R.id.radarscreen_menu_settings:
startActivity(new Intent(this, Settings.class));
break;
case R.id.radarscreen_menu_quit:
quitApp();
}
return true;
}
public void onResume() {
super.onResume();
Log.i("com.example.ghostsam", "onResume RadarScreen");
getWindowManager().getDefaultDisplay().getMetrics(this.getDisplay);
this.getDisplayWidth = this.getDisplay.widthPixels;
this.getDisplayHeight = this.getDisplay.heightPixels;
this.getDisplayScale = (this.getDisplayWidth / 480.0F);
this.layoutFontFace = Typeface.createFromAsset(getAssets(),
"Roboto-Regular.ttf");
this.settingsGeneralVibrate = PreferenceManager
.getDefaultSharedPreferences(getBaseContext())
.getBoolean("settings_general_vibrate", true);
this.vib = ((Vibrator) getSystemService("vibrator"));
this.ivLogo = ((ImageView) findViewById(R.id.ivLogo));
this.ivLogo.setImageBitmap(Bitmap.createScaledBitmap(
BitmapFactory.decodeResource(getResources(),
R.drawable.logo),
(int) (460.0F * this.getDisplayScale), (int) (68.0F *
this.getDisplayScale),
true));
this.ivSignalButton = ((ImageView)
findViewById(R.id.ivSignalButton));
this.ivSignalButton.setImageBitmap(drawButton("start radar",
"#005F21"));
this.ivSignalButton.setOnTouchListener(this);
this.ivRadar = ((ImageView) findViewById(R.id.ivRadar));
this.ivRadar.setImageBitmap(drawRadar(Boolean.valueOf(false)));
this.ivRadarGhosts = ((ImageView) findViewById(R.id.ivRadarGhosts));
if (this.ivRadarGhosts != null) {
this.ivRadarGhosts.setImageBitmap(drawRadarGhosts(Boolean.valueOf(false)));
}
this.countdownShowGhost = new CountDownTimer(15000L, 1000L) {
public void onFinish() {
RadarScreen.this.showGhosts = Boolean.valueOf(false);
RadarScreen.this.hideGhosts = Boolean.valueOf(false);
if (RadarScreen.this.countdownHideGhost != null) {
RadarScreen.this.countdownHideGhost.start();
}
}
public void onTick(long paramLong) {
Random localRandom = new Random();
if (!RadarScreen.this.showGhosts.booleanValue()) {
RadarScreen.this.showGhosts = Boolean.valueOf(true);
RadarScreen.this.showGhostsZufallszahl = (1000 +
localRandom
.nextInt(10000));
if (localRandom.nextInt(50) >= 10) {
AlphaAnimation localAlphaAnimation2 = new
AlphaAnimation(0.0F, 0.975F);
localAlphaAnimation2.setDuration(1000L);
localAlphaAnimation2.setFillAfter(true);
if (RadarScreen.this.ivRadarGhosts != null) {
RadarScreen.this.ivRadarGhosts.startAnimation(localAlphaAnimation2);
RadarScreen.this.ivRadarGhosts.setImageBitmap(
RadarScreen.this.drawRadarGhosts(Boolean.valueOf(true)));
if (RadarScreen.this.settingsGeneralVibrate) {
RadarScreen.this.vib.vibrate(20L);
}
}
}
}
if ((RadarScreen.this.showGhostsZufallszahl > paramLong)
&& (!RadarScreen.this
.hideGhosts.booleanValue())) {
RadarScreen.this.hideGhosts = Boolean.valueOf(true);
AlphaAnimation localAlphaAnimation1 = new
AlphaAnimation(0.975F, 0.0F);
localAlphaAnimation1.setDuration(1000L);
localAlphaAnimation1.setFillAfter(true);
if (RadarScreen.this.ivRadarGhosts == null) {
return;
}
RadarScreen.this.ivRadarGhosts.startAnimation(localAlphaAnimation1);
}
}
};
this.countdownHideGhost = new CountDownTimer(12500L, 2250L) {
public void onFinish() {
RadarScreen.this.showGhosts = Boolean.valueOf(false);
RadarScreen.this.hideGhosts = Boolean.valueOf(false);
if (RadarScreen.this.countdownShowGhost != null) {
RadarScreen.this.countdownShowGhost.start();
}
}
public void onTick(long paramLong) {
}
};
}
public void onStop() {
super.onStop();
Log.i("com.example.ghostsam", "onStop RadarScreen");
BitmapDrawable localBitmapDrawable1 = (BitmapDrawable)
this.ivLogo.getDrawable();
this.ivLogo.setImageBitmap(null);
this.ivLogo.setImageDrawable(null);
this.ivLogo = null;
Bitmap localBitmap1 = localBitmapDrawable1.getBitmap();
if ((localBitmap1 != null) && (!localBitmap1.isRecycled()))
{
localBitmap1.recycle();
}
BitmapDrawable localBitmapDrawable2 = (BitmapDrawable)
this.ivRadar.getDrawable();
this.ivRadar.setImageBitmap(null);
this.ivRadar.setImageDrawable(null);
this.ivRadar = null;
Bitmap localBitmap2 = localBitmapDrawable2.getBitmap();
if ((localBitmap2 != null) && (!localBitmap2.isRecycled()))
{
localBitmap2.recycle();
}
BitmapDrawable localBitmapDrawable3 = (BitmapDrawable)
this.ivRadarGhosts.getDrawable();
this.ivRadarGhosts.setImageBitmap(null);
this.ivRadarGhosts.setImageDrawable(null);
this.ivRadarGhosts = null;
Bitmap localBitmap3 = localBitmapDrawable3.getBitmap();
if ((localBitmap3 != null) && (!localBitmap3.isRecycled()))
{
localBitmap3.recycle();
}
BitmapDrawable localBitmapDrawable4 = (BitmapDrawable)
this.ivSignalButton
.getDrawable();
this.ivSignalButton.setImageBitmap(null);
this.ivSignalButton.setImageDrawable(null);
this.ivSignalButton = null;
Bitmap localBitmap4 = localBitmapDrawable4.getBitmap();
if ((localBitmap4 != null) && (!localBitmap4.isRecycled()))
{
localBitmap4.recycle();
}
this.countdownHideGhost.cancel();
this.countdownHideGhost = null;
this.countdownShowGhost.cancel();
this.countdownShowGhost = null;
this.radarRun = Boolean.valueOf(false);
this.showGhosts = Boolean.valueOf(false);
this.hideGhosts = Boolean.valueOf(false);
}
public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
switch (paramMotionEvent.getAction()) {
default:
if (paramView != this.ivSignalButton) {
break;
}
case 0:
if (this.radarRun.booleanValue()) {
if (this.radarRun.booleanValue()) {
if (this.ivSignalButton == null) {
break;
}
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#1BA449"));
}
}
case 1:
if (this.ivSignalButton == null) {
break;
}
this.ivSignalButton.setImageBitmap(drawButton("start
radar", "#1BA449"));
}
// while (paramView != this.ivSignalButton);
if (this.radarRun.booleanValue()) {
if (this.ivSignalButton != null) {
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#005F21"));
}
if ((paramMotionEvent.getX() <= 0.0F) ||
(paramMotionEvent.getX() >= paramView
.getWidth()) ||
(paramMotionEvent.getY() <= 0.0F) ||
(paramMotionEvent.getY() >= paramView
.getHeight())) {
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#005F21"));
}
if (this.ivSignalButton != null) {
this.ivSignalButton.setImageBitmap(drawButton("start
radar", "#005F21"));
}
RotateAnimation localRotateAnimation = new
RotateAnimation(0.0F, 360.0F, 1, 0.5F, 1,
0.5F);
localRotateAnimation.setInterpolator(new LinearInterpolator());
localRotateAnimation.setFillAfter(true);
localRotateAnimation.setRepeatMode(1);
if (!this.radarRun.booleanValue()) {
if (this.ivSignalButton != null) {
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#005F21"));
}
}
this.radarRun = Boolean.valueOf(true);
this.radarRun = Boolean.valueOf(false);
if (this.ivRadar != null) {
this.ivRadar.setImageBitmap(drawRadar(Boolean.valueOf(false)));
}
localRotateAnimation.setDuration(10L);
localRotateAnimation.setRepeatCount(0);
if (this.ivRadarGhosts != null) {
this.ivRadarGhosts.setImageBitmap(drawRadarGhosts(Boolean.valueOf(false)));
}
if (this.countdownHideGhost != null) {
this.countdownHideGhost.cancel();
}
if (this.countdownHideGhost != null) {
this.countdownShowGhost.cancel();
}
}
if (this.ivSignalButton == null) {
this.ivSignalButton.setImageBitmap(drawButton("start radar",
"#005F21"));
}
if (this.ivRadar != null) {
this.ivRadar.setImageBitmap(drawRadar(Boolean.valueOf(true)));
}
localRotateAnimation.setDuration(3000L);
localRotateAnimation.setRepeatCount(-1);
if (this.countdownHideGhost == null) {
this.countdownHideGhost.start();
}
this.ivRadar.startAnimation(localRotateAnimation);
return true;
}
}
class is RadarSceen then method ontouch method is crash is null pointer
exception and this method use start radar and stop radar.then
localRotateAnimation.setDuration(3000L) crash is null pointer exception
public class RadarScreen extends Activity implements View.OnTouchListener {
private static final String APP_TAG = "com.example.ghostsam";
private CountDownTimer countdownHideGhost = null;
private CountDownTimer countdownShowGhost = null;
private DisplayMetrics getDisplay = new DisplayMetrics();
private int getDisplayHeight;
private float getDisplayScale;
private int getDisplayWidth;
private Boolean hideGhosts = Boolean.valueOf(false);
private ImageView ivLogo = null;
private ImageView ivRadar = null;
private ImageView ivRadarGhosts = null;
private ImageView ivSignalButton = null;
private Typeface layoutFontFace;
private Boolean radarRun = Boolean.valueOf(false);
// private RotateAnimation rotateAnimation ;
private RotateAnimation localRotateAnimation;
private boolean settingsGeneralVibrate = true;
private Boolean showGhosts = Boolean.valueOf(false);
private int showGhostsZufallszahl = 0;
private Vibrator vib = null;
public Bitmap drawButton(String paramString1, String paramString2) {
Bitmap localBitmap = Bitmap
.createBitmap(this.getDisplayWidth - (int) (70.0F *
this.getDisplayScale),
(int) (52.0F * this.getDisplayScale),
Bitmap.Config.ARGB_8888);
Canvas localCanvas = new Canvas(localBitmap);
Paint localPaint = new Paint();
localPaint.setTypeface(this.layoutFontFace);
localPaint.setTextAlign(Paint.Align.CENTER);
localPaint.setAntiAlias(true);
localPaint.setColor(Color.parseColor(paramString2));
localCanvas.drawRoundRect(
new RectF(0.0F, 0.0F, localBitmap.getWidth(),
localBitmap.getHeight()), 12.0F,
12.0F, localPaint);
localPaint.setColor(Color.parseColor("#000000"));
localCanvas.drawRoundRect(new RectF(2.0F, 2.0F, -2 +
localBitmap.getWidth(),
-2 + localBitmap.getHeight()), 12.0F, 12.0F, localPaint);
localPaint.setColor(Color.parseColor(paramString2));
localPaint.setAlpha(200);
localPaint.setTextSize(32.0F * this.getDisplayScale);
localPaint.setTextScaleX(1.75F);
localPaint.setFakeBoldText(true);
localCanvas.drawText(paramString1, localBitmap.getWidth() / 2,
36.0F * this.getDisplayScale, localPaint);
return localBitmap;
}
public Bitmap drawRadar(Boolean paramBoolean) {
Bitmap localBitmap = Bitmap
.createBitmap(-50 + this.getDisplayWidth, -50 +
this.getDisplayWidth,
Bitmap.Config.ARGB_8888);
Canvas localCanvas = new Canvas(localBitmap);
Paint localPaint = new Paint();
int i = (int) ((localBitmap.getWidth() - 10.0F *
this.getDisplayScale) / 2.0F
+ 5.0F * this.getDisplayScale);
int j = (int) (i - 5.0F * this.getDisplayScale);
localPaint.setAntiAlias(true);
localPaint.setColor(Color.parseColor("#FFFFFF"));
localPaint.setStyle(Paint.Style.STROKE);
localPaint.setStrokeWidth(3.0F * this.getDisplayScale);
localPaint.setAlpha(75);
for (int k = 0; ; k++) {
if (k > 4) {
localPaint.setAlpha(100);
localPaint.setStyle(Paint.Style.FILL);
localPaint.setShader(new SweepGradient(i, i, 0, -16711936));
if (paramBoolean.booleanValue()) {
RectF localRectF = new RectF();
localRectF.set(i - j, i - j, i + j, i + j);
localCanvas.drawArc(localRectF, 0.0F, 360.0F, true,
localPaint);
}
localPaint.setShader(null);
localPaint.setAlpha(255);
localPaint.setColor(Color.parseColor("#810003"));
localPaint.setStyle(Paint.Style.FILL);
localPaint.setStrokeWidth(0.0F);
localCanvas.drawCircle(i, i, 10.0F * this.getDisplayScale,
localPaint);
return localBitmap;
}
localCanvas.drawCircle(i, i, j - k * 40 *
this.getDisplayScale, localPaint);
}
}
public Bitmap drawRadarGhosts(Boolean paramBoolean) {
Bitmap localBitmap = Bitmap
.createBitmap(-50 + this.getDisplayWidth, -50 +
this.getDisplayWidth,
Bitmap.Config.ARGB_8888);
Canvas localCanvas = new Canvas(localBitmap);
Paint localPaint = new Paint();
if (paramBoolean.booleanValue()) {
int i = (int) ((localBitmap.getWidth() - 10.0F *
this.getDisplayScale) / 2.0F
+ 5.0F * this.getDisplayScale);
int j = (int) (i - 5.0F * this.getDisplayScale);
localPaint.setAntiAlias(true);
localPaint.setAlpha(255);
Random localRandom = new Random();
localPaint.setAlpha(150);
int k = localRandom.nextInt(180);
int m = localRandom.nextInt(j);
int n = i + (int) (Math.cos(3.141592653589793D * k / 180.0D) *
m);
int i1 = i + (int) (Math.sin(3.141592653589793D * k / 180.0D)
* m);
localPaint.setColor(-16711936);
localPaint.setShader(
new RadialGradient(n, i1, 22.0F *
this.getDisplayScale, -16711936, 0,
TileMode.CLAMP));
localCanvas.drawCircle(n, i1, 15.0F * this.getDisplayScale,
localPaint);
if (localRandom.nextInt(50) < 5) {
int i6 = localRandom.nextInt(180);
int i7 = localRandom.nextInt(j);
int i8 = i + (int) (Math.cos(3.141592653589793D * i6 /
180.0D) * i7);
int i9 = i + (int) (Math.sin(3.141592653589793D * i6 /
180.0D) * i7);
localPaint.setShader(
new RadialGradient(i8, i9, 22.0F *
this.getDisplayScale, -16711936, 0,
TileMode.CLAMP));
localCanvas.drawCircle(i8, i9, 15.0F *
this.getDisplayScale, localPaint);
}
if (localRandom.nextInt(75) < 5) {
int i2 = localRandom.nextInt(180);
int i3 = localRandom.nextInt(j);
int i4 = i + (int) (Math.cos(3.141592653589793D * i2 /
180.0D) * i3);
int i5 = i + (int) (Math.sin(3.141592653589793D * i2 /
180.0D) * i3);
localPaint.setShader(
new RadialGradient(i4, i5, 22.0F *
this.getDisplayScale, -16711936, 0,
TileMode.CLAMP));
localCanvas.drawCircle(i4, i5, 15.0F *
this.getDisplayScale, localPaint);
}
}
return localBitmap;
}
public void onCreate(Bundle paramBundle) {
Log.i("com.example.ghostsam", "onStart RadarScreen");
requestWindowFeature(1);
getWindow().setFlags(1024, 1024);
super.onCreate(paramBundle);
setContentView(R.layout.radarscreen);
SharedPreferences localSharedPreferences =
getSharedPreferences("app_prefs", 0);
int i = localSharedPreferences.getInt("appStartCounter", 0);
int j = localSharedPreferences.getInt("appStartFirst", 0);
int k = i + 1;
SharedPreferences.Editor localEditor = localSharedPreferences.edit();
localEditor.putInt("appStartCounter", k);
if (j <= 0) {
localEditor.putInt("appStartFirst", (int)
(System.currentTimeMillis() / 1000L));
}
localEditor.commit();
if ((k == 5) || (k == 10) || (k == 25)) {
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setIcon(17301543);
Resources localResources1 = getResources();
Object[] arrayOfObject1 = new Object[1];
arrayOfObject1[0] = "name";
localBuilder.setTitle(localResources1.getString(R.string.app_name,
arrayOfObject1));
Resources localResources2 = getResources();
Object[] arrayOfObject2 = new Object[1];
arrayOfObject2[0] = "name";
localBuilder.setMessage(localResources2
.getString(R.string.dialog_ratemarket_question,
arrayOfObject2));
Resources localResources3 = getResources();
Object[] arrayOfObject3 = new Object[1];
arrayOfObject3[0] = "name";
localBuilder.setPositiveButton(
localResources3.getString(R.string.dialog_button_yes,
arrayOfObject3),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface
paramDialogInterface,
int paramInt) {
Resources localResources =
RadarScreen.this.getResources();
Object[] arrayOfObject = new Object[1];
arrayOfObject[0] = "name";
Intent localIntent = new
Intent("android.intent.action.VIEW",
Uri.parse(localResources.getString(R.string.app_marketlink,
arrayOfObject)));
RadarScreen.this.startActivity(localIntent);
paramDialogInterface.dismiss();
}
});
Resources localResources4 = getResources();
Object[] arrayOfObject4 = new Object[1];
arrayOfObject4[0] = "name";
localBuilder.setNegativeButton(
localResources4.getString(R.string.dialog_button_no,
arrayOfObject4),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface
paramDialogInterface,
int paramInt) {
paramDialogInterface.dismiss();
}
});
localBuilder.create().show();
}
}
public boolean onCreateOptionsMenu(Menu paramMenu) {
getMenuInflater().inflate(R.menu.radarscreen, paramMenu);
return true;
}
public void onError(Exception paramException) {
}
public void onIllegalHttpStatusCode(int paramInt, String paramString) {
}
public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent) {
if (paramInt == 4) {
quitApp();
}
for (int i = 1; ; i = 0) {
return true;
}
}
@SuppressLint("NewApi")
public boolean onOptionsItemSelected(MenuItem paramMenuItem) {
switch (paramMenuItem.getItemId()) {
default:
break;
case R.id.radarscreen_menu_moreapps:
Resources localResources2 = getResources();
Object[] arrayOfObject2 = new Object[1];
arrayOfObject2[0] = "name";
startActivity(new Intent("android.intent.action.VIEW",
Uri.parse(localResources2
.getString(R.string.app_marketdeveloperlink,
arrayOfObject2))));
break;
case R.id.radarscreen_menu_rateapp:
Resources localResources1 = getResources();
Object[] arrayOfObject1 = new Object[1];
arrayOfObject1[0] = "name";
startActivity(new Intent("android.intent.action.VIEW",
Uri.parse(
localResources1.getString(R.string.app_marketlink,
arrayOfObject1))));
break;
case R.id.radarscreen_menu_about:
startActivity(new Intent(this, About.class));
break;
case R.id.radarscreen_menu_settings:
startActivity(new Intent(this, Settings.class));
break;
case R.id.radarscreen_menu_quit:
quitApp();
}
return true;
}
public void onResume() {
super.onResume();
Log.i("com.example.ghostsam", "onResume RadarScreen");
getWindowManager().getDefaultDisplay().getMetrics(this.getDisplay);
this.getDisplayWidth = this.getDisplay.widthPixels;
this.getDisplayHeight = this.getDisplay.heightPixels;
this.getDisplayScale = (this.getDisplayWidth / 480.0F);
this.layoutFontFace = Typeface.createFromAsset(getAssets(),
"Roboto-Regular.ttf");
this.settingsGeneralVibrate = PreferenceManager
.getDefaultSharedPreferences(getBaseContext())
.getBoolean("settings_general_vibrate", true);
this.vib = ((Vibrator) getSystemService("vibrator"));
this.ivLogo = ((ImageView) findViewById(R.id.ivLogo));
this.ivLogo.setImageBitmap(Bitmap.createScaledBitmap(
BitmapFactory.decodeResource(getResources(),
R.drawable.logo),
(int) (460.0F * this.getDisplayScale), (int) (68.0F *
this.getDisplayScale),
true));
this.ivSignalButton = ((ImageView)
findViewById(R.id.ivSignalButton));
this.ivSignalButton.setImageBitmap(drawButton("start radar",
"#005F21"));
this.ivSignalButton.setOnTouchListener(this);
this.ivRadar = ((ImageView) findViewById(R.id.ivRadar));
this.ivRadar.setImageBitmap(drawRadar(Boolean.valueOf(false)));
this.ivRadarGhosts = ((ImageView) findViewById(R.id.ivRadarGhosts));
if (this.ivRadarGhosts != null) {
this.ivRadarGhosts.setImageBitmap(drawRadarGhosts(Boolean.valueOf(false)));
}
this.countdownShowGhost = new CountDownTimer(15000L, 1000L) {
public void onFinish() {
RadarScreen.this.showGhosts = Boolean.valueOf(false);
RadarScreen.this.hideGhosts = Boolean.valueOf(false);
if (RadarScreen.this.countdownHideGhost != null) {
RadarScreen.this.countdownHideGhost.start();
}
}
public void onTick(long paramLong) {
Random localRandom = new Random();
if (!RadarScreen.this.showGhosts.booleanValue()) {
RadarScreen.this.showGhosts = Boolean.valueOf(true);
RadarScreen.this.showGhostsZufallszahl = (1000 +
localRandom
.nextInt(10000));
if (localRandom.nextInt(50) >= 10) {
AlphaAnimation localAlphaAnimation2 = new
AlphaAnimation(0.0F, 0.975F);
localAlphaAnimation2.setDuration(1000L);
localAlphaAnimation2.setFillAfter(true);
if (RadarScreen.this.ivRadarGhosts != null) {
RadarScreen.this.ivRadarGhosts.startAnimation(localAlphaAnimation2);
RadarScreen.this.ivRadarGhosts.setImageBitmap(
RadarScreen.this.drawRadarGhosts(Boolean.valueOf(true)));
if (RadarScreen.this.settingsGeneralVibrate) {
RadarScreen.this.vib.vibrate(20L);
}
}
}
}
if ((RadarScreen.this.showGhostsZufallszahl > paramLong)
&& (!RadarScreen.this
.hideGhosts.booleanValue())) {
RadarScreen.this.hideGhosts = Boolean.valueOf(true);
AlphaAnimation localAlphaAnimation1 = new
AlphaAnimation(0.975F, 0.0F);
localAlphaAnimation1.setDuration(1000L);
localAlphaAnimation1.setFillAfter(true);
if (RadarScreen.this.ivRadarGhosts == null) {
return;
}
RadarScreen.this.ivRadarGhosts.startAnimation(localAlphaAnimation1);
}
}
};
this.countdownHideGhost = new CountDownTimer(12500L, 2250L) {
public void onFinish() {
RadarScreen.this.showGhosts = Boolean.valueOf(false);
RadarScreen.this.hideGhosts = Boolean.valueOf(false);
if (RadarScreen.this.countdownShowGhost != null) {
RadarScreen.this.countdownShowGhost.start();
}
}
public void onTick(long paramLong) {
}
};
}
public void onStop() {
super.onStop();
Log.i("com.example.ghostsam", "onStop RadarScreen");
BitmapDrawable localBitmapDrawable1 = (BitmapDrawable)
this.ivLogo.getDrawable();
this.ivLogo.setImageBitmap(null);
this.ivLogo.setImageDrawable(null);
this.ivLogo = null;
Bitmap localBitmap1 = localBitmapDrawable1.getBitmap();
if ((localBitmap1 != null) && (!localBitmap1.isRecycled()))
{
localBitmap1.recycle();
}
BitmapDrawable localBitmapDrawable2 = (BitmapDrawable)
this.ivRadar.getDrawable();
this.ivRadar.setImageBitmap(null);
this.ivRadar.setImageDrawable(null);
this.ivRadar = null;
Bitmap localBitmap2 = localBitmapDrawable2.getBitmap();
if ((localBitmap2 != null) && (!localBitmap2.isRecycled()))
{
localBitmap2.recycle();
}
BitmapDrawable localBitmapDrawable3 = (BitmapDrawable)
this.ivRadarGhosts.getDrawable();
this.ivRadarGhosts.setImageBitmap(null);
this.ivRadarGhosts.setImageDrawable(null);
this.ivRadarGhosts = null;
Bitmap localBitmap3 = localBitmapDrawable3.getBitmap();
if ((localBitmap3 != null) && (!localBitmap3.isRecycled()))
{
localBitmap3.recycle();
}
BitmapDrawable localBitmapDrawable4 = (BitmapDrawable)
this.ivSignalButton
.getDrawable();
this.ivSignalButton.setImageBitmap(null);
this.ivSignalButton.setImageDrawable(null);
this.ivSignalButton = null;
Bitmap localBitmap4 = localBitmapDrawable4.getBitmap();
if ((localBitmap4 != null) && (!localBitmap4.isRecycled()))
{
localBitmap4.recycle();
}
this.countdownHideGhost.cancel();
this.countdownHideGhost = null;
this.countdownShowGhost.cancel();
this.countdownShowGhost = null;
this.radarRun = Boolean.valueOf(false);
this.showGhosts = Boolean.valueOf(false);
this.hideGhosts = Boolean.valueOf(false);
}
public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
switch (paramMotionEvent.getAction()) {
default:
if (paramView != this.ivSignalButton) {
break;
}
case 0:
if (this.radarRun.booleanValue()) {
if (this.radarRun.booleanValue()) {
if (this.ivSignalButton == null) {
break;
}
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#1BA449"));
}
}
case 1:
if (this.ivSignalButton == null) {
break;
}
this.ivSignalButton.setImageBitmap(drawButton("start
radar", "#1BA449"));
}
// while (paramView != this.ivSignalButton);
if (this.radarRun.booleanValue()) {
if (this.ivSignalButton != null) {
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#005F21"));
}
if ((paramMotionEvent.getX() <= 0.0F) ||
(paramMotionEvent.getX() >= paramView
.getWidth()) ||
(paramMotionEvent.getY() <= 0.0F) ||
(paramMotionEvent.getY() >= paramView
.getHeight())) {
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#005F21"));
}
if (this.ivSignalButton != null) {
this.ivSignalButton.setImageBitmap(drawButton("start
radar", "#005F21"));
}
RotateAnimation localRotateAnimation = new
RotateAnimation(0.0F, 360.0F, 1, 0.5F, 1,
0.5F);
localRotateAnimation.setInterpolator(new LinearInterpolator());
localRotateAnimation.setFillAfter(true);
localRotateAnimation.setRepeatMode(1);
if (!this.radarRun.booleanValue()) {
if (this.ivSignalButton != null) {
this.ivSignalButton.setImageBitmap(drawButton("stop
radar", "#005F21"));
}
}
this.radarRun = Boolean.valueOf(true);
this.radarRun = Boolean.valueOf(false);
if (this.ivRadar != null) {
this.ivRadar.setImageBitmap(drawRadar(Boolean.valueOf(false)));
}
localRotateAnimation.setDuration(10L);
localRotateAnimation.setRepeatCount(0);
if (this.ivRadarGhosts != null) {
this.ivRadarGhosts.setImageBitmap(drawRadarGhosts(Boolean.valueOf(false)));
}
if (this.countdownHideGhost != null) {
this.countdownHideGhost.cancel();
}
if (this.countdownHideGhost != null) {
this.countdownShowGhost.cancel();
}
}
if (this.ivSignalButton == null) {
this.ivSignalButton.setImageBitmap(drawButton("start radar",
"#005F21"));
}
if (this.ivRadar != null) {
this.ivRadar.setImageBitmap(drawRadar(Boolean.valueOf(true)));
}
localRotateAnimation.setDuration(3000L);
localRotateAnimation.setRepeatCount(-1);
if (this.countdownHideGhost == null) {
this.countdownHideGhost.start();
}
this.ivRadar.startAnimation(localRotateAnimation);
return true;
}
}
Subscribe to:
Comments (Atom)