Skip to content

Instantly share code, notes, and snippets.

View jeroencoumans's full-sized avatar

Jeroen Coumans jeroencoumans

View GitHub Profile
@heyimalex
heyimalex / react-state-cache-mixin.js
Created August 4, 2014 19:52
React mixin for caching state in sessionStorage across mounts.
var StateCacheMixin = function(key) {
if (!Modernizr.sessionstorage) {
return {};
}
return {
componentWillMount: function() {
var prevState = sessionStorage.getItem(key);
if (prevState === null) return;
try {
prevState = JSON.parse(prevState);
@heyimalex
heyimalex / react-promise-state.js
Last active July 14, 2017 05:46
Helper for dealing with promise-y state in React.js
const PENDING = 0;
const FULFILLED = 1;
const REJECTED = 2;
function PromiseState(component, stateKey, initial) {
this.component = component;
this.stateKey = stateKey;
var self = this;
var Fluxxor = require('fluxxor');
var request = require('superagent');
var AuthStore = Fluxxor.createStore({
actions: {
"LOGIN_AUTH": "onLoginAuth",
},
initialize: function() {
this.currentUser = {};
@vegetableman
vegetableman / gist:e9ed4df769c49343af84
Created May 13, 2014 18:02
Scroll Cloaking on reactjs
/**
* @jsx React.DOM
*/
// Parent
var React = require('react'),
BlockItemView = require('./BlockItemView.jsx');
module.exports = BlockView = React.createClass({displayName: 'BlockView',
@maedhr
maedhr / gist:8823168
Created February 5, 2014 13:04
React GoogleMap Example
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false" ></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://fb.me/react-0.8.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
<script type='text/jsx'>
/** @jsx React.DOM */
ExampleGoogleMap = React.createClass({
getDefaultProps: function () {
@mattmccray
mattmccray / router.js
Last active December 26, 2015 14:29
Simple Backbone/Exoskeleton Router for use with React (http://facebook.github.io/react/)
var _missing= function(data){ return React.DOM.pre(null, "Route not found: "+ data.route) },
_router= null,
_started= false,
_nextId= 1;
function handleRouteChange(container, component) {
var routeParams= Array.prototype.slice.call( arguments, 1 )
React.renderComponent(
component({ routeParams:routeParams }, null),
container
@sheymann
sheymann / sigma.fruchterman.js
Created February 28, 2013 15:37
Fruchterman-Reingold layout plugin for Sigma.js with automatic cooling and stopping condition.
/**
* Linkurious 2012, all rights reserved.
* Sébastien Heymann <[email protected]>,
* Romain Yon <[email protected]>
*
* Please use http://jsbeautifier.org/ and indent with 2 spaces.
*
* Lib docs:
* http://twitter.github.com/bootstrap/
* http://docs.jquery.com/
@LeverOne
LeverOne / LICENSE.txt
Created October 24, 2011 04:17 — forked from jed/LICENSE.txt
generate random v4 UUIDs (107 bytes)
DO WTF YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Alexey Silin <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WTF YOU WANT TO PUBLIC LICENSE
@mwbrooks
mwbrooks / projectAppDelegate.m
Created February 15, 2011 18:43
ON PhoneGap-iOS, open external links in the external browser (Safari.app)
/**
* Note: the following function should already exist in your application delegate file.
* Replace it with the following implementation.
*
* Thanks to @purplecabbage for implementation.
* Thanks to Ruddiger for the iFrame patch.
*/
// ...