Skip to content

Instantly share code, notes, and snippets.

@phawk
phawk / html5
Created March 18, 2011 19:33
shortcut that doesn't rely on .js
// you need js if you want to reference:
header{
color: 'pink';
}
// but without the need for js you can have:
<header id="header">
and do
#header{
color: 'pink';
public function add_facebook( $id, $fb_access_token )
{
$data = array('fb_access_token' => $fb_access_token);
$this->db->where('id', $id);
if( $this->db->update( $this->db_table, $data ) )
{
return TRUE;
}
else
{
<?php
$start = microtime();
$x = 1;
do{
$x++;
$result = null;
$i = 0;
<?php
$start = microtime();
$x = 1;
do{
$x++;
$result = null;
$i = 0;
<script type="text/javascript">
/*
* Basic reusable form validation
*
* @author Pete Hawkins <[email protected]>
* @created 2011-05-11
* @requires jQuery
*
* Setup:
* Add your fields as objects in an array to the validatorConfig.fields object.
# custom prompt
# pman, open man in preview
pman() { man -t "$@" | open -f -a Preview; }
# aliases
alias planzaivps="ssh -p 1892 [email protected]"
# open files in coda
alias coda="open -a Coda"
@phawk
phawk / php-recursive-closure
Created January 4, 2012 09:49
php recursive closure
public function save()
{
//
// Find the root ID of the category to make selecting much easier
//
// Get all categories
$all_categories = $this->all_categories();
$parent_id = $this->get_parent_id();
@phawk
phawk / PHP Recursive Closures.php
Created January 14, 2012 12:01
A quick example of a recursive closure in PHP, passing itself into the scope by reference.
<?php
$closure = function ($params) use (&amp;$closure) {
// ...
$closure($params);
}
// Start the magics
$closure($params);
# domain: phawk.co.uk & peteyhawkins.com
<VirtualHost *:80>
ServerName phawk.co.uk
ServerAlias www.phawk.co.uk www.peteyhawkins.com peteyhawkins.com
ProxyPass / http://localhost:9000/
ProxyPassReverseCookieDomain localhost your.domain
ProxyPreserveHost on
<Location />
ProxyPassReverse /
</Location>
<?php
class MY_Controller extends CI_Controller
{
public $data = array(); // Array to store data - passed to views.
protected $view_path = null; // Here to overide the view path if needed.
protected function __construct()
{