Skip to content

Instantly share code, notes, and snippets.

@blimmer
blimmer / rename-master-to-main.sh
Last active Jun 17, 2020
A helper tool to fix local clones after renaming "master" branches to "main"
View rename-master-to-main.sh
#! /bin/bash
set -e
if ! git diff-index --quiet HEAD --; then
echo "ERROR: you have uncommited changes. Please stash or commit before running this script."
exit 1
fi
git fetch
View components.card-thingy.js
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['card-thingy'],
click() {
this.sendAction('transitionToMyRoute');
}
});
@blimmer
blimmer / monkeypatch.rb
Created Mar 21, 2018
Rails Issue #30947 Workaround
View monkeypatch.rb
# This patch is to work around this bug in Rails 5.0.x and 5.1.x
# https://github.com/rails/rails/issues/30947
# Because we use SQLite for tests and MySQL in prod, having the options hash
# containing ENGINE=InnoDB causes problems when we try to prepare the test database.
#
# Because of this, we need to remove those options from the generated schema.rb file.
# Here is the source that's setting `options`
# https://github.com/rails/rails/blob/81787a895126ead62a2859b33eccbbb74ef38892/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L561
#
# This should be removed for Rails 5.2 ++
View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
array: Ember.A([]),
setSomeStuff() {
this.get('array').pushObjects(['foo', 'bar', 'baz']);
}
});
@blimmer
blimmer / components.my-ec-component.js
Created Oct 31, 2017
ember concurrency example for joey
View components.my-ec-component.js
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
export default Ember.Component.extend({
myVal: null,
asyncPoll: task(function * () {
console.log('polling');
this.set('myVal', Math.random());
yield timeout(1000); // ms
this.get('asyncPoll').perform(); // requeue myself
@blimmer
blimmer / foo_for_caching.rb
Created Sep 27, 2017
Rails Issue 30680 Workaround
View foo_for_caching.rb
# This class exists to make the caching of Foo objects more efficient.
# Marshaling full activerecord objects is expensive, especially in Rails 5
# because of this bug: https://github.com/rails/rails/issues/30680
# This simple ruby class selects a very small subset of parameters needed
# for common operations on these objects. It also acts like Foo, by
# passing attributes through to an in-memory Foo model.
class FooForCaching
attr_accessor :attributes
# This is a list of attributes we want to save in cache
@blimmer
blimmer / bug_report.rb
Last active Sep 16, 2021
ActiveRecord 5 Bug Report - marshal slow loading
View bug_report.rb
# frozen_string_literal: true
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
@blimmer
blimmer / components.user-info.js
Created Aug 9, 2017
wip multipage validations
View components.user-info.js
import Ember from 'ember';
import { validator, buildValidations } from 'ember-cp-validations';
import { userInfoValidations } from '../models/order';
const Validations = buildValidations(userInfoValidations);
export default Ember.Component.extend(Validations, {
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});