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 renderConditionCards = () => { | |
const renderedConditions = isMobileBreakpoint | |
? conditions[0] | |
: conditions.slice(0, 4); | |
return renderedConditions.map((condition, i) => { | |
const percentageProbability = getPercentageText(condition.probability); | |
const isTopCondition = i === 0; | |
const isSecondCondition = i === 1; | |
const lastIteration = i === renderedConditions.length - 1; | |
const shouldRenderAccordion = |
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 processResponseBody = async (response) => { | |
let result = ''; | |
if (!response || !response.body) { | |
return; | |
} | |
const reader = response.body.getReader(); | |
return new Promise((resolve) => { | |
reader.read().then(function processText({ done, value }) { | |
// Result objects contain two properties: |
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
// before | |
export default React.createClass({ …. }); | |
// after | |
export default class extends React.Component { … } |
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
function knapsack(vals, wts, maxWeight) { | |
var maxValFound = 0; | |
function maxVal(vals, wts, currentVal, currentWeight) { | |
for(var i=0; i<vals.length; i++) { | |
var addVal = vals[i]; | |
var addWeight = wts[i]; | |
if(currentWeight + addWeight > maxWeight) { | |
continue; |
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 { Router, Route, IndexRedirect, browserHistory } from 'react-router'; | |
import { syncHistoryWithStore } from 'react-router-redux'; | |
import { AppContainer } from './components/App'; | |
import { RandomContainer } from './components/Random'; | |
export default React.createClass({ | |
history: null, | |
_routes: null, |
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
// I run this right after webpack-dev-server task is complete | |
gulp.task('watch', () => { | |
gulp.watch('./styles/**/*.scss', ['watchCss']); | |
}); | |
// this triggers whenever a `.scss` file changes | |
// which triggers a new scss compliation | |
gulp.task('watchCss', ['buildStyles'], () => { | |
// browserSyncInstance is defined in my above gist | |
// https://gist.github.com/moog16/095f6e6e592ae83c0182e0977c8a8762 |
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 path = require('path'); | |
const merge = require('webpack-merge'); | |
const webpack = require('webpack'); | |
// args.getArgs is a custom function that I wrote for yarn | |
const args = require('./build/utils/args'); | |
// ENV Variables | |
const client = args.getArg('client') || 'default'; | |
const stubs = args.getArg('stubs'); | |
const PORT = 8080; |
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 gulp = require('gulp'); | |
const sass = require('gulp-sass'); | |
const path = require('path'); | |
const gutil = require("gulp-util"); | |
// custom importer for scss files that resolve file names in | |
// main app.scss manifest | |
const importer = require('../scssImporter'); | |
const postcss = require('gulp-postcss'); | |
const autoprefixer = require('autoprefixer'); | |
const cssnano = require('cssnano'); |
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 webpack = require('webpack'); | |
const WebpackDevServer = require('webpack-dev-server'); | |
const webpackConfig = require('./webpack.config.js'); | |
const browserSync = require('browser-sync'); | |
// a nice npm module written to have BrowserSync work with Webpack | |
// and webpack-dev-server | |
const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); | |
const renderTemplate = require('./build/gulp/template'); | |
const clients = require('./build/gulp/clients')(); | |
let browserSyncInstance; |
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 argv = require('yargs').argv; | |
const webpackConfig = { | |
colors: true, | |
module: { | |
loaders: [ | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules|jspm_packages)/, | |
loader: 'babel' | |
}, { |
NewerOlder