Skip to content

Instantly share code, notes, and snippets.

View lukemorton's full-sized avatar

Luke Morton lukemorton

View GitHub Profile
@lukemorton
lukemorton / controller-publicize.php
Created April 2, 2011 14:32
Creates a file in DOCROOT if found within the CFS.
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Controller for Publicize. Currently only contains a redirect
* action.
*
* @package Publicize
* @category Helpers
* @author Luke Morton
* @copyright Luke Morton, 2011
* @license MIT
@lukemorton
lukemorton / kostache-layout.php
Created April 6, 2011 18:42
Basic HTML5 Mustache layout
<?php defined('SYSPATH') or die('No direct script access.');
class Kostache_Layout extends Kohana_Kostache_Layout {
public $app_id;
public $page_id;
public function charset()
{
@lukemorton
lukemorton / view-account.php
Created April 7, 2011 17:56
View-Model logic separation
<?php
class View_Account extends Kostache {
protected $_user = NULL;
protected $_user_view = NULL;
protected function _user()
{
location / {
try_files $uri /index.php?$query_string;
}
location = /index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
@lukemorton
lukemorton / index.php
Created April 12, 2011 18:21
Create a new Kohana app easily
<?php
/**
* The directory in which your application specific resources are located.
* The application directory must contain the bootstrap.php file.
*
* @see http://kohanaframework.org/guide/about.install#application
*/
$application = '../application';
window.BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
@lukemorton
lukemorton / example.js
Created May 20, 2011 16:59
SpellChecker Library for JS
var spell = new Zamt('spellchecker.php', function (string) {
// Update when checked
$('textarea').val(string);
alert('Spell check completed.');
});
spell.check($('textarea').val(), function (suggestion) {
// Get array of suggested words
@lukemorton
lukemorton / jquery.retina.js
Created May 26, 2011 18:11
An idea by @Johnathan1707
// By using this.each you can now do something like this:
// $('img.apply-2x').retina();
// And by returning this we can also method chain:
// $('img.apply-2x').retina().click(function () { alert('hello'); });
$.fn.retina = function () {
if (window.devicePixelRatio === 2) {
// Run this function on every selected element
this.each(function () {
@lukemorton
lukemorton / afs.js
Created May 26, 2011 23:34
Playing about with some functions for a manifest reading asset compiler (node.js)
var exec = require('child_process').exec;
var fs = require("fs");
var _ = require("./underscore")._;
var tools = require("./afs/tools");
var p = require('path');
var args = process.argv;
var options = {
"manifest" : "manifest.json",
"dist" : "dist",
"path" : ".",
@lukemorton
lukemorton / example.html
Created May 30, 2011 01:15
Process an array asynchronously :D
<!doctype html>
<html>
<head>
<title>An example</title>
<meta charset="utf-8" />
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="orderlyqueue.js"></script>
<script>