Skip to content

Instantly share code, notes, and snippets.

View lukemorton's full-sized avatar

Luke Morton lukemorton

View GitHub Profile

Denormalised

Orders

  • id
  • created
  • updated
  • building name
  • flat number
  • house number
<?php
class Arr extends Kohana_Arr {
/**
* Recursive version of [array_map](http://php.net/array_map), applies the
* same callback to all elements in an array, including sub-arrays.
*
* // Apply "strip_tags" to every element in the array
* $array = Arr::map('strip_tags', $array);
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Example extends Controller {
public function action_index()
{
$this->request->response = new View_Example;
// or $this->response->body(new View_Example); in K3.1
}
<?php
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
'database' => MODPATH.'database', // Database access
'orm' => MODPATH.'orm', // Object Relationship Mapping
'kostache' => MODPATH.'kostache', // Object Relationship Mapping
));
@lukemorton
lukemorton / bootstrap-example.php
Created January 23, 2011 18:00
Your first Kohana 3.1 controller
<?php
// Excerpt from bootstrap.php
Kohana::init(
array(
'base_url' => '/',
'index_file' => '', // Important
)
);
@lukemorton
lukemorton / reset-example.html
Created January 24, 2011 00:53
event looping
<form>
<div id="custom-input">
<!-- slider html or something -->
</div>
<input type="reset" />
</form>
<script>
$(function () {
$('form').reset(function () {
$('#custom-input').trigger('reset');
@lukemorton
lukemorton / jquery.slider.css
Created February 3, 2011 02:14
slider tutorial
.slider-container {
width: 600px;
height: 200px;
overflow: hidden;
position: relative;
}
.slider ul, .slider li {
margin: 0;
padding: 0;
list-style: none;
@lukemorton
lukemorton / sorting.php
Created February 14, 2011 23:07
sorting two dimensions in PHP
<pre><?php
// A nice simple 2 dimensional array
$people = array(
// array($name, $age)
array('Jim', 20),
array('Betty', 50),
array('Bob', 35),
array('Rob', 22),
array('Rachel', 40),
@lukemorton
lukemorton / with-jquery.sub.html
Created February 15, 2011 15:04
jQuery.sub examples
<!doctype html>
<html>
<head>
<title>Testing jQuery.sub()</title>
</head>
<body>
<div class="example">Testing</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script src="with-jquery.sub.js"></script>
<script>
@lukemorton
lukemorton / ecosystem.html
Created February 16, 2011 00:23
JS ecosystems
<!doctype html>
<html>
<head>
<title>Messages</title>
<meta charset="utf-8" />
</head>
<body>
<ul id="messages">
<li id="message-1">
<div class="message">Message</div>