Skip to content

Instantly share code, notes, and snippets.

Matt Vague mattvague

View GitHub Profile
mattvague / Normalizing-Denormalizing-JSONAPI-in-redux.js
Last active Jan 14, 2019
How I do Normalizing / Denormalizing of JSONAPI data in redux
View Normalizing-Denormalizing-JSONAPI-in-redux.js
// This is quick demo of how I currenty normalize / denormalize JSON API responses into redux
import normalize from 'json-api-normalizer'
// Given this example response from a JSONAPI endpoint
const json = {
data: [{
View ScrollVelocity.js
import React from 'react'
import { PureComponent } from 'react'
class ScrollVelocity extends PureComponent {
constructor (props, context) {
super(props, context)
this.state = {
lastScrollTop: 0,
lastScrollLeft: 0,
View invalid_records.rake
namespace :invalid_records do
task check: [:environment] do
puts "Checking for invalid records...\n"
invalid_records = []
total_record_count = 0
# Make sure that all AR models are required
Dir["#{Rails.root}/app/models/**/*.rb"].each { |file_path| require file_path rescue nil }
View gist:6025606
class BulkFileJob
@queue = :bulk
# Class methods
def self.perform(bulk_id)
View gist:5497342
// Retina helper mixins for Compass
// Copyright 2012, Joe Lambert.
// Free to use under the MIT license.
// Inline for standard / URL for retina
background-image: asset-data-uri($image)
View gist:3896506
classes =
aClass: class AClass
constructor: ->
alert("A class")
# Should say "A class"
new classes.aClass
class bClass extends classes.aClass
constructor: ->
View gist:1389605
ActiveAdmin.register Post do
collection_action :favorite, :method => :post, :batch_action => true do
ActiveAdmin.register Post do
batch_action :favorite do |selection|
mattvague / gist:1233433
Created Sep 21, 2011
Regex that matches any valid zip code or postal code
View gist:1233433
/(^\d{5}$)|(^\d{5}-\d{4}$)|(^[a-zA-Z]\d[a-zA-Z] ?\d[a-zA-Z]\d$)/i
View javascript_lint_spec.rb
require 'spec_helper'
require 'jslint'
describe "Javascript" do
before do
@lint =
:paths => ['public/javascripts/**/*.js'],
:exclude_paths => ['public/javascripts/vendor/**/*.js'],
:config_path => 'spec/support/jslint.yml'
You can’t perform that action at this time.