Skip to content

Instantly share code, notes, and snippets.

View triptych's full-sized avatar
💭
Making web things

Andrew Wooldridge triptych

💭
Making web things
View GitHub Profile
You must download the yui3-files (for every version you want to serve) as well as the Gallery-modules.
Yui3 --> http://yuilibrary.com/yui/quick-start/ or https://github.com/yui/yui3
Gallery --> download zip from https://github.com/yui/yui3-gallery
The Gist presumes the next directory-structure on the server:
/usr/local/yui_libraries/
/usr/local/yui_libraries/yui3/
/usr/local/yui_libraries/yui3/3.10.3/...
@triptych
triptych / promise001.js
Last active August 29, 2015 13:56
Source code for YUI 3.15.0 release blog post
js
function doSomething(aNumber) {
if (typeof aNumber !== 'number') {
return Promise.reject(new TypeError('Expected a number'));
}
return somethingElse().then(...);
}
@triptych
triptych / promise002.js
Last active August 29, 2015 13:56
Source code for YUI 3.15.0 release blog post
var promise1 = Promise.resolve('foo'); // a promise for the value ‘foo’
var promise2 = new Promise(function (resolve) {
resolve(promise1);
});
promise2.then(function (value) {
// value is ‘foo’
});
YUI().require('some-es6-module', function (Y, imports) {
var foo = imports['some-es6-module'].foo;
});
@triptych
triptych / index.html
Created April 17, 2014 22:32
A basic example of using handlebars-helper-intl
<!doctype html>
<html>
<head>
<title>Basic handlebars-helper-intl example</title>
<!-- Optional libraries, if older browser support required for Intl -->
<script src="./app/bower_components/intl/Intl.min.js"></script>
<!-- Required libraries -->
<!-- IntlMessageFormat library with the English language pack -->
@triptych
triptych / index.html
Last active August 29, 2015 14:00
Demo using Intl.js
<html lang="en-US">
<head>
<title>Dynamically including Intl.js</title>
<script>
// check to see if window.Intl exists. If not, include the polyfill
if (!window.Intl) {
var elem = document.createElement("script");
elem.setAttribute("src", "http://yui.yahooapis.com/platform/intl/0.1.2/Intl.js");
document.getElementsByTagName("head")[0].appendChild(elem);
@triptych
triptych / index.html
Created May 14, 2014 21:33
code for ScotchApp-0.0.1.apk
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.4.2/pure-min.css">
<style>
.app {
width: 300px;
margin: 0 auto;
}
@triptych
triptych / snippet1.html
Created May 14, 2014 21:40
code for ScotchApp-0.0.1.apk
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.4.2/pure-min.css">
<script src="http://yui.yahooapis.com/3.16.0/build/yui/yui-min.js"></script>
@triptych
triptych / snippet2.html
Created May 14, 2014 21:41
code for ScotchApp-0.0.1.apk
<script>
YUI().use('app', function (Y) {
// Initial view:
Y.HomeView = Y.Base.create('homeView', Y.View, [], {
render : function () {
var html = '<h1>Scotch Regions</h1>';
html += '<p><button class="pure-button">Cambletown</button>';
// more html content
this.get('container').setHTML(html);
@triptych
triptych / index.html
Last active August 29, 2015 14:02
Demo client side rendering of handlebars-helper-intl
<html>
<head>
<!-- bower install handlebars handlbars-helper-intl, npm install intl-messageformat -->
<script src="./bower_components/handlebars/handlebars.js"></script>
<script src="./node_modules/intl-messageformat/build/intl-messageformat.en.min.js"></script>
<script src="./node_modules/intl-messageformat/locale-data/fr.js"></script>
<script src="./bower_components/handlebars-helper-intl/lib/helpers.js"></script>
<script id="template1" type="text/x-handlebars-template">
{{#intl locales="en-US" }}