Skip to content

Instantly share code, notes, and snippets.

@ryanjduffy
ryanjduffy / README.md
Last active August 29, 2015 14:01
enyo.attach prototype

Overview

Exercise to allow an enyo kind to "attach" to existing markup for progressive enhancement, web component-style integration, or preference for markup over enyo-style components[] block.

View it in action on JSFiddle

Attaching a kind to a control

Define it and call enyo.attach with a reference to the kind and target node

enyo.kind({name: });

@ryanjduffy
ryanjduffy / post.md
Created February 27, 2014 18:14
Using Gravatar with Parse

Gravatar is an service that allows users to specify a public avatar image linked to an email address. I recently decided to allow users to use their Gravatar avatar with my Parse-backed app rather than build in my own avatar system. To simplify things, I’ve hooked beforeSave for the User object to hash the email address and add it to the object. That ensures that any email address change is automatically hashed on the server and allows me to send the hash down to clients rather than the email address to protect privacy.

function MD5(s){ /* one of many publicly available MD5 functions */ }

Parse.Cloud.beforeSave(Parse.User, function(request, response) {
  var email = request.object.get("email");
  request.object.set("emailHash", email? MD5(email) : "");
  response.success();
});
@ryanjduffy
ryanjduffy / README.md
Last active February 18, 2018 06:32
Enyo Inspector Bookmarklet to inspect an Enyo instance by shift-clicking it.
@ryanjduffy
ryanjduffy / installer.sh
Created May 1, 2013 16:43
Parse Cloud Code installer for c9.io
#!/bin/bash
TMP_FILE=~/parse.tmp
if [ -e $TMP_FILE ]; then
echo "Cleaning up from previous install failure"
rm -f $TMP_FILE
fi
echo "Fetching latest version ..."
/**
_enyo.FittableLayout_ provides the base positioning and boundary logic for
the fittable layout strategy. The fittable layout strategy is based on
laying out items in either a set of rows or a set of columns, with most of
the items having natural size, but one item expanding to fill the remaining
space. The item that expands is labeled with the attribute _fit: true_.
The subkinds <a href="#enyo.FittableColumnsLayout">enyo.FittableColumnsLayout</a>
and <a href="#enyo.FittableRowsLayout">enyo.FittableRowsLayout</a> (or
<i>their</i> subkinds) are used for layout rather than _enyo.FittableLayout_
@ryanjduffy
ryanjduffy / fiddle
Last active December 14, 2015 00:09
Enyo CLI fiddle
/*
* jssha256 version 0.1 - Copyright 2006 B. Poettering
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ryanjduffy
ryanjduffy / inherited.sublime-snippet
Created January 19, 2013 20:38
If you're using Sublime Text 2 for EnyoJS, you need this snippet!
<snippet>
<content><![CDATA[
this.inherited(arguments);
]]></content>
<tabTrigger>inh</tabTrigger>
<scope>source.js</scope>
<description>this.inherited(arguments);</description>
</snippet>
enyo.kind({
name: "LoaderTest",
kind: enyo.TestSuite,
testSingleLoad: function() {
enyo.load("tests/loader1.js", enyo.bind(this,
function() {
if (window.LOADER_TEST === "loader1") {
this.finish();
}
else {
enyo.kind({
name:"ex.RemoteEcho",
kind:"cli.Command",
command:"recho",
commandHandler:function(source, command) {
this.doCommandResponse({response:[{content:"You said, \"" + command.argList.join(" ") + "\""}]});
}
});
enyo.kind({