Skip to content

Instantly share code, notes, and snippets.

View petehunt's full-sized avatar

Pete Hunt petehunt

View GitHub Profile
/** @jsx React.DOM */
var Hello = React.createClass({
mixins: [LinkedStateMixin],
getInitialState: function() {
return {name: 'phunt'};
},
render: function() {
return (
<div>
@petehunt
petehunt / gist:6601475
Created September 17, 2013 22:20
memory allocations oh no
<html>
<head>
<title>wtf</title>
</head>
<body>
yolo
<script>
window.addEventListener('mousemove', function() {}, false);
</script>
</body>
@petehunt
petehunt / gist:6601468
Created September 17, 2013 22:20
omg memory allocations
<html>
<head>
<title>wtf</title>
</head>
<body>
yolo
<script>
window.addEventListener('mousemove', function() {}, false);
</script>
</body>
function resetBrowserify(cb) {
window.require = null;
// TODO: somehow identify all browserified script tags
var scripts = Array.prototype.slice.call(document.querySelectorAll("script[src='build/browserified.js']"));
scripts.map(function(script) {
script.remove();
var newScript = document.createElement('script');
newScript.src = script.src;
document.head.appendChild(newScript);
});
var visitors = require('react-tools/vendor/fbtransform/visitors').transformVisitors;
var transform = require('react-tools/vendor/fbtransform/lib/transform').transform;
console.log(transform(visitors.react, '/** @jsx React.DOM */<p />').code);
import os
import json
import subprocess
import sys
def relativize(path):
return os.path.relpath(os.path.abspath(path), os.path.abspath('.'))[:-3]
DEPS_MEMO = {}
/** @jsx React.DOM */
var MyRootComponent = React.createClass({
getInitialState: function() {
return {perMinute: '-', perDay: '-'};
},
componentDidMount: function() {
var socket = io.connect(this.props.url);
socket.on('business.clickout', this.setState.bind(this));
},
render: function() {
/** @jsx React.DOM */
var MyComponent = React.createClass({
getInitialState: function() {
// set up the initial state. used for "logical" initialization code
return {perMinute: '-', perDay: '-'};
},
componentDidMount: function() {
// fired only once, when the component is added to the DOM
// used for initialization code that has "side effects" i.e. i/o, jquery plugins, etc
var socket = io.connect(this.props.url);