All posts in Technology

Apache2 Setup

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

sudo apt-get install mysql-server mysql-client # u/p root/root

sudo apt-get install vim # ;-)

sudo apt-get install php-pear
sudo apt-get install php5-dev
sudo apt-get install php5-curl
sudo pecl i pecl_http

cd /etc/php5/apache2
add extension to php.ini
sudo apachectl restart

sudo apt-get install phpunit

# Add Virtual Host

Code Camp Notes

# Software Craftsmanship

## Things to look at:

* Utah Software Craftsmanship Group
* Code Katas
* Apprenticeship Patterns Book

Different language communities can be considered as Dojos, you can expert in one and cross pollinate so to speak.

# HTML5

## Things to look at:

* Modernizer
* Protocol Registers
* Stream API
* getUserMedia (Webcams, Audio, Etc)

# Distributed Systems

## Fallacies of Distributed Systems

* The network is reliable
* Latency is zero
* Bandwidth is infinite
* The network is homogeneous

## Things to look at:

* Udi Dahan
* [http://goo.gl/kyDAE](Cap Theorem)
* Eventual Consistency is sexy.
* /h/a/r/r/y/p/o/t/cache.json
* CQRS, Event Sourcing
* Messaging is hot.

# RIAS and Node.JS

## Things to look at:

* Yahoo Design Patterns
* Pattern Tap
* Patternry
* UIPatterns

Sustainability In Computer Science

This video and talk is top notch.

Content Warning: There is a bit of vulgarity in his more honest parts.

View Partials In Kohana 3

To create view partials within a Kohana view just use this bit of code..

<?php include(Kohana::find_file('views', 'path/to/partial')); ?>

Kohana 3 Routes and Request Class

Kohana 3 Routes and Requests

Kohana sports a powerful and lean Request class. The most useful I’ve seen of any PHP framework, it essentially takes a regular expression and routes it to the appropriate controller, directory, action, or other value using keys, this allows for some robust URLs and applications. Lets take a look at how to mimic Basecamp style URL’s in Kohana minus the sub domain. If there is interest I’ll add that in a later article, just let me know in the comments, yeah?

Basecamp Project Style Route

Route::set('projects', 'projects/
(/(/(/)))', array(
    'project_id' => '\d+'
  ))->defaults(array(
    'controller' => 'log',
    'action' => 'index',
));

This route will take a URL like projects/1/, and load up the Controller_Log.php file and fire the action_index. In fact anything after projects/1/ will be fired like the default route. So this allows you to use, projects/1/todos/add and fire the action_add in the Controller_Todos.php file. Even better if you want to scope your todos to the project referenced in the URL, you can set the project in the controllers before() method:

public function before()
	{
		parent::before();

		$property = ORM::factory('project')
						->where('id','=', $this->request->param('property_id'))
						->where('user_id', '=', $this->user->id)
						->find();

		if($property->loaded())
		{
			$this->property = $property;
			$this->template->property = $property;
		}
		else
		{
                        // Couldn't find the project
			$this->request->redirect('/');
		}

	}

Notice I grabbing the parameter from the URL using the param() method in the Request class using the specified key in the route.


$this->request->param('project_id');

You could grab any parameter this way:


$this->request->param('id');

Using this method in your actions allows you to never pass parameters to your functions again, thus you can change the order of your routes and the site will function the exact same way.

Kohana Framework

Real-time Syncing Your iPhone With Google

One of my good friends, Will Robertson showed me a trick buried deep inside of Google’s documentation. You can use real time syncing across all your Google products using Exchange.

I add a calendar event on my phone, instantly it is added to my iPad, iPhone, and both computers (work and home). I get this real-time effect for Calendars, Email, and Contacts.

Skip IMAP, use exchange.

http://www.google.com/support/mobile/bin/answer.py?answer=138740&topic=14252

Assets – A PHP 5 Asset Combining Class

Assets takes multiple JavaScript or CSS files and combines them into one.

So mootools.js, drag.js, slider.js, and tips.js can become script.php?load=mootools,drag,slider,tips.

Rather then four script tags, you have one. I recently published this Open Source PHP class to combine different text files into one in real time. The benefit here is JavaScript management and page loading speed. Making a bunch of HTTP requests to external JavaScript will slow down the page load, if you don’t believe me just open your website and profile it using the WebKit Inspector.

Documentation

There are two ways to really use Assets.

Automatic

Assets::factory()->get()->render();

This method implies that you are calling the page with a parameter of “load” in the URL. The file names need to be separated by commas. Example: script.php?load=mootools,drag,slider,tips

Manual

Assets:factory()->add('file.js')->add('file2.js')->render();

This methods adds each file individually passed in using PHP. It is worth noting that you can also pass and array of file names into the add() method.

Notes

If you prefer to use the new Assets that is completely OK. You don’t have to use the factory() method. Also, I am open to feedback; in fact that’s half the reason I release my code for free is for people to tear it up and tell me what to improve.

Download

Assets is on GitHub