Skip to content

Instantly share code, notes, and snippets.

@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 ..."
@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 / 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 () {
// vim: syntax=JSX
import React from 'react';
export default class MyClass extends React.Component {
render() {
return (
<a href="google.com">Let's head to google.com</a>
);
}
}
@ryanjduffy
ryanjduffy / logState.js
Last active January 30, 2023 08:43
Log React State Changes
import React from 'react';
const original = React.Component.prototype.setState;
const logState = function (type, current, updated) {
console.log(type.displayName || type.name || 'Component', 'updating', current, 'with', updated);
}
const logger = function (partialState, callback) {
const type = this._reactInternalInstance._currentElement.type;
@ryanjduffy
ryanjduffy / debugger.html.diff
Created February 26, 2017 02:07
Auto-expand breakpoints when adding a new breakpoing in debugger.html
diff --git a/src/components/SecondaryPanes/index.js b/src/components/SecondaryPanes/index.js
index 43dcb33..f4aad39 100644
--- a/src/components/SecondaryPanes/index.js
+++ b/src/components/SecondaryPanes/index.js
@@ -65,6 +65,15 @@ const SecondaryPanes = React.createClass({
displayName: "SecondaryPanes",
+ componentWillReceiveProps(nextProps) {
+ const { breakpoints: { size }} = this.props;