Skip to content

Instantly share code, notes, and snippets.

View wrburgess's full-sized avatar
:shipit:
Shippin'

Randy Burgess wrburgess

:shipit:
Shippin'
View GitHub Profile
@wrburgess
wrburgess / *rail_static_assets_on_heroku_cedar.md
Created December 10, 2016 21:14 — forked from bensheldon/*rail_static_assets_on_heroku_cedar.md
Serving Rails Static Assets on Heroku using a CDN with gzip and cache control

Optimizing Rails Static Assets on Heroku Cedar

Serving Rails static assets is hard, especially on Heroku Cedar where Heroku forces Rails to serve static assets itself (which isn't particularly performant nor worth your dyno-dollar)---this is different than Heroku Bamboo which used Varnish and is no more. To make the best of the situation, I highly recomend:

  1. Using the Heroku-Deflater gem which will selectively gzips assets (it gzips text-based files; and excludes images or binary files, which can actually be bigger when gzipped)

  2. Configure your production environment to set cache-control headers and get out of denial about how static assets are being served on Heroku Cedar

  3. Use AWS Cloudfront (or a CDN of your choosing) to serve the assets. Cloudfront is great because you can use the same Distribution

@wrburgess
wrburgess / rspec_rails_cheetsheet.rb
Created December 4, 2016 23:31 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@wrburgess
wrburgess / all_s3_objects.rb
Created September 21, 2016 02:30 — forked from brianhempel/all_s3_objects.rb
List/fetch all objects in a bucket with AWS::S3 Ruby gem
# by default you only get 1000 objects at a time
# so you have to roll your own cursor
S3.connect!
objects = []
last_key = nil
begin
new_objects = AWS::S3::Bucket.objects(bucket_name, :marker => last_key)
objects += new_objects
@wrburgess
wrburgess / .block
Created June 14, 2016 21:40 — forked from mbostock/.block
Bar Chart with Negative Values
license: gpl-3.0
@wrburgess
wrburgess / ultimate-ut-cheat-sheet.md
Created June 2, 2016 14:51 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@wrburgess
wrburgess / example_activejob.rb
Created April 8, 2016 04:50 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
@wrburgess
wrburgess / Gemfile
Last active March 24, 2016 02:27 — forked from tylerhunt/Gemfile
ActiveAdmin association autocomplete without complicated plugins.
gem 'active_model_serializers'
gem 'activeadmin'
gem 'jquery-ui-rails'
@wrburgess
wrburgess / fix-homebrew-npm.md
Created December 5, 2015 18:09 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

If you just want to fix the issue quickly, scroll down to the "solution" section below.

Explanation of the issue

If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you may see an error like this:

$ npm update npm -g
@wrburgess
wrburgess / genreView.js
Created November 30, 2015 04:22 — forked from joshhunt/genreView.js
Routing in TVML app using Page.js
import genreTemplate from 'templates/genre.tvml.jade';
import get from 'lib/api/get';
import tvOS from 'lib/tvOS';
export default function tvSeriesView({params}) {
get(`/genres/${params.genreSlug}`).then((viewData) => {
const doc = genreTemplate(viewData);
tvOS.pushDocument(doc);
});
}
@wrburgess
wrburgess / # Sublime Emmet JSX Reactjs.md
Created October 20, 2015 02:35 — forked from max-mykhailenko/# Sublime Emmet JSX Reactjs.md
Sublime text 3. Enable Emmet in JSX files with Sublime React plugin

Problem

  • Using emmet in jsx files
  • Emmet expands text when js autocomplete needed
  • Using className instead of class

How it works

  • Install plugin RegReplace
  • Install plugin Chain Of Command