Skip to content

Instantly share code, notes, and snippets.

Steven Lindberg slindberg

View GitHub Profile
@slindberg
slindberg / awesome_face.nc
Last active Dec 31, 2016
G-code for drawing an awesome face on a 3-axis CNC
View awesome_face.nc
%
(Modal reset)
G0 G90 G17 G40 H0 G70 G80
(Tool change - black sharpie)
G53 Z0.0
M06 T1
M19
G54 X0.0 Y0.0
G0 Z0.25 H1
@slindberg
slindberg / app_templates_components_form-control.hbs
Last active Dec 8, 2016
Two-way bindings and the `mut` helper in Ember
View app_templates_components_form-control.hbs
<div class="form-control">
<label>{{attrs.label}}</label>
{{! Since mutable attributes are now wrapped, this will no longer work :( }}
{{input value=attrs.value}}
{{! Instead, we need to leverage some kind of event... }}
{{input value=attrs.value.value key-up=attrs.value.update}}
{{! Or, forgo two-way bindings and the `input` helper altogether, which forces us to create an explicit action... }}
View keybase.md

Keybase proof

I hereby claim:

  • I am slindberg on github.
  • I am slindberg (https://keybase.io/slindberg) on keybase.
  • I have a public key whose fingerprint is B8DE 7D75 20BF AE0F 4BBF 5301 B3D8 0328 DA30 4283

To claim this, I am signing this object:

@slindberg
slindberg / if-all-exists.js
Last active Aug 29, 2015
Bound conditional Handlebars helpers for Ember
View if-all-exists.js
import ifConditionHelper from 'myapp/helpers/if-condition';
/**
* Logical AND Existence Conditional Block
*
* Usage: {{#if-all-exists field1 field2}}Either field1 or field2 is truthy{{/if-all-exists}}
*
* Executes the given block if all arguments are defined
*/
export default function() {
@slindberg
slindberg / README.md
Last active Aug 29, 2015
Model 'Fragments' in Ember Data
View README.md
@slindberg
slindberg / ember-data.dependent-relations.js
Last active Mar 7, 2016
Dependent Relationships in Ember Data
View ember-data.dependent-relations.js
/**
Ember Data: Dependent Relationships
This package extends Ember Data to support creating relationships
where a model's dirty state depends not only on its own attributes
but on the dirty state of models in dependent relationships as well.
```javascript
App.Thing = DS.Model.extend({
name : DS.attr('string'),
@slindberg
slindberg / multi-select-input.hbs
Created Jan 23, 2014
Ember Components: Overridable Content Blocks Example
View multi-select-input.hbs
{{#content-for "option"}}
<a href="#">{{view.label}}</a>
{{/content-for}}
{{#content-for "unselected-option"}}
{{content-for "option"}}
{{/content-for}}
{{#content-for "selected-option"}}
{{content-for "option"}}
@slindberg
slindberg / README.md
Last active Feb 19, 2018
Ember debug helpers intended to be used in the JavaScript console
View README.md

Ember.Console

This is a set of helpers for finding the application's currently active models/routes/controllers/etc. This isn't a straightforward process because of how Ember (rightly) encapsulates application objects, but it's useful in debugging environments to be able to quickly access them. And with the beta release of Ember Data, the store is not easily accessible without helpers either.

Usage

All helpers can be called directly if you provide them an application instance:

@slindberg
slindberg / adapter.js
Last active Dec 24, 2015
Ember data serializer that normalizes embedded records without ids
View adapter.js
App.ApplicationSerializer = DS.RESTSerializer.extend({
// Extract embedded relations from the payload and load them into the store
normalizeRelationships: function(type, hash) {
var store = this.store;
this._super(type, hash);
type.eachRelationship(function(attr, relationship) {
var relatedTypeKey = relationship.type.typeKey;
@slindberg
slindberg / index.html
Last active Dec 11, 2015 — forked from iffy/index.html
Custom path interpolator
View index.html
<html>
<head>
<title>Chart</title>
<style>
path {
stroke: #f00;
}
.line {
stroke: #0f0;
fill: none;
You can’t perform that action at this time.