Skip to content

Instantly share code, notes, and snippets.

View leebyron's full-sized avatar
🌎

Lee Byron leebyron

🌎
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script src="http://fb.me/react-with-addons-0.12.0.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@leebyron
leebyron / es6_import.js
Last active August 29, 2015 14:13
ES6 import -> CJS example
import * as foo from "foo"
var $foo = require("foo");
var foo = $foo;
import foo from "foo"
var $foo = require("foo");
var foo = $foo.default;
import { foo } from "foo"
var $foo = require("foo");
@leebyron
leebyron / gist:d4ad335f833389642af8
Created December 29, 2014 03:53
Unsubscribe from all Amazon Birthday Alerts
/*
At some point I connected Facebook friends to Amazon wishlists. Now I get
multiple emails from Amazon for the birthday of everyone I ever met.
Removing people from this list requires a bunch of manual clicking.
Automation FTW.
1) http://www.amazon.com/gp/registry?ie=UTF8&type=wishlist
@leebyron
leebyron / gist:755227877ce47077e16d
Created November 21, 2014 02:18
Jasmine matcher for Immutable
beforeEach(function () {
this.addMatchers({
is: function(expected) {
return Immutable.is(this.actual, expected);
}
})
})
@leebyron
leebyron / index.js
Created November 20, 2014 01:05
requirebin sketch
/*
This is a trivial example of using Immutable structures as React state.
Note that replaceState() must be used instead of setState(), as setState expects
an object literal and will merge it (Object.assign) with the previous state.
replaceState() is a simple swap.
*/
@leebyron
leebyron / index.js
Created November 11, 2014 22:44
requirebin sketch
var insertCSS = require('insert-css')
insertCSS('.foo { color: red; }')
var React = require('react/addons');
var CSSCore = require('react/lib/CSSCore');
window.r = React;
var Component = React.createFactory(React.createClass({
render: function() {
function handleClick(element, event) {
if (event.button === 1) {
return { count: 0 };
}
if (element.props.onClick) {
element.onClick();
}
element.updateState(s => {...s, count: s.count + 1 });
}
var data = {...}
var react = React.renderComponentToString(<Component data={data} />);
writeToClient(
'<html><head><script src="myCompiledJS.js"></script></head>' +
'<body><div id="foo">' + react + '</div>' +
'<script>React.renderComponent('+
'Component({data:'+ JSON.stringify(data) + '}), document.getElementById("foo")'+
')</script>' +
'</body></html>'
@leebyron
leebyron / Gradient2D.pde
Last active August 23, 2017 20:09
Solar relative position math from Solar Calendar.
class Gradient2D{
PImage source;
Gradient2D(String src){
source = loadImage(src);
}
color get(float g1, float g2){
int x = constrain( floor( g1*source.width ), 0, source.width-1);
@leebyron
leebyron / geocode
Created October 14, 2014 21:50
Simple geocoder
class Geocoder{
// google maps api key
String apiKey;
Geocoder(String apiKey){
this.apiKey = apiKey;
}
double[] locate(String location){