This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
var fs = require('fs'), | |
moment = require('moment'), | |
underscore = require('underscore'), | |
child_process = require('child_process'), | |
spawn = child_process.spawn, | |
exec = child_process.exec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WithStopPropagation = React.createClass({ | |
propTypes: { | |
children: React.PropTypes.node.isRequired, | |
eventNames: React.PropTypes.arrayOf(React.PropTypes.string).isRequired | |
}, | |
eventNameToReactEventName: function(name){ | |
return "on" + name[0].toUpperCase() + name.slice(1); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# no reason for this to be declared out here | |
# links = [] | |
delicious.get 'posts/all', (data) -> | |
# your for loop was an overcomplicated version of map | |
links = data.map (item) -> item.href | |
# pass the data where you need it | |
doSomething(links) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {forEach} = React.Children; | |
var childrenAreType = function(desiredType) { | |
var validator = function(props, propName, componentName) { | |
forEach(props[propName], (element) => { | |
const {type} = element; | |
if (type !== desiredType) { | |
throw TypeError(`Invalid child for "${componentName}": "${type.displayName || type.name || type}", expected "${desiredType.name}"`); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LineItemDetailContainer = React.createClass({ | |
displayName: 'LineItemDetailContainer', | |
mixins: [FluxMixin], | |
propTypes: { | |
/** | |
* lineItemId that we are displaying the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import md5 from 'MD5'; | |
class Avatar extends React.Component { | |
static propTypes = { | |
email: React.PropTypes.string, | |
size: React.PropTypes.number | |
} | |
static defaultProps = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from "React"; | |
export var Enhance = ComposedComponent => class extends Component { | |
static displayName = "Enhanced" | |
constructor() { | |
this.state = { data: null }; | |
} | |
componentDidMount() { | |
this.setState({ data: 'Hello' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from "react"; | |
export var Enhance = ComposedComponent => class extends Component { | |
static displayName = "Enhanced" | |
constructor() { | |
super(); | |
this.state = { data: null }; | |
} | |
componentDidMount() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const KEY = Symbol('my key'); | |
class Foo { | |
constructor(){ | |
this[KEY] = 'my secret key'; | |
} | |
get key(){ | |
return this[KEY]; | |
} | |
} |