Skip to content

Instantly share code, notes, and snippets.

@grese
grese / iframe_sandbox.jsx
Created Jun 12, 2016
A ReactJS component for rendering other React components into a "src-less" iframe
View iframe_sandbox.jsx
var Sandboxr = React.createClass({
componentDidMount() {
const iframe = this.refs.frame;
const node = iframe.contentDocument.createElement('div');
iframe.contentDocument.body.appendChild(node);
this._contentNode = node;
this._renderChildrenIntoContentNode(this.props);
},
@grese
grese / iframe-embed.js
Last active Dec 4, 2015
Dynamic iFrame Embed
View iframe-embed.js
function embedHTMLContent(markup, container) {
// generate a new HTML document, and an iFrame...
var newDoc = document.implementation.createHTMLDocument('sample flickr content'),
iFrame = document.createElement('iframe'),
destDoc, srcNode, newNode;
// Style the empty iframe, and insert it into the DOM...
iFrame.width = '400px';
@grese
grese / closureMath.js
Last active Aug 29, 2015
A script that creates functions for operators and operands, which can be used to perform basic math operations.
View closureMath.js
/*
* Creates functions for the numbers 0-9, and also functions for +, -, *, and /.
* Here is a list of the available functions:
* Operands: zero(), one(), two(), three(), four(), five(), six(), seven(), eight(), nine();
* Operators: plus(), minus(), times(), divide();
*
* Usage:
* The Operands ('zero' through 'nine') can be called with or without an operator as an argument.
*
* The Operators ('plus', 'minus', etc..) require that a number be passed as a param, and must be executed within an Operand.
You can’t perform that action at this time.