Saturday, 31 August 2013

Adding Javascript functionality to wordpress page section

Adding Javascript functionality to wordpress page section

I made a fiddle to display what I want to do.
http://jsfiddle.net/5bCN6/
var div = $('#move');
var upper = $('#up');
var downer = $('#down');
upper.click(function() {
div.animate( { top: '-100'}, 500);
});
downer.click(function() {
div.animate( { top: '0'}, 500);
});
I want to add the code above to a wordpress page.
I added the 3 divs to a page in wordpress in the text editor in the edit
page section of wordpress so the 3 divs show up on the page when I look at
the site. The problem I am having is that I cannot figure out how to get
the javascript to work. I added it to its own file called java.js and
added it to the bottom of footer.php using this.
<script type="text/javascript" src="<?php bloginfo('template_url');
?>/js/java.js"></script>
again, this did not work.
I somehow feel that by including it like that, the javascript is looking
for those divs in footer.php but it cant find it there because it resides
in a page in the back end (probably in page.php. Any ideas?

Java: String to Date

Java: String to Date

I have spent lot of time to convert my string to date. I have string in
Fri Jan 04 12:32:28 CST 2013
format. And my code is below
myDate=(Date) new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz
yyyy").parse(str);
Please help me how to get rid of this. This code throws exception
java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date

how to deal with unexpected width and height

how to deal with unexpected width and height

I am currently using the following code to re size all images bigger than
800 x600 to the required size.
if (($width>800) and ($height>600))
{
WideImage::load($img_path.$name)->resize(800,
600)->saveToFile($img_path.$name);
}
However this won't work if for example an image has a width of 1024 and
height 559
I can use an or but I am not sure how to deal with resizing those Images .

Friday, 30 August 2013

Depth vs Postion

Depth vs Postion

I've been reading about reconstructing a fragment's position in world
space from a depth buffer, but I was thinking about storing position in a
high-precision three channel position buffer. Would doing this be faster
than unpacking the position from a depth buffer? What is the cost of
reconstructing position from depth?

Thursday, 29 August 2013

Form contact mail php in bold

Form contact mail php in bold

I use this really simple and great mail contact form:
http://www.saaraan.com/2011/12/making-simple-jquery-ajax-contact-form It
work fine !
But I would like that the message content, writed by the visitor, be bold
in my email box.
This is possible ?
My php code :
<?php
if($_POST)
{
//check if its an ajax request, exit if not
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
die();
}
$to_Email = "myemail@gmail.com"; //Replace with recipient email address
$subject = 'Ah!! My email from Somebody out there...'; //Subject
line for emails
//check $_POST vars are set, exit if any missing
if(!isset($_POST["userName"]) || !isset($_POST["userEmail"]) ||
!isset($_POST["userPhone"]) || !isset($_POST["userMessage"]))
{
die();
}
//Sanitize input data using PHP filter_var().
$user_Name = filter_var($_POST["userName"], FILTER_SANITIZE_STRING);
$user_Email = filter_var($_POST["userEmail"], FILTER_SANITIZE_EMAIL);
$user_Phone = filter_var($_POST["userPhone"], FILTER_SANITIZE_STRING);
$user_Message = filter_var($_POST["userMessage"],
FILTER_SANITIZE_STRING);
//additional php validation
if(strlen($user_Name)<4) // If length is less than 4 it will throw an HTTP
error.
{
header('HTTP/1.1 500 Name is too short or empty!');
exit();
}
if(!filter_var($user_Email, FILTER_VALIDATE_EMAIL)) //email validation
{
header('HTTP/1.1 500 Please enter a valid email!');
exit();
}
if(!is_numeric($user_Phone)) //check entered data is numbers
{
header('HTTP/1.1 500 Only numbers allowed in phone field');
exit();
}
if(strlen($user_Message)<5) //check emtpy message
{
header('HTTP/1.1 500 Too short message! Please enter something.');
exit();
}
//proceed with PHP email.
$headers = 'From: '.$user_Email.'' . "rn" .
'Reply-To: '.$user_Email.'' . "rn" .
'X-Mailer: PHP/' . phpversion();
@$sentMail = mail($to_Email, $subject, $user_Message .' -'.$user_Name,
$headers);
if(!$sentMail)
{
header('HTTP/1.1 500 Couldnot send mail! Sorry..');
exit();
}else{
echo 'Hi '.$user_Name .', Thank you for your email! ';
echo 'Your email has already arrived in my Inbox, all I need to do is
Check it.';
}
}?>

Are firebase callbacks in iOS app fired on UI Thread by design?

Are firebase callbacks in iOS app fired on UI Thread by design?

I am using firebase iOS sdk to develop a chat app. Just wondering whether
the child added callback is fired on the UI thread or a background thread.

Wednesday, 28 August 2013

Conditional logistic regression in SPSS (using multinomial logistic regression) and R (using clogistic() of Epi)

Conditional logistic regression in SPSS (using multinomial logistic
regression) and R (using clogistic() of Epi)

I want to use NOMREG of SPSS (by GUI from "Regression --> Multinomial
Logistic Regression") for my matched data. However, I don't know where to
insert the strata variable (the matching variable) into the GUI or syntax.
On a side note, I have a question on conditional logistic regression in R
that have posted it to the programming branch of the StackExchange because
the last time I sent a code-related question here, mods fried me (although
I see other people send their R code here). Anyways, the address for my R
question is this (LINK).