Skip to content

Instantly share code, notes, and snippets.

View moimikey's full-sized avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
@andrewgleave
andrewgleave / AnimatableComponent.js
Last active May 17, 2024 02:06
Keyframe animation support for React. Enables integration between React components and JS animation events.
/** @jsx React.DOM */
'use strict';
var React = require('react');
var AnimatableComponent = React.createClass({
propTypes: {
tag: React.PropTypes.component.isRequired,
@staltz
staltz / introrx.md
Last active August 2, 2025 18:25
The introduction to Reactive Programming you've been missing
@lygaret
lygaret / index.js
Last active July 3, 2025 09:26
ES6 Quasi-Literal for JSX
define(function(require) {
var React = require('react');
var paramRegex = /__(\d)+/;
var parser = new DOMParser();
var errorDoc = parser.parseFromString('INVALID', 'text/xml');
var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI;
// turns the array of string parts into a DOM
// throws if the result is an invalid XML document.
@LenaicTerrier
LenaicTerrier / twitter-entities.js
Last active September 26, 2021 01:53 — forked from wadey/twitter-entities.js
Added support for emojis and html specials characters.
/*
* twitter-entities.js
* This function converts a tweet with "entity" metadata
* from plain text to linkified HTML.
*
* See the documentation here: http://dev.twitter.com/pages/tweet_entities
* Basically, add ?include_entities=true to your timeline call
*
* Based off existing code from Wade Simmons
* Licensed under the MIT license
@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
@arnemart
arnemart / gist:c26aeddcb7d719b45529
Last active August 29, 2015 14:05
Cursors example
var React = require('react');
var Immutable = require('immutable-with-cursors');
var mainComponent = React.createClass({
getInitialState: function() {
return this.props;
},
render: function() {
return React.DOM.ul(
null,
@moimikey
moimikey / functions.js
Created August 13, 2014 15:51
Firebug lite's useful helper methods condensed
this.arrayInsert = function (array, index, other) {
for (var i = 0; i < other.length; ++i) {
array.splice(i + index, 0, other[i])
}
return array
};
this.createStyleSheet = function (doc, url) {
var style = this.createElement("link");
style.setAttribute("charset", "utf-8");
style.setAttribute("rel", "stylesheet");
@moimikey
moimikey / array_reverse.js
Last active June 14, 2023 17:08
reversing an array, the fast and simple way!
var i, arr = [1, 2, 3, 4, 5, 6, 7, 8];
for(i = 0; i < arr.length / 2; i++) {
var temp = arr[i];
arr[i] = arr[arr.length - i - 1]
arr[arr.length - i - 1] = tmp
}
/*
passes:
@sebmarkbage
sebmarkbage / react_legacyfactory.md
Last active March 15, 2020 00:32
Use a factory or JSX

React Element Factories and JSX

You probably came here because your code is calling your component as a plain function call. This is now deprecated:

var MyComponent = require('MyComponent');

function render() {
 return MyComponent({ foo: 'bar' }); // WARNING
@moimikey
moimikey / konami.coffee
Last active October 3, 2015 22:39
a standalone marionette module you can use in your own app to add a single konami code
@MM.module 'KonamiApp', (KonamiApp, App, Backbone, Marionette, $, _) ->
# up, up, down, down, left, right, left, right, a, enter
KonamiApp.sequence = [38, 38, 40, 40, 37, 39, 37, 39, 65, 13]
KonamiApp.pressed = []
KonamiApp.on
'start': ->
$(window).on 'keyup.konami', KonamiApp.pressedKey
'stop': ->
$(window).off '.konami'