Introduction
The purpose of a collection is to store objects in an organized manner with specific access rules. We are going to build a collection class using the Standard PHP Library (SPL). Our final product will be capable of iterating, counting and access to objects via array. If you are not familiar with SPL you can [...]
Archives for Programming
Building an Object Collection Manager with the Standard PHP Library (SPL)
Forcing files to download from Amazon S3
I have been messing around with Amazon S3 for hosting files the last few days. One of the things I wanted to do was force a file to download instead of the browser attempting to open it (jpgs, txt, mp3, etc.). A quick Google search didn’t return anything useful. There is a whole bunch of [...]
How we cache at CollegeHumor
CollegeHumor, like many websites that want to reduce database requests and speed up processing, uses memcached as a caching layer. This article will explain our software implementation and discuss a number of things we learned along the way. If you read my blog you will know I’m a PHP guy. CollegeHumor is also coded in [...]
To CMS or not to CMS?
In one of my recent posts someone asked in the comments what I thought about Drupal. It felt off topic, so I decided to write a post about Content Management Systems.
I personally don’t have much experience with open source (or enterprise) CMS. I had a short stint with Joomla and eventually ditched it. I have [...]
Facebook Invite Bookmarklet
One of the best Facebook features is the ability to invite friends to events. The most annoying part about this system is the inability to invite more then 100 friends at a time (Facebook: wheres the invite all!?). In the past I have clicked one by one and sent invites in blocks of 100. Today [...]
PHP Recursive Multidimensional Array Flatten Using SPL
function array_flatten_recursive($array) {
if($array) {
$flat = array();
foreach(new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST) as $key=>$value) {
if(!is_array($value)) {
$flat[] = $value;
}
}
return $flat;
} else {
[...]
Recursive PHP in_array function
I needed a recursive in_array function the other day and disliked all the samples I found on php.net. I wrote this one using the StandardPHPLibrary. It will recursively search through a multidimensional array and return true if the $needle is found in the $haystack.
function in_array_recursive($needle, $haystack) {
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($haystack));
foreach($it [...]
Weebly Puzzle
This site attracts a decent amount of JavaScript folks so I thought this would be relevant and maybe even helpful. I read news.ycombinator.com everyday (or several times a day). If you are into the startup world, you should as well. It has by far the best startup news and a great community. The feedback and [...]
Muxtape’s Is Growing Fast!
On Tuesday March 25th, Justin Ouellette one of the developers from Vimeo launched Muxtape as a side project. The idea isn’t totally original, but its executed far better then the competition. Muxtape is a site that lets you make virtual mix tapes. You upload up to 12 songs from your computer and share the custom [...]
BustedTees Relaunch
This morning at 5am Kunal Shah, Nick Dunkman, Jmo and myself launched a new version of the BustedTees website! Visually the site hasn’t changed much. Amir Cohen, one the front end developer for CollegeHumor did an excellent job recoding the front end. We spent the better part of the last 4 months recoding everything from [...]
Posts