Skip to content

Instantly share code, notes, and snippets.

View iammerrick's full-sized avatar

Merrick Christensen iammerrick

View GitHub Profile
<?php
//^.*(?=:) selects name
$subject = 'name:varchar(255)';
preg_match('/(?P<type>\w+)($|\((?P<length>(\d+|(.*)))\))/', $subject, $matches);
print_r($matches);
preg_match('/^(?P<name>[a-z]+):(?P<type>\w+)($|\((?P<length>(\d+|(.*)))\))/', $subject, $matches);
@iammerrick
iammerrick / gist:783524
Created January 17, 2011 21:32
Party Foul?
<?php
/*
Plugin Name: Location
Description: Manage locations of restaurants, and the displaying of them.
Version: 1.0
Author: Riser Media
Author URI: http://www.risermedia.com
License: Commercial
*/
/**
* Ruby
*/
class Person
def initialize(name)
@name = name.capitalize
@loves = [];
end
def love(what)
public function as_csv($columns)
{
foreach($this->as_array() as $item)
{
$csv .= implode(',', Arr::extract($item, $columns))."\n";
}
}
<?php
/**
* CSV Class
*/
class CSV
{
public static function factory($path = NULL)
{
<?php
public function __call($name, $arguments)
{
if($name === 'find_file')
{
return call_user_func_array($name, $arguments);
}
}
<?php
$user = ORM::factory('user');
$user->email = Arr::get($_POST, 'email');
$user->username = Arr::get($_POST, 'email');
$user->password = '123456';
$user->save();
document.cookie.match('(?:^|;)\\s*' + myCookieKey.escapeRegExp() + '=([^;]*)');
@iammerrick
iammerrick / gist:799456
Created January 27, 2011 22:41
Auto Invoke Closure - No moving function around...
<?php
$json = new stdClass();
$json->states = function(){
$array = array();
foreach($db->get_states() as $state)
{
$array[] = $state;
}