Skip to content

Instantly share code, notes, and snippets.

@kara-ryli
kara-ryli / yui-async-multi-grunt.js
Created April 14, 2013 19:58
Boilerplate for a grunt multi task that leverages YUI's Promises module to sanely handle asynchronous tasks that atomically process multiple files.
/*jshint node:true*/
module.exports = function(grunt) {
var Y = require("yui/promise"),
name = "...",
desc = "...",
defaultOptions = { /* */ };
function executeAsyncTask(resolve, reject, file, options) {
// this is where your business logic goes
// call `resolve` when the task is finished
@kara-ryli
kara-ryli / ios-linkfix.js
Last active December 14, 2015 07:58
Prevents iOS from showing the URL bar when the user clicks on a cancelled link
/*global YUI*/
/**
* Prevents iOS from showing the URL bar for cancelled links
*
* @module ios-linkfix
* @requires base-build, event-touch, node-base, node-event-delegate, plugin
*/
YUI.add("ios-linkfix", function (Y, NAME) {
var HREF = "href",
DATA = "data-" + NAME,
@kara-ryli
kara-ryli / viewport.html
Last active December 12, 2015 00:29
Supporting a mobile layout combined with a fixed-width desktop/tablet layout can be a bit challenging. This is what I've come up with to solve the problem.
<!--
This is the mobile viewport setting. iOS 5 has a bug that
does some goofy scaling when you rotate it unless you set
the max scale to 1. We could do a one-off for this,
but it doesn't seem worth it.
-->
<meta id="meta-viewport" name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,maximum-scale=1">
<script>
@kara-ryli
kara-ryli / innocent.html
Created January 28, 2013 22:16
Never put code before an ampersand when using SCSS nesting. Therein lies madness.
<div class="wrap">
<div class="bar">
<div class="foo">Text!</div>
</div>
</div>
@kara-ryli
kara-ryli / handlebars_compile.sh
Created January 24, 2013 19:41
Pipe Handlebars output directly to YUI Compressor, then save the results to a file of the same name.
#!/bin/bash
handlebars $1 | java -jar ~/bin/yuicompressor.jar --type js -o ${1/.handlebars/.js}
@kara-ryli
kara-ryli / data.json
Created January 16, 2013 18:54
A simple handlebars helper that enables testing of value equality. String, number and boolean values are supported.
{
"tests": [
{ "agree": "yes" },
{ "agree": "no" }
]
}
@kara-ryli
kara-ryli / _placeholder.scss
Created January 8, 2013 23:36
Mixin for browser-namespaced placeholder styling.
@mixin placeholder {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
&::-webkit-input-placeholder {
@content;
}
&::-moz-placeholder {
@content;
}
@kara-ryli
kara-ryli / get-requirements.js
Created January 3, 2013 02:40
Returns the list of modules required to load a YUI module. Doesn't manage triggers and conditionals.
/*global YUI*/
YUI.add("get-depenedencies", function (Y) {
/**
* Provides a method to recursively lookup YUI module dependencies
*
* @module get-depenedencies
*/
/**
Retrieves the entire module dependency list for the given module.
@kara-ryli
kara-ryli / complex-loader.js
Created December 20, 2012 01:31
Potential enhancement to YUI's loader API allowing module-level skin selection and avoiding naming collisions.
YUI({
groups: {
group1: { modules: ["mymodule": {}], base: "http://group1..." },
group2: { modules: ["mymodule": {}], base: "http://group2..." },
}
}).use(
// maintain current usage
"node",
// allow specifying skins at the module level
{ name: "slider", skin: "round-dark" /* or ["sam", "round-dark"] */ },
@kara-ryli
kara-ryli / yogi-import.js
Created December 12, 2012 01:09
A simple nodejs script that imports an existing YUI module-based project into a Yogi <http://yui.github.com/yogi/>-based tree. It's not perfect--it doesn't remove the existing boilerplate, but it's a start.
/*global require,console,process*/
var fs = require("fs.extra"),
exec = require('child_process').exec,
path = process.argv[2];
fs.readdirSync(path).forEach(function (name) {
var loc = path + "/" + name;
// Is it a directory?
if ((/^[^\.]/).test(name)) {