Skip to content

Instantly share code, notes, and snippets.

@cowboyd
cowboyd / dataset.js
Last active August 27, 2015 21:48
An API to put the fun back in rendering an asynchronous, paginated dataset in JavaScript!
import Dataset from 'dataset';
import getStuff from 'get-stuff';
// Dataset.js is a JavaScript only object for navigating through paged
// data. It understands that rendering a paged dataset in realtime as
// it is incrementally and asynchronously loaded is no mean feat, and
// so it's got your back.
//
// It's goal is to give you as much information about what exactly is
// happening at any give moment so that you can represent it
@cowboyd
cowboyd / paged-dataset.js
Last active August 29, 2015 14:04
Paged Dataset in Ember Data
App.PagedDataset = Ember.ArrayProxy.extend({
page: 1,
store: null, //instance of DS.Store
type: null, // the type name of the record array e.g. 'person'
content: Ember.computed('page', function() {
return this.store.find(this.type, {page: this.get('page')});
})
})
var dataset = App.PagedDataset.create({
@cowboyd
cowboyd / robobs.rb
Created September 16, 2014 20:16
hypothetical ruby DSL for brick pi robot operations
# config phase
OperationInstance = Struct.new(:start, :condition, :finish)
class OperationBuilder
def start(&block)
@start = block || proc {}
end
def condition(&block)
class DemoBot < BrickPi::Bot
motor :port_A
motor :port_B
property :forward_speed do |value|
motor_A.spin value
motor_B.spin value
end
property :rotation_speed do |value|
@cowboyd
cowboyd / store_helper.coffee
Created October 14, 2014 14:39
Setting up the store
# We generally use Mocha not QUnit, so ymmv.
# Basically, make the store available for all test cases so
# they can do setup.
#
# creating fixture data has always been a problem for us, and
# we have yet to find the "sweet" solution
#
# This goes in global spec helper
beforeEach ->
@cowboyd
cowboyd / precompile.rb
Created October 29, 2014 14:35
Using Precompiled Templates from Ruby
require 'handlebars'
# reopen this class to give access to the
# underlying runtime
class Handlebars::Context
attr_reader :js
end
context = Handlebars::Context.new
template = context.js.eval my_precompiled_template
@cowboyd
cowboyd / concerning-net-neutrality.md
Last active August 29, 2015 14:16
Letter to John Cornyn, United States Senator from Texas

Mr Cornyn,

I am the owner of a small tech firm (http://frontside.io) that employees 6 people in Central Texas, so I can assure you that I am driven by pragmatism rather any ideological consideration. Like you, I am concerned with my people and the best way to ensure their continued prosperity.

That is why I find it less important the fashion in which my rights are protected, so long as they remain protected. I am not crazy about net neutrality being enforced by the FCC, but I am, without a doubt, dead set on its enforcement through one means or another. Right now, the FCC is the only governmental body making any stand to protect the fairness of our networks, and so lacking a better option, I feel obligated to support them. If you could commit publicly to a plan to protect net neutrality that does not involve over-regulation or the overreach of a regulatory body such as the FCC, then I would engage with it vigorously, but at the moment the loudest voice in the debate is your colleague and co-senator Ted Cru

@cowboyd
cowboyd / mutable-collection.js
Created March 26, 2015 14:59
Present a mutable interface to an immutable array and track changes in realtime
import Ember from 'ember';
/**
* Presents a mutable interface to an immutable array.
*
* As you make changes to the array, it tracks which objects are new,
* which objects have been removed, and which objects were in the
* original array. To use an instance of this class, set the
* `original` property to an array. This array will not be touched as
* you make changes via the mutable interface. E.g.
import Ember from 'ember';
import XHR from 'ember-xhr';
/**
* On the rails server, this creates an active record that stores the
* filename and generates the pre-signed url, the return format is
* something like:
*
* {
* "upload": {
$ docker pull andrewd/osxcross
$ docker run andrewd/osxcross x86_64-apple-darwin12-cc --version ✱
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-apple-darwin12
Thread model: posix