Skip to content

Instantly share code, notes, and snippets.

View Ross-Hunter's full-sized avatar

Ross-Hunter Ross-Hunter

View GitHub Profile
# We mix this in to our controllers
module Authenticatable
extend ActiveSupport::Concern
included do
before_action :authenticate_user!
end
protected

Keybase proof

I hereby claim:

  • I am ross-hunter on github.
  • I am rosshunter (https://keybase.io/rosshunter) on keybase.
  • I have a public key ASBO_f8n8vDlPUoW7QSPIbfdMdhvmwZLi0e1OE-UGxAQ-go

To claim this, I am signing this object:

@Ross-Hunter
Ross-Hunter / notes.md
Created January 9, 2018 13:10
Notes from JSONAPI Ruby Meetup
@Ross-Hunter
Ross-Hunter / request_spec_helpers.rb
Last active January 8, 2018 22:28
Request Spec Helpers
module RequestSpecHelpers
def authenticate user
params = { email: user.email, password: 'test_password' }
post api_v2_auth_path, params: params
# You will need to modify this line based on your auth scheme
# This code works with token based auth
@auth_token = json_body.dig :meta, :'auth-token'
end
// ** Mad Libs **
// Ask the user for the words to fill in the blanks
var who = prompt("a person");
var what = prompt("a thing");
var amount = prompt("a number");
// prompt always returns a string. here we convert it to a number
amount = Number(amount);
// calculate the total
var total = amount * 5;
@Ross-Hunter
Ross-Hunter / flexbox-mobile.html
Created October 18, 2017 17:23
Flexbox Mobile Funtimes!
<html>
<style>
/* RESET CSS */
ul {
margin: 0;
padding: 0;
}
li {
margin: 0;
padding: 0;
@Ross-Hunter
Ross-Hunter / flexbox.html
Last active October 18, 2017 15:22
Flexbox Funtimes!
<html>
<style>
.flex-container {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.top-nav {
background-color: #551A8B;
color: rgba(255,255,255,0.8);
@Ross-Hunter
Ross-Hunter / .gitconfig
Created March 9, 2017 15:46
My Git Files
[include]
path = ~/.gitconfig-core
path = ~/.gitconfig-aliases
[user]
name =
email =
[alias]
pr = !zsh -ic open-pr
[core]
autocrlf = input
module HttpHelpers
def authenticate user
params = { email: user.email, password: 'test_password' }
post '/auth', params
@auth_token = json_body.dig :meta, :'auth-token'
end
def authed_get endpoint, opts = {}
get endpoint, opts, auth_header
@Ross-Hunter
Ross-Hunter / json_api_airborne_helpers.rb
Last active April 11, 2017 15:33
Expecation Helpers for jsonapi using the Airborne gem
module ExpectationHelpers
def expect_attributes attrs
expect_json 'data.attributes', dasherize_keys(attrs)
end
def expect_attributes_in_list attrs
expect(json_body[:data]).to_not be_empty
expect_json 'data.?.attributes', dasherize_keys(attrs)
end