- It is more important to have a standard than what the standard is.
- ‘use strict’ in JavaScript.
- jslint
- jQuery
- Throw objects not strings as exceptions in JavaScript:
throw { 'name': 'MyException', 'message': 'Something went wrong', 'code': 500, 'previous': e // Nested exception. } - Controllers should be super-skinny (because they are hard to test).
- HTML5
- Only read querystring and post body in the controller.
- Say *why* you did something in the commit message, don’t just describe what you did.
- The first line of a commit message should be a short standalone message.
- Err on the side of verbosity in commit messages.
- Don’t form HTML in JavaScript strings.
- Good internationalization is hard (ICU?).
- Run the tests before pushing.
- Automate deployment.
- Keep markup as semantic as possible.
- Code review is a priority.
- LESS
- SMACSS
- Responsive Design
- Backbone
- Automatically pull dependencies in, don’t add them to the repo.
- Don’t store artifacts generated by the build process alongside the source code.
- git
- Unit tests
- The unit tests should run *fast* and offline.
- Send the right HTTP response code.
- JSON
Backup All Databases MySQL
export DATE=`date --rfc-3339=date` && mysqldump -u root -p --all-databases >~/bak/db-$DATE.sql
FuelPHP Updates
In working with FuelPHP recently a few thing have come up. The devs on #fuelphp on Freenode have been awesome at coming up with or accepting fixes. Here are the problems with immediate workarounds and long term solutions.
Fuel won’t let you refer to a View_Model with a templating engine extension
While View::forge('hello/world.twig') works fine, ViewModel::forge('hello/world.twig') fails to find the ViewModel because of the “.twig” part.
Workaround is to instead explicitly set the view on your ViewModel with public $_view = 'world.twig';
Long term fix is coming in Fuel 1.2.1 maintenance release https://github.com/fuel/core/commit/c06b0c67c027ee17bafa59cb089bd6c5baee80ab
Fuel insists that controllers are in the global namespace and prefixed with “Controller_”
No workaround.
Long term fix coming in Fuel 1.3 that will allow you to namespace and prefix controllers as you desire (as you already can with views) via a config setting: https://github.com/fuel/core/commit/882e564de66dc3f4edf83181b8fa36a8a8b083cd
Fuel’s View_Smarty does not expose the “plugins_dir” option.
Workaround is to set the option anyway, direct on the Parser object in your controller(s). The trouble is that accessing this object (and working out if it is Smarty-related) can be complicated. The naive version is something like:
$this->view->parser()->addPluginsDir(APPPATH.DS.'pluginsdirectoryname');
But if you want to continue to support non-Smarty rendering engines and are using ViewModels and Controller_Template it ends up looking more like (don’t judge me!):
if (is_object($this->canvas)) {
$rc = new \ReflectionClass($this->canvas);
if ($rc->hasMethod('parser')) {
$parser = $this->canvas->parser();
} else if ($rc->hasProperty('_view')) {
$parser = $this->canvas->_view->parser();
} else {
throw new YokoException('Unable to initialize Smarty i18n plugin.');
}
$smartyParam = 'plugins_dir';
$ourPluginsDir = APPPATH . '/smarty';
$pluginsDir = array_merge($parser->$smartyParam, [$ourPluginsDir]);
$parser->$smartyParam = $pluginsDir;
}
The long term fix is coming in the 1.3 release of Fuel’s parser package https://github.com/fuel/parser/pull/48. The devs were very good about accepting this patch which bodes well for future contributions to the project.
Spain’s Finalists
Spain 1 - 0 Germany 2008 Spain 1 - 0aet Netherlands 2010 Spain 4 - 0 Italy 2012
Casillas (F F F) Sergio Ramos (F F F) Xavi (F F F) Iniesta (F F* t87) Alonso (f63 t87 F) Farbregas (t63 f87 t75) Torres (t78* f105 f75*) Capdevila (F F _) Puyol (F F _) Busquets (_ F F) Silva (t56 S t59*) Fabregas (_ f87 t75) Pedrito (_ t60 f59) Arbeloa (S S F) Marchena (F S _) Senna (F _ _) Pique (_ _ F) Alba (_ _ F*) Jesus Navas (_ f60 S) Santi Cazorla (f66 _ S) Mata (_ S f87*) Villa (S t105 _) Guiza (f78 _ _) Reina (S S S) Albiol (S S S) Llorente (_ S S) Javi Martinez (_ S S) Juanfran (_ _ S) Negredo (_ _ S) Palop (S _ _) Fernando Navarro (S _ _) Sergio Garcia (S _ _) Juanito (S _ _) De la Red (S _ _) Valdes (_ S _)
F = full match played, t = subbed off, f = subbed on, S = unused substitute, _ = not present, * = goal.
