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.

composer dump-autoload

Make sure you have setup composer to be accessed globally. Otherwise you’ll need to do this command.

/usr/local/bin/composer.phar composer dump-autoload

Further you may want to optimize your autoload. According to Taylor this can speed up your application by 30%.

composer dump-autoload --optimize

Edit: Another option noted by luviyo is to do the following.

Open app/starts/global.php and add:

ClassLoader::addDirectories(array( app_path().'/libraries', ));

Thanks for the tip!

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

chmod +x rename.sh

Then ran it in the directory I needed to rename files in.

./rename.sh

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’),
(‘Antigua and Barbuda’),
(‘Argentina’),
(‘Armenia’),
(‘Australia’),
(‘Austria’),
(‘Azerbaijan’),
(‘Bahamas, The’),
(‘Bahrain’),
(‘Bangladesh’),
(‘Barbados’),
(‘Belarus’),
(‘Belgium’),
(‘Belize’),
(‘Benin’),
(‘Bhutan’),
(‘Bolivia’),
(‘Bosnia and Herzegovina’),
(‘Botswana’),
(‘Brazil’),
(‘Brunei’),
(‘Bulgaria’),
(‘Burkina Faso’),
(‘Burma’),
(‘Burundi’),
(‘Cambodia’),
(‘Cameroon’),
(‘Canada’),
(‘Cape Verde’),
(‘Central Africa’),
(‘Chad’),
(‘Chile’),
(‘China’),
(‘Colombia’),
(‘Comoros’),
(‘Congo, Democratic Republic of the’),
(‘Costa Rica’),
(‘Cote dIvoire’),
(‘Crete’),
(‘Croatia’),
(‘Cuba’),
(‘Cyprus’),
(‘Czech Republic’),
(‘Denmark’),
(‘Djibouti’),
(‘Dominican Republic’),
(‘East Timor’),
(‘Ecuador’),
(‘Egypt’),
(‘El Salvador’),
(‘Equatorial Guinea’),
(‘Eritrea’),
(‘Estonia’),
(‘Ethiopia’),
(‘Fiji’),
(‘Finland’),
(‘France’),
(‘Gabon’),
(‘Gambia, The’),
(‘Georgia’),
(‘Germany’),
(‘Ghana’),
(‘Greece’),
(‘Grenada’),
(‘Guadeloupe’),
(‘Guatemala’),
(‘Guinea’),
(‘Guinea-Bissau’),
(‘Guyana’),
(‘Haiti’),
(‘Holy See’),
(‘Honduras’),
(‘Hong Kong’),
(‘Hungary’),
(‘Iceland’),
(‘India’),
(‘Indonesia’),
(‘Iran’),
(‘Iraq’),
(‘Ireland’),
(‘Israel’),
(‘Italy’),
(‘Ivory Coast’),
(‘Jamaica’),
(‘Japan’),
(‘Jordan’),
(‘Kazakhstan’),
(‘Kenya’),
(‘Kiribati’),
(‘Korea, North’),
(‘Korea, South’),
(‘Kosovo’),
(‘Kuwait’),
(‘Kyrgyzstan’),
(‘Laos’),
(‘Latvia’),
(‘Lebanon’),
(‘Lesotho’),
(‘Liberia’),
(‘Libya’),
(‘Liechtenstein’),
(‘Lithuania’),
(‘Macau’),
(‘Macedonia’),
(‘Madagascar’),
(‘Malawi’),
(‘Malaysia’),
(‘Maldives’),
(‘Mali’),
(‘Malta’),
(‘Marshall Islands’),
(‘Mauritania’),
(‘Mauritius’),
(‘Mexico’),
(‘Micronesia’),
(‘Moldova’),
(‘Monaco’),
(‘Mongolia’),
(‘Montenegro’),
(‘Morocco’),
(‘Mozambique’),
(‘Namibia’),
(‘Nauru’),
(‘Nepal’),
(‘Netherlands’),
(‘New Zealand’),
(‘Nicaragua’),
(‘Niger’),
(‘Nigeria’),
(‘North Korea’),
(‘Norway’),
(‘Oman’),
(‘Pakistan’),
(‘Palau’),
(‘Panama’),
(‘Papua New Guinea’),
(‘Paraguay’),
(‘Peru’),
(‘Philippines’),
(‘Poland’),
(‘Portugal’),
(‘Qatar’),
(‘Romania’),
(‘Russia’),
(‘Rwanda’),
(‘Saint Lucia’),
(‘Saint Vincent and the Grenadines’),
(‘Samoa’),
(‘San Marino’),
(‘Sao Tome and Principe’),
(‘Saudi Arabia’),
(‘Scotland’),
(‘Senegal’),
(‘Serbia’),
(‘Seychelles’),
(‘Sierra Leone’),
(‘Singapore’),
(‘Slovakia’),
(‘Slovenia’),
(‘Solomon Islands’),
(‘Somalia’),
(‘South Africa’),
(‘South Korea’),
(‘Spain’),
(‘Sri Lanka’),
(‘Sudan’),
(‘Suriname’),
(‘Swaziland’),
(‘Sweden’),
(‘Switzerland’),
(‘Syria’),
(‘Taiwan’),
(‘Tajikistan’),
(‘Tanzania’),
(‘Thailand’),
(‘Tibet’),
(‘Timor-Leste’),
(‘Togo’),
(‘Tonga’),
(‘Trinidad and Tobago’),
(‘Tunisia’),
(‘Turkey’),
(‘Turkmenistan’),
(‘Tuvalu’),
(‘Uganda’),
(‘Ukraine’),
(‘United Arab Emirates’),
(‘United Kingdom’),
(‘United States’),
(‘Uruguay’),
(‘Uzbekistan’),
(‘Vanuatu’),
(‘Venezuela’),
(‘Vietnam’),
(‘Yemen’),
(‘Zambia’),
(‘Zimbabwe’);

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 could use that version instead (it looks nicer anyway).

Finally, I’ve found this solution on a forum, by installing Compiz Config Settings Manager:

  1. Go then to Applications>System Tools>Preferences>Compiz Config Manager
  2. Scroll down to the bottom of the window and where it says Windows Management, click on either Application Switcher (dynamic) or Static Application Switcher, depending on which you prefer.

If you need to install Compiz Config Manager:

  1. Click Alt+Ctrl+T, to open the Terminal
  2. Type this: sudo apt-get install compizconfig-settings-manager,
  3. Or search for compizconfig-settings-manager in the Software Center and install from there.