Skip to content

Instantly share code, notes, and snippets.

@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 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 / 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 / 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 / README.md
Last active August 29, 2015 14:27
Console jsperf

Usage Example

// Setup code before all tests are ran
jsperf.before(function () {
   testStr = '-1/2';
});

// Teardown code after all tests are ran
jsperf.after(function () {
@ryanjduffy
ryanjduffy / dev.palm.com.17701
Created August 25, 2011 14:01
toaster example
var _Example = {
name:"com.technisode.example.App",
kind:"Control",
components:[
{kind:"Button", caption:"click me", onclick:"clicked"},
{kind:"toaster.addtsk", name:"addtsk"}
],
clicked:function() {
this.$.addtsk.openAtCenter();
}
@ryanjduffy
ryanjduffy / gist:1199671
Created September 7, 2011 03:21
Reset kind to published properties
var _Example = {
name:"com.technisode.example.App",
kind:"Control",
published:{
a:1,
b:2,
c:3
},
components:[
{kind:"IntegerPicker", name:"aPicker", label:"A"},
@ryanjduffy
ryanjduffy / App.js
Created February 23, 2012 17:33
Enyo wrapper for cubiq's iScroll 4
enyo.kind({
name:"ex.App",
kind:"Control",
components:[
{kind:"cubiq.iScroll", components:[
{kind:"VirtualRepeater", onSetupRow:"setupRow", components:[
{name:"row", onclick:"rowClicked"},
{kind:"Button", onclick:"buttonClicked"},
{kind:"Slider", min:0, max:20}
]},
@ryanjduffy
ryanjduffy / app.css
Created November 29, 2012 14:20
Enyo Tutorial - To Do Application
.todo-list {
width:50%;
background:#fff;
}
.todo-list .task-row {
height:40px;
background:#ccf;
border-bottom:1px solid #eef;
}
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({