Clear Laravel 4 Autoload

Laravel 4 currently has a very frustrating issue. If you add a model it will not know of it until you clear the autoload. [ps]composer dump-autoload[/ps] Make sure you have setup composer to be accessed globally. Otherwise you'll need to do this command. [ps]/usr/local/bin/composer …



Linux rename a bunch of file's extensions

In order to rename a whole folders file extensions from jpeg to jpg I wrote this script called rename.sh in bash. #!/bin/bash for filename in *.jpeg do echo \$filename; cleaned=`basename \$filename .jpeg`; echo \$cleaned; mv \$filename \$cleaned.jpg; done Then I made is executable from the command …



Query to insert all countries into database

I needed to insert all of the countries in the world into a database. I couldn't find the query to run, so I created my own. Here it is. 'country' is the table name and 'name' is the column name. INSERT INTO country (name) VALUES ('Afghanistan'), ('Albania'), ('Algeria'), ('Andorra'), ('Angola' …



Linux Ubuntu 12.04 alt-tab not working

I’ve recently installed Ubuntu 12.04 Prestige Pangolin (I use Gnome Classic), and immediately noticed that the alt+tab shortcut wasn’t working. I tried fixing it within Applications>Systems Tools>System Settings, but that did not work. I have compiz Config Manager already install so I figured I …



Setting up Composer globally for Laravel 4

An easy way to set up composer globally is to follow the instructions on getcomposer.org site: [ps] \$ curl -s http://getcomposer.org/installer | php \$ sudo mv composer.phar /usr/local/bin/composer [/ps] Now I can use composer by invoking just the composer command. Optional way to do it …



LessPHP

Why would I want to use the php version of a native node.js project? Well, for starters not all projects are deployed on servers that have node.js installed. Second, well, the first one is pretty much the only reason. So with that out of the way, I ran …



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 …