Skip to content

Instantly share code, notes, and snippets.

View ericdfields's full-sized avatar
🏠
Working from home in Baltimore, sometimes in DC

Eric Brookfield ericdfields

🏠
Working from home in Baltimore, sometimes in DC
View GitHub Profile
@ericdfields
ericdfields / bounce.py
Last active October 24, 2023 20:36
A python script to take a bunch of session stems and mix them down for quick reference listening
#
# For when you have a cigar box of SD cards that get dumped onto an external hard drive
# https://chat.openai.com/share/7090a9c0-2618-445e-a706-a232cf1d1a29
#
import argparse
from pydub import AudioSegment
from pydub.effects import normalize, compress_dynamic_range
import os
@ericdfields
ericdfields / const.js
Last active September 25, 2019 20:09
Globally available dark mode support in a Nuxt (Vue.js) app
/* store/const.js */
export const state = () => ({
darkMode: false
});
export const mutations = {
setDarkMode: state => {
state.darkMode = true;
},
unsetDarkMode: state => {
state.darkMode = false;
import reduce from 'lodash/reduce'
import isArray from 'lodash/isArray'
const prepareModelForRails = (model) => {
if (typeof model !== 'object') {
return model
} else {
if (isArray(model)) {
return model.map( m => prepareModelForRails(m) )
} else {
return reduce(model, (result, value, key) => {
EditPersonForm = reduxForm({
form: 'person',
touchOnChange: true
})(EditPersonForm);
import { createStore, combineReducers } from 'redux'
import { reducer as formReducer } from 'redux-form'
const reducers = {
form: formReducer
const renderPhoneNumbers = ({ fields, meta: { touched, error, submitFailed } }) => (
<ul>
<li>
<button type="button" onClick={() => fields.push({})}>Add Phone Number</button>
{(touched || submitFailed) && error && <span>{error}</span>}
</li>
{fields.map((member, index) => {
const field = fields.get(index)
if (field && field._destroy) {
return false
class EditPersonForm extends Component {
render() {
const { handleSubmit } = this.props
return (
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="first_name">First Name</label>
<Field name="first_name" component="input" />
</div>
<div>
ajax
.post( parseHref(this.props) )
.setCsrfToken()
.send( updatedPayload(payload,entity) )
.end( (err,response) => {
if (err) {
return standardError()
}
this.setDisabled()
this.props.callback && this.props.callback()
const ajax = require('superagent')
require('superagent-rails-csrf')(ajax)
export default ajax
@ericdfields
ericdfields / gist:3d4ed9c7f7b559289a102207facd61a7
Created February 3, 2017 15:30
Add multiple items to an Amazon Cart with a single button
I've seen links around the web for a list of items and a single 'add to amazon cart' button.
I don't know how to do this more easily through an amazon-provided UI, but it seems that you can hack it together through URL params easy enough, like so:
https://www.amazon.com/gp/aws/cart/add.html?AssociateTag=your_tag&tag=your_tagQ&ASIN.1=B012NH05UW&Quantity.1=1&ASIN.2=B012M8LXQW&Quantity.2=1
* ASINs are the string after /dp/ in amazon URLs. (amazon.com/dp/string_is_here)
* Add as URL params w/ incrementing identifiers and quantity couplets (ASIN.1, Quantity.1, ASIN.2, Quantity.2…)
@ericdfields
ericdfields / component.js
Last active January 10, 2017 18:27
Loading Inline SVG into React
/*
Use CSS for styling via the awesome styled-components library
https://styled-components.com
*/
import styled from 'styled-components'
const LoadingImage = require('loading-svg/loading-spin.svg')
const LoadingComponent = styled(LoadingImage)`