Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Knipe niborg

View GitHub Profile
@niborg
niborg / login_macros.rb
Created Apr 29, 2020
Request spec login macros
View login_macros.rb
def create_session(user)
payload = { username_or_email: user.email }
if user.two_factor?
payload.merge!(auth_code: user.otp_code)
else
payload.merge!(password: user.password)
end
post '/sessions', payload
error = session[:flash] && session[:flash][:error]
@niborg
niborg / date_parser.rb
Created Jul 12, 2019
Service wrapping Ruby's standard library so as to sniff out date ranges.
View date_parser.rb
# frozen_string_literal: true
module Utilities
# Class wrapping Ruby's standard library so as to sniff out date ranges.
#
class DateParser
Error = Class.new(StandardError)
RangeParseError = Class.new(Error)
DateRangeNotPresent = Class.new(Error)
View reports
report: {
// Params to filter the results
//
filters: {
date_range: {
start: <formatted date String>, // required
end: <formatted date String> // optional defaults to today
},
matter_types: <Array of ids>, // optional, defaults to array containing all matter types
sources: <Array of ids>, // optional, defaults to array containing all sources,
View ethereum_acct
0x07666C5dCdF60c6e837bDfc4f26Ad457e30dfC38
@niborg
niborg / gist:39214bd8d088eacd1ffb296b6232060d
Last active Mar 19, 2018
template demonstrating that :if option in after_commit on: [event] triggered during other lifecycles
View gist:39214bd8d088eacd1ffb296b6232060d
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.