Skip to content

Instantly share code, notes, and snippets.

View barelyknown's full-sized avatar

Sean Devine barelyknown

View GitHub Profile
@barelyknown
barelyknown / gist:3692433
Created September 10, 2012 17:42
Send Email From Rails Console
# Simple approach to sending email from the Rails console
# Implementation idea courtesy of Steve Klabnik
# http://blog.steveklabnik.com/posts/2012-09-09-random-ruby-tricks--class-new
# Create the mailer class with a block and assign to a variable
mailer = Class.new(ActionMailer::Base) do
def example_message
mail(to: "test@test.com", from: "test@test.com", subject: "Example Message") do |format|
format.text { render text: "Example message body" }
end
@barelyknown
barelyknown / db_structure_splitter.rake
Created May 11, 2025 00:26
db_structure_splitter.rake
require "fileutils"
require "active_support/core_ext/string/inflections"
namespace :db do
# db:split_structure
# ------------------
# This Rake task processes the `db/structure.sql` file generated by Rails (typically from `pg_dump`).
# Its primary goal is to split this monolithic SQL file into a more manageable, organized
# set of smaller SQL files. The organization is primarily table-centric, meaning that DDL
# statements related to a specific table (CREATE TABLE, ALTER TABLE, CREATE INDEX, CREATE TRIGGER,
@barelyknown
barelyknown / list_recent_files.rb
Created April 9, 2025 02:01
To find the most recent files in a directory, run: ./scripts/list_recent_files.rb [directory_path] or specify the number with -n [count].
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'time'
require 'open3'
require 'fileutils'
require 'optparse'
# Parse command line options
@barelyknown
barelyknown / xbe-10-step-problem-solving-process.md
Created October 22, 2024 20:39
This document outlines a comprehensive 10-step problem-solving process designed to efficiently address customer issues and opportunities. The process ensures clear communication, thorough analysis, and effective resolution while maintaining customer satisfaction throughout.

10-Step Problem Solving Process

This document outlines a comprehensive 10-step problem-solving process designed to efficiently address customer issues and opportunities. The process ensures clear communication, thorough analysis, and effective resolution while maintaining customer satisfaction throughout.

  1. Assign a Customer Success Captain
  2. Communicate the Process to the Customer
  3. Gather Information about the Problem and Context
  4. Determine the Severity of the Problem
  5. Generate Resolution Strategies
  6. Select the Optimal Resolution Strategy
@barelyknown
barelyknown / rspec_diff_vs_master.zsh
Created May 18, 2024 18:47
This script identifies changed spec files in a Git repository and runs RSpec tests on them.
#!/bin/zsh
# Step 1: Get the list of changed files
changed_files=$(git diff --name-only master)
# Step 2: Initialize an array for spec files
spec_files=()
# Step 3: Populate the array with spec files
while IFS= read -r file; do
@barelyknown
barelyknown / business-answer-why-ember-4.md
Last active September 28, 2022 01:06
What does changing to Ember 4 mean for the XBE platform and users?

Ember is the framework that the client is built with. We started with Ember 1.x and have stayed updated with the various versions of ember through the years. The bet on ember, more than just the framework at the time, is on the Ember community, its core team, its roadmap, and its ideals. Ember is a productive framework and it’s a pretty big reason we’re able to have such a huge app built by such a small team.

Ember has one surprising upgrade philosophy: Upgrading to the new major version adds no new features. It only removes deprecated features. 4.0 will bring us no new features, but will make sure that our code base fits the newer specifications which are in some ways stricter and more robust. Better. The work to deprecate and get us ready for 4.0 was carried out over the past several months, lead by Hassan.

But in the same way Ember 3.0 didn’t bring in new features, Ember 3.13 established Octane, which brought with it several patterns like tracked properties and element modifiers and native classes, whic

@barelyknown
barelyknown / gist:1369399
Created November 16, 2011 06:09
How do you check if a parent SObject has any children Sobjects in a VisualForce page without a wrapper class?
When looping through a set of Salesforce.com SObjects from a VisualForce page, you may want to test whether the SObject has any children without wrapping the SObjects in a wrapper class. Here's how:
Controller:
Create a property in the controller that is a map of the parent IDs and Boolean flag.
public Map<Id, Boolean> hasChildren {
get {
if (this.hasChildren == null) {
for (Parent__c parent : [select id, (select id from children__r) from parent__c]) {
if (parent.children__r.size() > 0) {
@barelyknown
barelyknown / xbe-newsletter-37.md
Created November 9, 2020 20:32
We're not going to rename "Incidents" to "Opportunities", but we probably should!

If half the secret to optimizing operational performance is careful planning of each day's work, the other half is learning from all significant deviations between planned and actual performance so that avoidable issues aren't repeated. XBE calls this process "Incident Management", and it's the key to continuous improvement.

Most teams find incident management challenging for two main reasons:

  1. Strong cultural aversion to placing attention on mistakes and problems
  2. Unfamiliarity with continuous improvement tools

Culture eats strategy for breakfast.

When a company's culture makes incident management uncomfortable or punitive, familiarity with continuous improvement tools won't matter much. Therefore, let's focus first on what norms get in the way and what changes will make continuous improvement possible.

@barelyknown
barelyknown / unobtrusive_poller.js.coffee
Last active April 25, 2019 21:01
Unobtrusive JavaScript solution for polling in a Rails application
###
Unobtrusive JavaScript solution for polling in a Rails application
Introduction:
Add a polling-placeholder wrapper div to any partial and add a data attribute
named poll that should be equal to "true" until you want to stop polling.
The default polling frequency will be used unless you provide an "interval" data
attribute which should be the number of milliseconds to use for the interval.
@barelyknown
barelyknown / simple_heroku_follower_solution.markdown
Last active February 18, 2019 23:21
Simple solution to use a follower database for some ActiveRecord reads.

Heroku recommends using Octopus to connect to followers.

But, Octopus doesn't work yet with Rails 4.1.

Here's a super simple solution to use a follower for some reads for an ActiveRecord class:

config/database.yml

follower_development:
  <<: *default