Navigation Menu

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 / description.md
Last active August 29, 2015 14:04
Ember Data Two Models in One Request

The Problem

We've got a server endpoint that's returning two models (in the example, Apples and Oranges). It makes sense for the server to do the computation in this way, so we ideally don't want to change this response structure. So, image you hit an endpoint /fruits that returns apples and oranges in a side-loaded fashion. In the example JSBin, we're mocking this response.

So far, so good. However, we want to be able to request Apples or Oranges indepently from the Store (e.g. store.findAll('orange') or store.findAll('apple')). We found a way to do this by overriding pathForType, which works great, but we are double-requesting the data from server when we request Apples and Oranges on the same page. Imagine you were able to swap in different components containing info about Apples or Oranges, and it needs to request itself from the store to ensure we have the data in the store to show the user (or request from the server if we don't have the data

# {{ 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')
@blimmer
blimmer / route-meta.coffee
Created March 26, 2015 20:08
RouteMetaMixin
`import Ember from 'ember'`
# Route mixin for setting head meta tags on transition into/out of route
#
# @example How to set meta tags on a route
# App.ExampleRoute = Ember.Route.extend App.RouteMetaMixin,
# meta: ->
# return
# meta_property_name1: meta_value1
# meta_property_name2: meta_value2
@blimmer
blimmer / adapters.application.js
Last active August 29, 2015 14:27
Ember Data - 2 Models with Same Path
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
});
@blimmer
blimmer / components.my-component.js
Last active August 29, 2015 14:27
Range Slider Working - Ember 1.13.6
import Ember from 'ember';
export default Ember.Component.extend({
_minZoom: 1,
_maxZoom: 5,
zoomLevel: 1,
});
<div class="form-group {{if hasError 'has-error'}}">
{{#if hasBlock}}
<label class='control-label infield-label'>{{yield}}</label>
{{/if}}
{{input type=type
class='form-control'
value=value
focus-out=(action 'fieldTouched')}}
{{#if hasError}}
<div class='help-block'>{{errorMessage}}</div>
@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 / application.controller.js
Created February 1, 2016 17:10
when setting goes wrong
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@blimmer
blimmer / notes.md
Last active March 31, 2016 20:47
EmberConf 2016