NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
| /* The API controller | |
| Exports 3 methods: | |
| * post - Creates a new thread | |
| * list - Returns a list of threads | |
| * show - Displays a thread and its posts | |
| */ | |
| var Thread = require('../models/thread.js'); | |
| var Post = require('../models/post.js'); |
NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
| # Note that while this file is in our config folder, it is | |
| # symlinked to our site folders, so paths are relative from there | |
| # Require gems and Compass plugins | |
| # require 'rgbapng' | |
| # require 'compass-fancybox-plugin' | |
| require 'compass-growl' | |
| # General | |
| output_style = :expanded |
| // Turns out this function already exists in Sass: mix(fg, bg, %) (http://d.pr/mGqa) | |
| // Alpha blending | |
| @function blend($bg, $fg) { | |
| $r: red($fg) * alpha($fg) + red($bg) * (1 - alpha($fg)); | |
| $g: green($fg) * alpha($fg) + green($bg) * (1 - alpha($fg)); | |
| $b: blue($fg) * alpha($fg) + blue($bg) * (1 - alpha($fg)); |
| /*! | |
| An experiment in getting accurate visible viewport dimensions across devices | |
| (c) 2012 Scott Jehl. | |
| MIT/GPLv2 Licence | |
| */ | |
| function viewportSize(){ | |
| var test = document.createElement( "div" ); | |
| test.style.cssText = "position: fixed;top: 0;left: 0;bottom: 0;right: 0;"; |
| var parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.hostname; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" | |
| parser.host; // => "example.com:3000" |
| if (!document.querySelectorAll) { | |
| document.querySelectorAll = function(selector) { | |
| var doc = document, | |
| head = doc.documentElement.firstChild, | |
| styleTag = doc.createElement('STYLE'); | |
| head.appendChild(styleTag); | |
| doc.__qsaels = []; | |
| styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}"; | |
| window.scrollBy(0, 0); |
I’ve been having a play around with Mutation Observers this morning, trying to work out when notifications happen and what happens when removing a node that was just added.
If you’re unfamiliar with Mutation Observers, they let you receive notifications when an element, or elements, have been modified in a particular way (here's an intro to Mutation Observers from Mozilla).
Consider this:
| <?php | |
| /* | |
| Usage: | |
| cache_fragment_output( 'unique-key', 3600, function () { | |
| functions_that_do_stuff_live(); | |
| these_should_echo(); | |
| }); | |
| */ | |
| function cache_fragment_output( $key, $ttl, $function ) { |