Skip to content

Instantly share code, notes, and snippets.

View lukemorton's full-sized avatar

Luke Morton lukemorton

View GitHub Profile
routeToRegex = (route) ->
'/' + route.replace('/', '\/') + '/g'
dispatch = (@route, @response) ->
@pattern = routeToRegex route
dispatch '/api/:something', ->
'Hello world'
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Controller default view loading for Kostache!
*
* To get your controllers guessing what views to load simply
* place this file into your "classes" directory in your application.
*/
class Controller extends Kohana_Controller {
@lukemorton
lukemorton / controllerSLASHcrud.php
Created December 24, 2010 11:44
Based on the Rails'esque CRUD
<?php defined('SYSPATH') or die('No direct script access.');
/**
* CRUDDDDD
*/
class Controller_Crud extends Controller {
/**
* Show a list of items
*
<!doctype html>
<html>
<head>
<title>Prioritise</title>
<style>
.selected{font-weight:bold;}
</style>
</head>
<body>
<h1>Prioritise</h1>
@lukemorton
lukemorton / kohana-orm.php
Created December 29, 2010 18:11
Information on using ORM
<?php
/**
* Information on getting started with ORM
*
* [!!] You must initialise ORM in your bootstrap
*
* @see http://kohanaframework.org/guide/tutorials.orm
* @see http://kohanaframework.org/guide/security.validation
* @see http://kohanaframework.org/guide/security.database
* @see https://github.com/kohana/orm/blob/3.0.8/classes/kohana/orm.php
/*
Book Owners Table
*/
CREATE TABLE IF NOT EXISTS `book_owners` (
`book_id` int(10) NOT NULL,
`owner_id` int(10) NOT NULL,
KEY `book` (`book_id`),
KEY `owner` (`owner_id`),
CONSTRAINT `book` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `owner` FOREIGN KEY (`owner_id`) REFERENCES `owners` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
(($) ->
class Plugin
constructor: (@element, @settings) ->
console.log @element
@element.bind
'click' : @started
'blur' : @stopped
started: (e) => @settings.start.call @element, e
stopped: (e) => @settings.stop.call @element, e
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="google-site-verification" content="CIkr4axborR-tfqw_KtW0SyDi7wbgrYUJRMZ85oNQIM" />
<meta name="description" content="Mayfield Construction the trusted local builders of Gravesend and Northfleet We take on a lot of contracts, please call 07739469915 and ask for Ed." />
<meta name="author" content="Edward Smith - mayfieldconstruction.co.uk" />
<meta name="robots" content="all, index, follow" />
<div class="calendar">
<div class="month">
<h3>January</h3>
<table>
<tr>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<?php
Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))')
->defaults(
array(
'directory' => 'admin',
'controller' => 'mycontroller'
)
);