Skip to content

Instantly share code, notes, and snippets.

View rosskevin's full-sized avatar

Kevin Ross rosskevin

View GitHub Profile
@rosskevin
rosskevin / es2015-rollup-import-chai.js
Last active April 18, 2016 20:48
This is the failed output of rollup for the statement `import {expect} from 'chai'` - bad options for global?
/*
Rollup messages:
[15:45:47] Treating 'buffer' as external dependency
[15:45:48] No name was provided for external module 'buffer' in options.globals – guessing 'require$$0'
index.js
import {expect} from 'chai'
chai - chai@3.5.0
// @flow
import React, {Component, PropTypes} from 'react'
import {withRouter} from 'react-router'
import {security} from '../../../lib/security/security'
import Form from 'react-formal'
import yup from 'yup'
import Helmet from 'react-helmet'
import Logger from '../../../lib/util/logger'
import autobind from 'autobind-decorator'
// @flow
import React, {Component, Element} from 'react'
import {withRouter} from 'react-router'
import {security} from '../../../lib/security/security'
import Form from 'react-formal'
import yup from 'yup'
import Helmet from 'react-helmet'
import Logger from '../../../lib/util/logger'
import autobind from 'autobind-decorator'
LINE_ITEM = Validations::Schema.new_schema do
required_id(:product_id)
required(:quantity).value(:number?, gteq?: 0)
optional(:period_start_at).maybe(:time?)
optional(:period_end_at).maybe(:time?)
end
SCHEMA = Validations::Schema.new_schema(BaseDocument::SCHEMA) do
required(:line_items).each(LINE_ITEM)
end
require 'i18n'
require 'reform/form/dry'
module Acme
module Validations
module DslExtension
#
# Setup our own macros here (much shorter to use)
#
# @see dry-rb/dry-validation extending_dsl_spec.rb
@rosskevin
rosskevin / Performance.js
Created September 12, 2016 17:26
React Performance/shouldComponentUpdate visibility helper
// @flow
import reShallowEqual from 'recompose/shallowEqual'
import Logger from './Logger'
class Performance {
static shouldComponentUpdate (component, nextProps, nextState, nextContext, dig = false) {
if (!__DEV__) {
return (
!reShallowEqual(this.props, nextProps) || !reShallowEqual(this.state, nextState) || !reShallowEqual(this.context, nextContext)
)
@rosskevin
rosskevin / Col.js
Last active December 11, 2022 18:15
material-ui `next` responsive layout/grid using JSS (originally based on flexboxgrid.com)
// @flow
import React, {Component, Element, PropTypes} from 'react'
import classNames from 'classnames'
import pure from 'recompose/pure'
import merge from 'lodash/merge'
import {createStyleSheet} from 'jss-theme-reactor'
import Logger from '../../util/Logger'
import {capitalizeFirstLetter} from '../../util/strings'
type DefaultProps = {
@rosskevin
rosskevin / Box.js
Created September 23, 2016 17:30
Samples for material-ui `next` responsive layout/grid using JSS (originally based on flexboxgrid.com)
// @flow
import React, {Element, PropTypes} from 'react'
import pure from 'recompose/pure'
import {createStyleSheet} from 'jss-theme-reactor'
import classNames from 'classnames'
import Logger from '../../../util/Logger'
type Props = {
type: ?string,
children: ?Element<any>
@rosskevin
rosskevin / com.sabnzbd.SABnzbd.plist
Created October 14, 2016 02:28
OSX sabnzbd daemon using launchctl with a wait for the volume to be present (using MountWatcher)
?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sabnzbd.SABnzbd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-a</string>
const config = {
devtool: 'source-map',
devServer: {
port: 3808,
headers: {
'Access-Control-Allow-Origin': '*'
}
},
context: '/Users/kross/projects/af/spec/dummy',
entry: {