Selectors in Infinite-Scroll

I get asked a lot how/what the selectors are in infinite-scroll and how to figure them out. So lets start from the beginning.. infinite-scroll uses jQuery selectors (which are based on CSS selectors) to find content and posts in order to load the content from the next page. Because web pages are different, we need to define ourselves what selectors infinite-scroll should use.

Infinite-Scroll uses four selectors, these are:

  • nextSelector
  • navSelector
  • contentSelector
  • itemSelector

It’s probably easiest Continue reading

PHP: unset() not freeing memory fully on objects

I spent a while trying to figure this out; but it’s quite simple (though I find rather counter-intuitive). Essentially when you create an object in PHP you are allocating memory for that object. When you want to remove that object you can use the unset() function (just like on most things in PHP). The problem occurs when there are variables stored inside the object — unset() doesn’t delete these from memory. This is because unset() doesn’t trigger the object’s destructor. A simple way around it is to explicitly call the destructor and then unset the object like so:

$myobject = new CrazySystem();
$myobject->LargeVariable = file_get_contents("VeryLargeFile.txt");
//Now we want to delete the object and everything it contains
$myobject->__destruct();
unset($myobject);
//It's now all gone!

Hope that helps anyone who was wondering why unsetting object still wasn’t freeing memory!

Select/Invite all friends on Facebook automatically

Facebook recently updated the way they allow you to invite friends. Purposely or, as a side effect, it means that the popular javascript code that lets you select all friends no longer works. The following code courtesy of John P. allows you to select all friends on the new version. (Yay!)

There is one catch. Because Facebook now only loads a few of your friends at a time, you have to scroll all the way down the invite list until you hit the very bottom (all your friends are displayed). You then just paste the following into the URL bar and hit enter:

View Code JAVASCRIPT
javascript:function check_all_in_document(doc){var c=new Array();c=doc.getElementsByTagName('input');for(var i=0;i<c.length;i++){if(c[i].type=='checkbox'){c[i].click();}}}check_all_in_document(window.document);for(var j=0;j<window.frames.length;j++){check_all_in_document(window.frames[j].document);}

Happy inviting! (If the code doesn’t work then make sure you click “View Code” in the box above.)

Amersham Dec

Amersham Dec is a brilliant example of a simple informational website for a shop that currently has its main presence in a physical location. The elegant and user-intuitive interface enables visitors to easily find out which range of products/brands the store stocks and details of how visitors can contact the shop either by phone, post or using the built-in contact form that uses CAPTCHA to help prevent spam posts. The vast majority of the target audience; decorating trade Continue reading