Skip to content

Instantly share code, notes, and snippets.

View MatthewRDodds's full-sized avatar

Matthew Russell Dodds MatthewRDodds

View GitHub Profile
@MatthewRDodds
MatthewRDodds / decorators.rb
Last active May 1, 2017 14:54
Ruby Decorator Recipe
module Decorator
def initialize(component)
@component = component
end
def method_missing(meth, *args)
if @component.respond_to?(meth)
@component.send(meth, *args)
else
super
@MatthewRDodds
MatthewRDodds / sql_review.md
Last active February 7, 2017 00:54
SQL Review

SQL Basics

Notes from CodeSchool's "Sequel to SQL"

Aggregate Functions

Some commonly used aggregate functions are: min, max, avg, sum, and count.

Examples:

@MatthewRDodds
MatthewRDodds / a.sh
Last active December 9, 2016 15:47
Seed staging database on heroku
heroku pg:reset DATABASE_URL --remote heroku-dev
heroku run rake db:migrate --remote heroku-dev
heroku run bash --remote heroku-dev
bundle install --with development
rake db:seed_fu RAILS_ENV=development
@MatthewRDodds
MatthewRDodds / a.txt
Created October 26, 2016 10:10
status codes
This is an interesting post about api messages and status codes, with examples from top apis: http://apigee.com/about/blog/technology/restful-api-design-what-about-errors
The TL;DR is that only about 8 status codes should be used as a maximum, and they should be used accurately to describe the error obviously.
These 8 statuses are:
200 - OK
404 - Not Found
500 - Internal Server Error
201 - Created
@MatthewRDodds
MatthewRDodds / gems_development_from_gemfile.md
Created October 19, 2016 15:04
Solution around commenting out gems for development and specifying path

Without this config update bundler will raise errors, it's a weird default they use (see this issue):

bundle config disable_local_branch_check true

The add the config for the gem to make bundler look to the path you specify rather than where it has downloaded the gem too, as source:

bundle config local.YOUR_GEM_NAME YOUR_GEMS_PATH
@MatthewRDodds
MatthewRDodds / spacing.scss
Created October 14, 2016 13:19
spacing.scss
$spacer: 1rem !default;
$spacer-x: $spacer !default;
$spacer-y: $spacer !default;
$spacers: (
0: (
x: 0,
y: 0
),
half: (
x: ($spacer-x * 0.5),
@MatthewRDodds
MatthewRDodds / elasticsearch_overview.md
Last active July 29, 2016 14:33
Thousand Foot Overview - Elasticsearch Queries

Elasticsearch Querying DSL Overview

TERMS

  • filter A filter is query that either matches a document or doesn't, it's boolean.
  • query A query uses scoring to order results by the degree to which they match the request. Queries are much less performant than filters.

Some queries can contain other queries (bool), some can contain filters (constant_score), and others can contain both (filtered).

@MatthewRDodds
MatthewRDodds / a.md
Last active September 13, 2017 15:49
Codeschool Font Guidelines Design

General Guidelines

Fonts

Serif

  • Humanist Serif good for Journalism or Historical
  • Transitional Sefir good for Traditional Acedamia and Legal
  • Modern Serif good for Arts and Culture
  • Eqyption (Slab Serif) good for Marketing and Promotional
@MatthewRDodds
MatthewRDodds / gist:8e3acbc20b481618e6ce
Created March 14, 2016 17:27
react on rails generator
rails generate react_on_rails:install --redux --server-rendering --ruby-linters --heroku-deployment --skip-bootstrap
@MatthewRDodds
MatthewRDodds / gist:59d444d491eab384fb5c
Created February 23, 2016 17:17
Skipping Authentication For Rspec Controllers in a Json API
RSpec.configure do |config|
  config.before(:each, type: :controller) do |example|
    unless example.metadata[:skip_login_mock]
      allow_any_instance_of(ApiController).to receive(:restrict_access)
        .and_return(true)
    end
  end
end