Skip to content

Instantly share code, notes, and snippets.

View barelyknown's full-sized avatar

Sean Devine barelyknown

View GitHub Profile
@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 / 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 / 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
@barelyknown
barelyknown / gist:153e94c0d847e15251a8
Last active January 23, 2018 11:28
Testing after_commit :do_something, on: :create
describe "#after_commit" do
context "on: :create" do
before do
expect(subject).to receive(:transaction_record_state).with(:new_record).and_return(true)
end
it "calls initiate_async" do
expect(subject).to receive(:initiate_async)
subject.run_callbacks(:commit)
end
end
@barelyknown
barelyknown / query-all-mixin.js
Created November 28, 2017 04:03
Example mixin that queries for all records using Ember data, one page at a time.
import Mixin from '@ember/object/mixin';
import { inject } from '@ember/service';
import { get } from '@ember/object';
import { task } from 'ember-concurrency';
const PAGE_LIMIT = 10;
// Mixin anywhere you'd like to query for all records that match
// a filter, one page at a time. This can be helpful anywhere you need
// need all records loaded, but don't want to hit the server with long
// running requests.
class ComparisonValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return if options[:allow_blank] && value.blank?
return if options[:allow_nil] && value.nil?
unless comparison_attribute = options[:attribute]
raise ArgumentError, "missing attribute option"
end
unless operator = options[:operator]
@barelyknown
barelyknown / contributor_first_names.csv
Created September 2, 2016 03:49
The first names of contributors to The Information as of September 1, 2016.
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
first_name
Aaron
Aaron
Abhilash
Adam
Adam
Adam
Adam
Adam
Aditya