Skip to content

Instantly share code, notes, and snippets.

View blimmer's full-sized avatar

Ben Limmer blimmer

View GitHub Profile
@blimmer
blimmer / fixMavericksUnicastIssue
Created October 31, 2013 00:30
Bash script to resolve unicast issue on Mac 10.9 (Mavericks). This fix is temporary and does not persist a reboot (unlike other scripts floating around).
#!/bin/bash
# Mavericks has a nasty issue regarding ARPs in corporate networks.
# It appears that they have tried to reduce bandwidth utilization by caching
# the results of ARPs. Unfortunately, this causes big problems with corporate
# networks with Virtual IPs or other corporate network redundancy measures.
# There exist other patches for this issue
# (see https://github.com/MacMiniVault/Mac-Scripts/blob/master/unicastarp/unicastarp-README.md)
# but they write a value that will be pulled everytime the machine reboots. Because
@blimmer
blimmer / bug_report.rb
Last active September 16, 2021 09:59
ActiveRecord 5 Bug Report - marshal slow loading
# 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
# {{ radio-button name='dish' value='spam' groupValue=selectedDish }} Spam
# {{ radio-button name='dish' value='eggs' groupValue=selectedDish }} Eggs
#
App.RadioButtonComponent = Em.Component.extend
tagName: 'input'
type: 'radio'
attributeBindings: [ 'checked', 'name', 'type', 'value' ]
checked: Em.computed 'value', 'groupValue', ->
return @get('value') == @get('groupValue')
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@blimmer
blimmer / rename-master-to-main.sh
Last active June 17, 2020 20:20
A helper tool to fix local clones after renaming "master" branches to "main"
#! /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
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['card-thingy'],
click() {
this.sendAction('transitionToMyRoute');
}
});
@blimmer
blimmer / ember-cli-mirage-server-shutdown.md
Last active July 22, 2018 00:48
Ember-CLI-Mirage server.shutdown() explanation

What's the problem?

Mirage starts up a global server when your app initializers run. That means that each time you destroy your app, you need to call server.shutdown(). However, if you are on Ember CLI 1.13.8 or below, you won't have a destroy-app.js helper so we can automatically do this for you.

What can I do?

There are several things you can do to fix this. You only need to do one of the options below.

Upgrade Ember-CLI

This is the easiest way to fix this problem. Upgrade to Ember CLI 1.13.9 or higher (follow the upgrade steps with ember init) and re-run ember g ember-cli-mirage. That's it!

@blimmer
blimmer / monkeypatch.rb
Created March 21, 2018 20:47
Rails Issue #30947 Workaround
# 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 ++
@blimmer
blimmer / components.my-component.js
Created December 6, 2017 16:34
Ember Array for Joey
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 October 31, 2017 17:48
ember concurrency example for joey
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