Wednesday, 11 September 2013

javascript countdown drift

javascript countdown drift

I have been coding a penny auction site and running into a problem with
the countdowns. The starting time seems to be a little different on
different machines (usually a discrepancy of about a second, but sometimes
2 or 3), which obviously is a big issue for bidders. I'm thinking a big
part of the answer is simply network lag, but (a) are there other factors
involved? and (b) is there a way to correct for network lag somehow?
I've tried hitting the server via an Ajax call every second, and that
works well enough (though there's always a bit of lag) but I'd rather not
have to do that because it'll be hard on the server.
JavaScript development is not my forte, so I'd appreciate any tips and
feedback!
Here's my code, as generated on the server
jQuery(document).ready(function() {
var aid = " . $aid . ";
var loadTime = Math.floor(jQuery.now()/1000);
//alert(loadTime);
serverTime = " . time() . ";
var clockDiff = loadTime - serverTime;
var diff;
auctionExpirationValue" . $aid . " = " . $expiry . ";
var newServerTime = setInterval(function() {
diff = window['auctionExpirationValue' + aid] -
Math.floor((jQuery.now())/1000) + clockDiff;
diff_string = parse_countdown(diff);
jQuery('#auction-expiry').html(diff_string);
},1000);
});
the clockDiff variable is to account for any clock differences between the
user's machine and the server. Obviously, if one machine is ahead or
behind the user would see different values in the countdown.
As you can see, the code loops every second (or, more or less every
second, I understand it's not exact), calculates the difference between
now and the auction expiry (compensating with clockDiff), formats it and
displays it. Pretty simple. The auctionExpirationValue*** global variable
is used to store the auction expiry time locally as a timestamp.
My client has also informed me that on his iPad, the countdown would
sometimes drift a little, in addition to the original discrepancy. What's
the explanation there?

Textarea Cutoff in PHP $_POST array

Textarea Cutoff in PHP $_POST array

My textarea on a webform [using POST method] is getting cutting off at
1024 characters.
The field does not have a max length attribute set and will allow over
1024 characters to be entered. However, when I view the $_POST array in
Eclipse and try to insert into Database, I can see it is not the entirety
of the user's input.
What is the root cause of this issue? Is there an inherent limitation that
I am unaware of? I can't seem to find any documentation on this issue. Any
advice is greatly appreciated.

How to get xml tag names in groovy

How to get xml tag names in groovy

can any one help me how to get tag names in my script.In below code i need
to get mbrSqncNum?help me out...
<Id>059A670</healthCardId>
<subscriberId>059A625</subscriberId>
<mbrSqncNum>10</mbrSqncNum>

Best practice - 'forgotten username' process

Best practice - 'forgotten username' process

I've currently been asked to implement a 'forgotten username'
functionality on a site I've inherited, and I'm curious what the best
practice is for the process. I'm already following best practice for
resetting the user's password (by sending an expiring, one use reset link)
- but there doesn't seem to be any best practice policy for a forgotten
username.
The options I've seen on other sites are:
1 Input email address and send it - this is the most straightforward, but
I'm uncomfortable about sending the username to the email address.
2 Input email address and send a single use, expiring link which displays
the username - but after it's expired or been used, it obviously won't
work anymore.
3 Similar to 3, but merge it with the change password process - if the
user forgets their username, they get to see their username, but they have
to reset their password too.
The user table doesn't have any other info set up within it (security
question, date of birth, etc) - so I can't ask for any of this information
without adding it retrospectively. But I'd appreciate any advice or views
others have on how they have either implemented it, or how they think it
should be implemented :).

Tuesday, 10 September 2013

Add Product to the Cart using Product ID Programmatically

Add Product to the Cart using Product ID Programmatically

I got this problem i cant solve it
I have an Array of name proidArray in this i have some products IDs
<?php for($i=0;$i<sizeof($proidArray);$i++){
echo $proidArray[$i];
} ?>
Its displaying all Product IDs in the array But actually my goal you can
see here
<?php for($i=0;$i<sizeof($proidArray);$i++) { ?>
<button type=-"button" class="button btn-cart" id="<?php echo
$proidArray[$i]; ?>" onclick="productAddToCartForm.submit(<?php echo
$proidArray[$i]; ?>)">
<span>Add To Cart</span>
</button>
<?php } ?>
Its displaying in Frontend like this

If i click first Add To Cart button means first product should add to the
cart ..
If i click second button means second product should be add to cart
Any thing wrong i did here ?
Any ideas ?

Issue viewing cells in excel vba

Issue viewing cells in excel vba

I have an excel sheet with macros in it. I face two issues here. 1. On
opening of the sheet I am selecting the cell A11. However, onve I move to
other cells the columns A, B and C disappear. In fact, if I do not select
A11 on opening of the sheet, the colums from A to C are not visible and
the sheet is moved to the left. Please suggest how to avoid this. 2.
Another problem that I have is when I go to sheet2 from sheet1 using the
following code Worksheets("sheet2").Select
sheet hangs for a second and the title text appears twice but as you
scroll down, everything is back to normal.

how to disable spring security authentication on just a few methods

how to disable spring security authentication on just a few methods

I have spring basic authentication implemented, but there are a few urls
which I don't want to be authenticated. For example,
http://www.mywebsite.com/rest/signUp
How to I make this unauthenticated?
@Transactional
@RequestMapping(value = "/signUp", headers =
"Accept=application/json", produces =
MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
public @ResponseBody String signUp(@RequestParam("user_name") String
login,
@RequestParam("pass_word") String passWord,
@RequestParam("first_name") String firstName,
@RequestParam("last_name") String lastName,
@RequestParam("network_name") String networkName,
@RequestParam("email") String email) {
if(!userDAO.loginExists(login)) {
User user = new User();
user.setLogin(login);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setNetworkName(networkName);
user.setEmail(email);
user.setPassword(passWord);
sessionFactory.getCurrentSession().save(user);
return json("success");
}
return json("failure");
}