Category Archives: Notes

General Notes, normally things I discover as I work.

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 Selectors in Infinite-Scroll

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
//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:

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.)

PHP Compilation (Cannot find -lltdl)

When compiling PHP from source (in my case version 5.3.2) on CentOS 5.4 I kept getting the following error when trying to compile with mcrypt:

"/usr/bin/ld: cannot find -lltdl"

This seems to be due to a missing development library with the obscure name of libtool-ltdl-devel to fix this simply use:

yum install libtool-ltdl-devel

Which should include the package along with several dependencies.