Skip to content

Instantly share code, notes, and snippets.

var LineItemDetailContainer = React.createClass({
displayName: 'LineItemDetailContainer',
mixins: [FluxMixin],
propTypes: {
/**
* lineItemId that we are displaying the
@brigand
brigand / container.js
Last active August 29, 2015 14:16 — forked from davidaurelio/container.js
prop types example
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}"`);
}
});
# 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)
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);
},
@brigand
brigand / dzen.js
Last active August 29, 2015 14:06 — forked from DanielFGray/dzen.js
#!/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;
@brigand
brigand / 0_reuse_code.js
Last active August 29, 2015 14:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
var mysql = require('mysql'),
http = require('http');
var connections = [null, null, null].map(function(){
var connection = mysql.createConnection({
host : 'localhost',
database : 'benchmark',
user : 'root',
password : '1234'
});
var Promise = require('bluebird'); // or load bluebird some other way
var getSoundCloudUser = function(artist, params){
var get = Promise.promisify(Soundcloud.get, Soundcloud)
return get('/e1/users/' + artist + '/stream', params);
};
var stream = {
tracks: [],
playlists: []
};
require! {
React
RRouter
request: superagent
Header: "../components/Header.ls"
Loading: "../components/Loading.ls"
}
Link = RRouter.Link
@brigand
brigand / Auth
Last active August 29, 2015 14:01
var mysql = require('../lib/db');
var pub = {
authorize:function(uid,origin, cb){
mysql.getConnection(function(err, connection) {
if (err){ return cb(err); }
// Use the connection
connection.query('SELECT secret_key,domain_name FROM rs_eshop_auth WHERE secret_key = ?',uid, function(err, rows) {
if (err){ return cb(err); }