Skip to content

Instantly share code, notes, and snippets.

View crobinson42's full-sized avatar
🏠
Working from home

Cory Robinson crobinson42

🏠
Working from home
  • American Software
  • Northwest USA
View GitHub Profile
<Form
onSubmit={props.handleSubmit}
render={({ handleSubmit, submitting, submitError, values }) => (
<form
className="col-md-8 offset-md-2 col-xs-12 text-center"
onSubmit={handleSubmit}
>
<Field name="email" validate={formValidate.required}>
{({ input, meta }) => (
@crobinson42
crobinson42 / carspeed.py
Created April 6, 2018 20:57
Track cars speed!
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import math
import datetime
import cv2
# place a prompt on the displayed image
def prompt_on_image(txt):
@crobinson42
crobinson42 / rollup.config.js
Created March 30, 2018 02:03
rollup-plugin-commonjs issue with default no exported
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
export default {
input: 'src/index.js',
output: [
{
file: 'lib/bundle.es.js',
format: 'es',
import React, { Component } from 'react'
import { connect } from 'react-redux'
class UserContainer extends Component {
componentDidMount() {
if (!this.props.user)
this.props.getUser()
}
render () {
// containers/user/actions.js
export const getUser = () => ({
type: 'GET_USER',
payload: {
request: {
url: '/people',
},
},
})
@crobinson42
crobinson42 / gist:8e20846c6dd2843af23cd7c1b5014611
Last active November 23, 2017 02:05
Citrusbyte.com - flatten array
function flatten (a) {
return [].concat( ...a.map(x => Array.isArray(x) ? flatten(x) : x) )
}
flatten([1, 2, [3, 4, [5], 6, [7, [8]]]])
// [ 1, 2, 3, 4, 5, 6, 7, 8 ]
@crobinson42
crobinson42 / ContactForm.jsx
Created November 21, 2017 21:30
Redux-form reusable validation field
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Field, reduxForm, SubmissionError } from 'redux-form'
import { connect } from 'react-redux'
import { required, phoneNumber, email } from 'utils/formUtils'
import { submitContactForm } from './actions'
import ReactLoading from 'react-loading'
import ValidationField from 'components/form/ValidationField'
@crobinson42
crobinson42 / index.js
Created April 7, 2017 23:39
xPath selector creator
// Hover your mouse over an element, then press ctrl + spacebar, the xPath selector will be console logged
var getElementXPath = function(element) {
if (element && element.id)
return '//*[@id="' + element.id + '"]'
else
return getElementTreeXPath(element)
}
var getElementTreeXPath = function(element) {
var paths = [];
@crobinson42
crobinson42 / dillon_task_filter_input.js
Created March 31, 2017 18:05
Live filter input for Dillon task board
// tamper script to add a live filter input next to search
const $table = $('table.task-list')
const $tableBody = $table.find('tbody')
const $filterInput = $('<input type="search" placeholder="filter"/>')
const filterInput = inputText => {
if (!inputText || inputText.length < 3) {
$tableBody.find('tr.hidden').map((i, el) => {
$(el).removeClass('hidden')
})
return
@crobinson42
crobinson42 / setup.js
Last active March 18, 2017 21:00
aablefishing.com - API fiddle config & globals
function setup(axiosConfig = {}) {
// http://jsfiddle.net/coryrobinson42/r4fto1et/6/
/*****************
SETUP & Config
******************/
// because of Cross-Origin-Site issues we use the raw dev box url
window.DEV_API = 'https://howesfishing-server-crobinson42.c9users.io/'