Skip to content

Instantly share code, notes, and snippets.

View brentmulligan's full-sized avatar

Brent Mulligan brentmulligan

View GitHub Profile
// Marionette.Gauntlet v0.0.0
// --------------------------
//
// Build wizard-style workflows with an event-emitting state machine
// Requires Backbone.Picky (http://github.com/derickbailey/backbone.picky)
//
// Copyright (C) 2012 Muted Solutions, LLC.
// Distributed under MIT license
Marionette.Gauntlet = (function(Backbone, Picky, Marionette, $, _){
@brentmulligan
brentmulligan / serializeObject.js
Created October 28, 2015 21:32
serialize form data
(function($){
$.fn.serializeObject = function(){
var self = this,
json = {},
push_counters = {},
patterns = {
"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
"key": /[a-zA-Z0-9_]+|(?=\[\])/g,
"push": /^$/,
/**
* Composite components are higher-level components that compose other composite
* or native components.
*
* To create a new type of `ReactClass`, pass a specification of
* your new class to `React.createClass`. The only requirement of your class
* specification is that you implement a `render` method.
*
* var MyComponent = React.createClass({
* render: function() {
@brentmulligan
brentmulligan / outside_controller.rb
Last active January 21, 2016 22:01
How to serialize with ActiveModelSerializer outside of a controller
serializer = PostSerializer.new(post)
adapter = ActiveModel::Serializer::Adapter.create(serializer)
# output
adapter.as_json
/Users/brentmulligan/.rvm/gems/ruby-2.3.0/bundler/gems/activeadmin-fcc5a60e01c5/lib/active_admin/namespace.rb:189:in `eval': Unable to autoload constant Engine, expected /Users/brentmulligan/.rvm/gems/ruby-2.3.0/gems/knock-1.5/lib/knock/engine.rb to define it (LoadError)
from /Users/brentmulligan/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/brentmulligan/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:543:in `load_missing_constant'
from /Users/brentmulligan/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/brentmulligan/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/inflector/methods.rb:270:in `const_get'
from /Users/brentmulligan/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/inflector/methods.rb:270:in `block in constantize'
from /Users/brentmullig
export default function* root() {
// yield an array of forked generator functions (watchers).
yield [
// Asyncly call each watcher
fork(watchReqProductList),
fork(watchReqProduct),
fork(watchCreateUser),
fork(watchReqUserAuth),
fork(watchCreateUserSession)
// This watcher is listening for a START_CREATE_USER dispatch.
// It expects that action to have a payload attribute and it passes that attribute along.
function* watchCreateUser() {
// while (true) tells the watcher to watch forever.
while (true) {
// "yield take" = Wait here until a 'START_CREATE_USER' action is dispatched
const { payload } = yield take(START_CREATE_USER)
// "yield fork" = Asyncly call a generator called startCreateUseFlow, pass it the payload.
yield fork(startCreateUserFlow, payload)
@brentmulligan
brentmulligan / debounce-redux-form-middleware.js
Last active November 5, 2019 21:01
debounce redux form actions with redux batched actions
import debounce from 'lodash/debounce'
import { batchActions } from 'redux-batched-actions'
/**
* Create a redux middleware function that debounces specified
* action types and processes them together with batchActions.
*
* @param {array} actionTypes - An array of actions types to debounce
* @param {number} [wait=0] - Time to wait before executing action batch
* @returns {function} - middleware function
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@brentmulligan
brentmulligan / yardoc_cheatsheet.md
Created October 22, 2019 15:37 — forked from phansch/yardoc_cheatsheet.md
Improved YARD cheatsheet