Skip to content

Instantly share code, notes, and snippets.

@kara-ryli
kara-ryli / loader-config.html
Created April 5, 2012 02:45
FIXME: Configure loader to work correctly with multiple CDNs and a third-party hosted YUI
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loader Test</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Ryan Cannon">
<script src="http://www.nfl.com/yui/3.4.1/build/yui/yui-min.js"></script>
<script>
var YUI_config = {
@kara-ryli
kara-ryli / date-ago.js
Created March 30, 2011 20:33
YUI module for calculating the time ago in words in English. Updated from the Prototype version and optimized for compressor.
YUI.add('date-ago', function (Y) {
function round(value) {
return Math.round(value);
}
function distanceOfTimeInWords(from_time, to_time, include_s) {
var include_seconds, distance_in_minutes, distance_in_seconds;
include_seconds = include_s || false;
distance_in_minutes = round(Math.abs(to_time - from_time) / 60000);
@kara-ryli
kara-ryli / yui3-serialize-form.js
Created February 18, 2011 02:26
Serialize a form into a query string with YUI3
YUI().use('node', 'array-extras', 'querystring-stringify', function (Y) {
var form = Y.one('FORM_SELECTOR'), query;
query = Y.QueryString.stringify(Y.Array.reduce(Y.one(form).all('input[name],select[name],textarea[name]')._nodes, {}, function (init, el, index, array) {
init[el.name] = el.value;
return init;
}));
console.log(query);
});