Skip to content

Instantly share code, notes, and snippets.

View mattvague's full-sized avatar

Matt Vague mattvague

View GitHub Profile
@mattvague
mattvague / javascript_lint_spec.rb
Created July 4, 2011 23:33
Javascript Lint spec
require 'spec_helper'
require 'jslint'
describe "Javascript" do
before do
@lint = JSLint::Lint.new(
:paths => ['public/javascripts/**/*.js'],
:exclude_paths => ['public/javascripts/vendor/**/*.js'],
:config_path => 'spec/support/jslint.yml'
@mattvague
mattvague / gist:1233433
Created September 21, 2011 21:55
Regex that matches any valid zip code or postal code
/(^\d{5}$)|(^\d{5}-\d{4}$)|(^[a-zA-Z]\d[a-zA-Z] ?\d[a-zA-Z]\d$)/i
@mattvague
mattvague / gist:1389605
Created November 23, 2011 19:15
Batch Action API
ActiveAdmin.register Post do
collection_action :favorite, :method => :post, :batch_action => true do
# DO STUFF
end
end
#vs.
ActiveAdmin.register Post do
batch_action :favorite do |selection|
classes =
aClass: class AClass
constructor: ->
alert("A class")
# Should say "A class"
new classes.aClass
class bClass extends classes.aClass
constructor: ->
// Retina helper mixins for Compass
// http://www.joelambert.co.uk
//
// Copyright 2012, Joe Lambert.
// Free to use under the MIT license.
// http://joelambert.mit-license.org/
// Inline for standard / URL for retina
=inline-background-image-retina($image)
background-image: asset-data-uri($image)
class BulkFileJob
@queue = :bulk
#-----------------------------------------------------------------------------
# Class methods
#-----------------------------------------------------------------------------
def self.perform(bulk_id)
new(bulk_id).perform
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 }
import React from 'react'
import { PureComponent } from 'react'
class ScrollVelocity extends PureComponent {
constructor (props, context) {
super(props, context)
this.state = {
lastScrollTop: 0,
lastScrollLeft: 0,
@mattvague
mattvague / Normalizing-Denormalizing-JSONAPI-in-redux.js
Last active January 14, 2019 18:18
How I do Normalizing / Denormalizing of JSONAPI data in redux
//
// 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: [{
name: ci
on:
push:
paths-ignore:
- 'README.md'
- 'docs/**'
env:
PGUSER: postgres
PGPASSWORD: postgres
jobs: