Skip to content

Instantly share code, notes, and snippets.

View blimmer's full-sized avatar

Ben Limmer blimmer

View GitHub Profile
<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 / 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,
});
@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 / 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
# {{ 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 / 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

@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