Skip to content

Instantly share code, notes, and snippets.

View tbcooney's full-sized avatar

Taylor Cooney tbcooney

View GitHub Profile
@tbcooney
tbcooney / sign-pdf.rb
Created September 24, 2020 15:31 — forked from matiaskorhonen/sign-pdf.rb
Quick and dirty PDF signing in Ruby (using Origami)
#!/usr/bin/env ruby
require "openssl"
require "time"
begin
require "origami"
rescue LoadError
abort "origami not installed: gem install origami"
end

Here is a plain-ruby approach for a flexible and expendable authorization solution to authorize actions that a user can? perform within an account or organization based on their access_level.

class CreateMembers < ActiveRecord::Migration[6.0]
  def change
    create_table :members do |t|
      t.references :account, null: false, foreign_key: true
      t.integer :access_level
      t.references :user, foreign_key: true
@tbcooney
tbcooney / business_hours.rb
Created August 21, 2019 04:07
Serialization TimeOfDay with Rails and jsonb
#!/usr/bin/env ruby
# Supplies TimeOfDay class that includes parsing, strftime, comparison, and arithmetic
gem 'tod', '~> 2.2'
ActiveRecord::Schema.define do
add_column :businesses, :force => true do |t|
t.jsonb :business_hours
end
end