Skip to content

Instantly share code, notes, and snippets.

View ryenski's full-sized avatar
🎯
Focusing

Ryan Heneise ryenski

🎯
Focusing
  • Austin, TX
View GitHub Profile
# Let's simulate a DripService object that will give us some output:
class DripService
include ActiveModel::Model
attr_accessor :entry
def call
print "You passed in an entry: #{entry.email}"
end
end
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_action :authenticate_user!
include CurrentTenant
end
@ryenski
ryenski / activity.rb
Last active December 5, 2018 12:36
Audit trail activity tracker, similar to PaperTrail, but without undo.
# == Schema Information
#
# Table name: activities
#
# id :uuid not null, primary key
# user_id :uuid
# tenant_id :uuid
# trackable_type :string
# trackable_id :uuid
module Archivable
extend ActiveSupport::Concern
included do
scope :archived, ->{ unscope(where: :archived_at).where.not(archived_at: nil) }
scope :without_archived, ->{ where(archived_at: nil) }
scope :with_archived, ->{ unscope(where: :archived_at) }
default_scope { without_archived }
end
module Trashable
extend ActiveSupport::Concern
included do
scope :trashed, ->{ unscope(where: :trashed_at).where.not(trashed_at: nil) }
scope :without_trashed, ->{ where(trashed_at: nil) }
scope :with_trashed, ->{ unscope(where: :trashed_at) }
default_scope { without_trashed }
# TODO: scope for items older than 30 days for reaping by the rake task:
assert_difference(Stock.value, +100) do
stock.increment
end
.card {
@apply bg-white shadow rounded-lg;
@media print {
@apply shadow-none;
}
}
.card-header {
@apply bg-gray-100 border-b border-gray-200 h-16 px-4 rounded-lg rounded-b-none flex justify-between items-center;
@media print {
@ryenski
ryenski / add_feature_flags_to_users.rb
Last active June 28, 2019 17:08
Feature Flags with Pundit
# Migration...
class AddFeatureFlagsToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :feature_flags, :string, array: true, default: []
end
end
# frozen_string_literal: true
# bundle exec rails runner create_accounts.rb
# An organization that the above users don't have access to
organization = Organization.find_or_create_by(slug: 'accounting-demo') do |o|
o.name = 'Accounting Demo'
o.invite_code = Rails.configuration.mx_iso_agent['invite_code']
end
@ryenski
ryenski / pix-brief.md
Last active October 14, 2019 17:42
Project Brief for PIX Portal

Project Brief for PIX Portal

We're looking for a talented and competent Ruby on Rails developer to help us re-engineer an existing app that's hard to maintain and expensive. The existing app is built using React on the frontend and Apache Airflow on the backend. We're going to re-engineer the app to make it more maintainable and remove some unneeded complexity that makes it difficult to maintain and expensive to develop.

The purpose of this app is to receive credit card processing reports, apply a markup algorithm, and then generate a report for each store based on the result.

About the app

The current process is handled by two separate apps: