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
<html>
<head>
<title>Detect Custom Protocol</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
</head>
<body>
<input id="protocol" value="" placeholder="custom protocol"/>
<button id="launch">Launch</button>
<!-- Mozilla Only -->
<iframe id="hiddenIframe" src="about:blank" style="display:none"></iframe>
<html>
<head>
<title>Wordnik demo from JavaScript</title>
<script src="http://static.smallpicture.com/bootstrap/js/jquery-1.9.1.min.js"></script>
<script>
var baseUrl = "http://api.wordnik.com/v4/word.json/";
var apiKey = "a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5"; //demo key from developer.wordnik.com
function getSynonyms (theWord, callback) {
var url = baseUrl + theWord + "/relatedWords?useCanonical=true&relationshipTypes=synonym&limitPerRelationshipType=100&api_key=" + apiKey;
var jxhr = $.ajax ({
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/...

Getting Started with YUI

Welcome to the YUI library! This tutorial contains everything you need to get up and running quickly with YUI. If you've never used YUI before, but you perhaps have a little experience with plain JavaScript or JavaScript frameworks, read onward.

Note that if you have experience with jQuery, it is a great idea to read or at least skim through the JS Rosetta Stone, which demonstrates how common jQuery and YUI idioms map to each other. The good news is that in the areas where YUI and jQuery overlap, you'll find that it is not too difficult to translate back and forth between the two.

Loading SimpleYUI

The easiest way to get started with YUI is to use SimpleYUI, a convenient package for working with DOM nodes, events, UI effects, and AJAX.

#!/bin/bash
##
# start|stop|restart python SimpleHTTPServer
#
# TODO:
# use shell Function for DRY
# USAGE:
# ./manage_simplehttpserver.sh start|stop|restart
#
#!/usr/bin/env node
var mcli = require('mojito-cli'),
args = ['start', '--context', 'environment:development'],
cwd = process.cwd();
mcli(args, cwd, function(err, msg) {
console.log(err || msg)
});
@triptych
triptych / .zshrc
Created March 19, 2013 23:42 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
// YUI.Env is not populated until you build a YUI base object once. You can cache a reference to it here, if you'd like,
// but you probably don't want to require anything. You certainly don't want to require anything from the Gallery.
YUI()
YUI.Env[YUI.version].groups.gallery.base = "http://path.to.my.server/lib/yui-gallery/build";
YUI.Env[YUI.version].groups.gallery.comboBase = "http://path.to.my.server/combo?
YUI.Env[YUI.version].groups.gallery.root = "lib/yui-gallery/build";
// This is how you *should* do this, ignore everything above:
YUI({groups: { gallery: { base: "http://path.to.my.server/lib/yui-gallery/build", comboBase: "http://path.to.my.server/combo?", root: "lib/yui-gallery/build" } } });
YUI.add(NAME, function(Y){
Y.MyWidget = Y.Base.create(NAME, Y.Widget, [], {
initializer: function() {
// set up anything initially that's not handled with the config
},
destructor: function() {
// tear down any thing that needs it