Ebuyer’s Roof-Top Rush Game

Ebuyer’s website has an addictive little game this Christmas involving jumping a little Santa across roof tops. Get 1000m to enter a prize draw.

http://www.ebuyer.com/christmas

Horribly amazing PHP – check if you’re on the last iteration of a foreach loop

The code is so horrible, it’s gone a full circle and become amazing once again. It’s a method of finding if you’re on the last iteration of a foreach loop. As with anything that uses array pointers in PHP, be careful how you use it as the results may not be as expected:

  1. $arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  2.  
  3. foreach ($arr as $a) {
  4.  
  5. // This is the line that does the checking
  6. if (!each($arr)) echo "End!\n";
  7.  
  8. echo $a."\n";
  9.  
  10. }

PHP – Converting bytes to a readable format

The following function takes in a number of bytes and the number of decimal places required in the output and returns the result in a readable format:

  1. function readable_filesize($bytes, $dp = 1) {
  2. // Extensions used
  3. $extensions = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
  4.  
  5. foreach ($extensions as $ext) {
  6. // If we can't divide again without getting < 1
  7. if ($bytes < 1024) {
  8. return number_format($bytes, $dp).$ext;
  9. }
  10.  
  11. $bytes /= 1024;
  12. }
  13.  
  14. // If we're here, we're at the end of the extensions array
  15. // thus return what we have
  16. return $bytes.$ext;
  17. }

Use like this:

  1. echo readable_filesize(123456);

 

Solved! phpMyAdmin cannot start session without errors

Solved! phpMyAdmin cannot start session without errors

This was a bit of a ridiculous error. It occurred after a PHP upgrade to 5.2.17 running under Apache with mod_php. Initially phpMyAdmin just rejected the login which clearing the browser’s cookies fixed. Following this, the error “cannot start session without errors” was produced. Sessions in PHP were working fine as other sites were setting them successfully. session.save_path in php.ini was set to /var/lib/php/session. This directory had write access from the Apache user. The problem was fixed by changing the permissions to 0777 on this directory.

  1. chmod 0777 /var/lib/php/session

I haven’t bothered to investigate the real reason behind the problem but the aforementioned permissions fix seems to have solved it. Do let me know if you figure this out.

How to win eBay auctions

How to win eBay auctions

eBayWikipedia: eBay Inc. (/ˈiːˌbeɪ/ EE-bay) is a multinational e-commerce corporation, facilitating online consumer-to-consumer and business-to-consumer sales. It is headquartered in San Jose, California. eBay w... is all about psychology… a little like gambling. The most a person is willing to pay is rarely actually the most they’re willing to pay. When one sees an eBay auction at a couple of pounds above the most you’re willing to pay, it’s very easy to rethink your bid.

As such, to get the best chance of winning an eBay action, bid at the very last moment. This gives those with a poor grasp on self control little chance to reconsider the amount they’re willing to pay. In order to do this, you need to decide how much you’re willing to pay. Oh… a catch 22 I hear you say. No. Stop being a fanny and make a decision. This will be based on:

  • How much you want what’s on offer
  • How much you can get it for elsewhere
  • How much money you have burning a hole in your pocket

Once you’ve made this decision, you have 2 options. The first is to wait until the very last moment of an auction and place your bid. I’ve lost many an auction because I forgot about it or my computer was a little too slow to get the bid in on time. The other option is to use an auction snipingWikipedia: Auction sniping is the practice, in a timed online auction, of placing a bid likely to exceed the current highest bid (which may be hidden) as late as possible—usually seconds before the end of the ... tool. I’ve used auctionsniper for a few years now. You just need to enter in the item number and your maximum bid. AuctionSniper will then bid for you in the closing seconds to give you the best chance of winning.

If you’re going to sign up, use the link above or the image link below as this gives me a few free snipes. You’ll also get some free snipes when you sign up to let you try the service.

 

P.S. This isn’t shameless affiliate driven promotion like a possibly mutual acquaintance does with crummy services such as GoDaddy. AuctionSniper is genuinely a decent service which I urge you to check out.