Cleanup/Delete Installed Application in XCode iPhone Simulator
To cleanup the previously installed application in XCode iPhone Simulator need a manual deletion, the applications is installed in directory:
/Users/*username*/Library/Application Support/iPhone Simulator/*simulator version*/Applications
There are GUID(s) named directories depend on your usage, you could check with `ls` command to ensure what application those directory holds and safely delete the directory manually.
Recursive directory iteration with PHP Filesystem API
I have a small stuff to do this morning related to php filesystem api, warming memcached for static files and php template to reduce I/O process overhead in front-end application
$dir = '/path/to/some/dir';
$flags = FilesystemIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS;
$iterator = new RecursiveDirectoryIterator($dir, $flags);
$result = array();
foreach ($iterator as $file) {
$result[] = $file->getFilename();
}
print_r($result);
The result will be list of files and directories exist in `$dir`, somehow i need a recursive iterator, luckily php has it all, with small pimp I can have it, just before line where `$result` declaration, I add this line
$iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
bingo! now it running recursively, i need some filtering here since i only need files with `.txt` or `.html` files, currently it returned all files and directories exists in `$dir` so i created a new iterator filtering class as below
class FilterTxtHtml extends FilterIterator {
public function accept() {
$fileinfo = $this->getInnerIterator()->current();
if (preg_match('/\.(txt|html)$/', $fileinfo)) {
return true;
}
return false;
}
}
save it somewhere, include it and put this line before `$result` declaration,
$iterator = new FilterTxtHtml($iterator);
final code as below:
$dir = '/path/to/some/dir';
$flags = FilesystemIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS;
$iterator = new RecursiveDirectoryIterator($dir, $flags);
$iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
$iterator = new FilterTxtHtml($iterator);
$result = array();
foreach ($iterator as $file) {
$result[] = $file->getFilename();
}
print_r($result);
Easy enough.
Twitter API + jQuery JSONP
Here i will show you how easily fetch non authenticated Twitter API methods using ajax json callback functions with jQuery framework, I use user_timeline method as an example but you can use this sampel to fire other twitter api method as long as its needless authorization.
The TwitterAPI Class
TwitterAPI = {
Statuses: {
user_timeline:function(screen_name, count, callback){
jQuery.getJSON("http://twitter.com/statuses/user_timeline/" + screen_name + ".json?count="+count+"&b="+Math.random()+"&callback=?",
callback);
}
}
};
PHP Error Exception Handling
Got a question from a friend today who is actually a great desktop programmer and just learn PHP since he believe that the future is in the web (hope you’re right dude). He asked me about how to handling error in PHP. Well i’ll write my answer here so can share with others and got feedback when I was wrong.
In PHP there are few options that you can use to handle errors & exceptions during script executions and as developer you must considering not the easiet but the most flexible approach which will help you when debugging your appllication, the more detail error message provided the faster you can fix it. Flexible means its easy for you to change the application behaviour when unexpected things happened during execution like: display error, logging error or even automatically notice you via email.
Why SEO lost importance
Cameron Chapman wrote an interesting post at instantShift today, he explain well about the position of SEO in web development & internet marketing world lately which is getting less & less important.
Social media is a big part of the blame for this situation. People can now ask their friends or complete strangers for recommendations on virtually anything, and get human-filtered results within minutes through Facebook, Twitter, or other social networking sites. Internet users are also becoming more savvy and can cut through search results to find the best content, regardless of optimal placement for the best keywords.
Even in cases where search engines still send significant traffic to a site, search engines are becoming so much more intelligent that it’s getting harder and harder to get good placement unless you’re providing the best content.
According to Chapman’s article, the 7 main reasons why SEO is getting less important are:




