Skip to content

Instantly share code, notes, and snippets.

View endash's full-sized avatar

Christopher Swasey endash

View GitHub Profile
@endash
endash / gist:a873ab32f544665f2f61
Last active August 29, 2015 14:07
Tips for riding Amtrak
  1. At Penn Station in NY if you have luggage always ask for a "red cap." Unlike the murderous dwarves of lore, these guys just carry your luggage for you on a cart. The main benefit, however, is that you get to go down on the platform before everyone else, which means no waiting in line, and first pick of seats. Even if you just have a backpack.
  2. At 30th Street Station in Philly don't bother waiting in the line to go down onto the platform. They almost always open the platform well before the train arrives and you're just gonna be standing around down there anyway.
  3. Never pay extra for business class on any of the Northeast Regional trains. They basically just exist as extra-fare last minute tickets and the accommodations are identical.
  4. Conversely, there are certain long distance trains on the east coast (the named trains like the Vermontor or the Palmetto) that are so so so worth the extra charge for business class. Only for trains that have what is known as a "club car" though, which is a combined ca
var BlankComponent = Ember.Component.extend();
container.register('component:link-to', BlankComponent);
var view = Ember.View.createWithMixins({tempalte: Ember.Handlebars.compile('{{#link-li viewName="testComponent"}}{{#link-to viewName="linkToComponent"}}{{/link-to}}{/link-li}}')});
view.get('testComponent') // link-li
view.get('testComponent.linkToComponent') // link-to
export default {
name: 'mockjax',
initialize: function () {
...
}
};
@endash
endash / gist:a69298d644fb491ee9c7
Created October 8, 2014 17:09
Wrap Array in Ember
export default function wrapArray(pathToArray, itemController) {
return Ember.computed(function () {
var content = this.get(pathToArray);
return this.container.lookupFactory("controller:array").create({
model: content,
parentController: this,
itemController: itemController
});
});

Idle Reminiscing (on Rails)

Rails, in 2007, was a tall glass of cold water. Coming from a world of spaghetti-coded PHP scripts (if you were lucky—ColdFusion, Java, or ASP if you weren't) it seemed to be the right framework at the right time: the router took away the jumble of scripts that hard-coded our app endpoints, the "MVC" structure and naming conventions fit all of our code into nice, individually labeled bins, and ActiveRecord single-handedly eliminated 99% of the reams of hand-coded, error-prone, wildly insecure SQL that littered our codebases.

In time, though, it's become more and more clear that Rails was simply a framework at the right time. Rails didn't impose a new object-oriented structure on our previously formless apps... it simply imposed a new Railsy structure, and obscured the difference with a language change. If a block of code went at the top of a PHP file, that same chunk of code, transmogrified, got stuck into the controller, by default, because that was the first point o

// This is a disaster, thanks mostly to jquery-file-upload
App.FileUploadView = Ember.View.extend({
templateName: 'file_upload_view',
tagName: 'form',
classNames: ['file-upload-view', 'clearfix'],
attributeBindings: ['action', 'method', 'enctype'],
// action: "http://my_bucket.s3.amazonaws.com/",
action: null,
method: "POST",
ModelProxy = Ember.Object.extend(Ember.Validations.Mixin, Ember.ActionHandler, {
init: function() {
this.props = {};
this._super.apply(this, arguments);
},
autosave: false,
content: null,
facebook: function () {
var route = this;
FB.login(function (response) {
if (response.authResponse) {
var session = route.controllerFor('session');
session.set('facebookAccessToken', response.authResponse.accessToken)
session.save().then(function () {
route.transitionTo('calendar_month')
});
}
this.resource("artists", function () {
this.route("index");
this.resource("artist", {path: "/artists/:id"}, function () {
this.route('index');
this.resource("albums", function () {
this.route("index");
this.resource("album", {path: "/albums/:id"}, function () {
this.route('index');
this.resource("tracks", function () {
this.route('index');
$scope.$watch('[min, max]', function (vals) {
var min = vals[0], max = vals[1], date = $scope.date;
var start = moment(date),
end = moment(date);
start.hour(min/60);
start.minute(min % 60);
end.hour(max/60);