Skip to content

Instantly share code, notes, and snippets.

View endash's full-sized avatar

Christopher Swasey endash

View GitHub Profile
@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
});
});
export default {
name: 'mockjax',
initialize: function () {
...
}
};
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
@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
Ember.autoComputed = function () {
var args = Array.prototype.slice(arguments);
if (!args.length) return;
var func = args.pop();
if (typeof func !== 'function') return;
var depKeys = args.slice(0, -1);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Struct</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.15.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
function _main($0,$1) {
$0 = $0|0;
$1 = $1|0;
var $2 = 0, $3 = 0, $4 = 0, $5 = 0, label = 0, sp = 0;
sp = STACKTOP;
_swift_once((_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_token9|0),(1|0),(0|0));
HEAP32[__TvOSs7Process5_argcVSs5Int32>>2] = $0;
_swift_once((_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_token10|0),(2|0),(0|0));
HEAP32[__TvOSs7Process11_unsafeArgvGVSs20UnsafeMutablePointerGS0_VSs4Int8__>>2] = $1;
$2 = 8;
@endash
endash / command.textmate
Last active August 29, 2015 14:15
Quick and dirty multiple file editing in one window for TextMate - Add the command to a bundle (I use source) with: keycombo ⌘S, save document, discard output. Upon saving a file with the 'scratch' extension the script will parse out all the included files and write them to disk IFF they are in the scratch file's directory or a subdirectory thereof
#!/usr/bin/env ruby
require '[..]/scratch_file.rb'
if (file_name = ENV['TM_FILEPATH']) && File.extname(file_name) == ".scratch"
ScratchFile.new(file_name).write!
end
@endash
endash / gist:ea75a61c90de30a4bb73
Created June 5, 2015 20:39
Instantiate a view from a nib/xib in Swift, with the current API
extension NSView {
class func instantiateViewFromNib<T>(named nibName: String, inBundle bundle: NSBundle = NSBundle.mainBundle()) -> T? {
var objects : NSArray?
if bundle.loadNibNamed(nibName, owner: nil, topLevelObjects: &objects) {
if let objects = objects {
for object in objects {
if let object = object as? T {
return object
sessionLength: function(key, value) {
if(value !== undefined) {
this.writeAttribute('sessionLength', value)
} else {
var sl = this.readAttribute('sessionLength') ;
if(sl > 0)
return sl;
return '0';
}