Skip to content

Instantly share code, notes, and snippets.

@ryanjduffy
ryanjduffy / App.js
Last active August 29, 2015 14:20
GridListImageItem + Badge Overlay
require('spotlight');
var
ready = require('enyo/ready'),
kind = require('enyo/kind'),
GridListImageItem = require('moonstone/GridListImageItem'),
ImageBadge = require('moonstone/ImageBadge');
ready(function () {
var C = kind({
@ryanjduffy
ryanjduffy / codepen.html
Created June 18, 2014 16:40
CodePen.io Launcher for EnyoJS
<html>
<head>
<title>CodePen.io Launcher for EnyoJS</title>
</head>
<body>
<form id="form" action="http://codepen.io/pen/define" method="POST"><input id="data" type="hidden" name="data"></form>
<script>
var q = document.location.search.substring(1);
var libs = q.split(",");
@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();
});