Using Zend to retrive wikipedia api content

function getWikipediaContent( \$wikiUrl ) { // initialize HTTP client \$client = new Zend_Http_Client(); // Set it for wikipedia \$client->setUri( \$wikiUrl ); // Set url params for get request \$client->setParameterGet('action','query'); \$client->setParameterGet('prop','revisions'); \$client->setParameterGet('rvprop','content'); \$client->setParameterGet('format','xml'); \$client->setParameterGet('titles', \$urlSlug); // Get the wiki page via a get request …



JS logging

I've been doing a fair about of js development lately and console.log has been my friend. However, writing console.log() is a bit heavy. So instead I've been adding this to my files as a quick way to log in javascipt. function log() { if (window.console && console.log) console …



Remove empty values from an array.

I developed this little one liner to remove empty values from an array in php. \$tags = array( 'testtag', 'testtag2', ' ' ); \$tagsCleaned = array_filter( array_map( 'trim', \$tags ), create_function( '\$a', 'return \$a!="";' ) ); Breaking that down inside out. array_map( 'trim', \$tags ) Array map the trim function to all of the values within the array, removing …



Using the + sign to merge arrays in php

Today came across code that used the + sign to merge two associative php arrays. At first I thought it was broken but turns out you can indeed merge two arrays with the + sign. \$album = array( 'title' => 'King of Limbs', 'band' => 'Radiohead', ); \$album_meta_data = array( 'upc' => '486898161589', 'price' = '11.98' ); \$output = \$album …



VMWare Fusion 4 - Set static IP address

In vmware Fusion 4 there is no boot.shthat is found in previous versions sudo "/Library/Application Support/VMware Fusion/boot.sh" --restart So if you make a change to the network settings like setting a static ip address you'll need to restart your computer for the settings to …



Recursively remove svn directories from a directory

Removing all .svn directories from a file structure in linux is as simple as running a one liner. find . -name .svn -print0 | xargs -0 rm -rf



How to add git to an amazon ami ec2 instance

To install git on amazon ami is really simple. Make sure you have sudo and then run yum to install it. sudo yum install git That's it. The output should be something like: \$ sudo yum install git Loaded plugins: fastestmirror, priorities, security Determining fastest mirrors amzn-main | 2.1 kB 00 …



Find loaded modules in Apache 2.x

I was trying to figure out how to find the loaded modules in Apache and came across this nice command. httpd -M Used like: \$ httpd -M Loaded Modules: core_module (static) mpm_prefork_module (static) http_module (static) so_module (static) authn_file_module (shared) authn_default_module (shared) ...... rewrite_module (shared) php5_module (shared) extract_forwarded_module (shared) geoip_module (shared) Syntax OK …



Display phpinfo from the command line

This afternoon I was wanting to get a couple things from phpinfo but didn't want to do the typical make a php file, put phpinfo, run it from a browser or command prompt. There's a better, quicker way if you know what you want. One will output it to a …



Scaling PHP Applications with Redis

Redis is an important technology when dealing with caching. This was one of the talks that I really wanted to attend at ZendCon. It was given by Josh Butts of Vertive LLC. Redis is a NoSQL technology that rides a fine line between database and in-memory cache. Redis also offers …