Skip to content

Instantly share code, notes, and snippets.

@mansona
mansona / parseDuration.js
Created August 22, 2011 13:50 — forked from sj26/parseDuration.js
Parses a natural duration string into seconds.
View parseDuration.js
// Try to be as sensible as possible about parsing durations
function parseDuration(duration) {
// .75
if (match = /^\.\d+$/.exec(duration)) {
return parseFloat("0" + match[0]) * 3600;
// 4 or 11.75
} else if (match = /^\d+(?:\.\d+)?$/.exec(duration)) {
return parseFloat(match[0]) * 3600;
// 01:34
} else if (match = /^(\d+):(\d+)$/.exec(duration)) {
@mansona
mansona / app.js
Created December 3, 2012 17:15
Zombie Basic Example
View app.js
var zombie = require("zombie");
var assert = require("assert");
zombie.debug = true;
var browser = new zombie();
browser.visit("http://google.com/")
.then(function(){
assert.equal(browser.statusCode, 401);
@mansona
mansona / statusCodes.js
Created December 4, 2012 11:57
Mocha Zombie exception thrown on 401 status code
View statusCodes.js
var expect = require('expect.js'),
Browser = require('zombie');
var browser = new Browser({waitDuration: 1500});
describe('Status Codes', function(){
this.timeout(2000);
it('Unauthorized', function(done){
View gist:4502560
// Version: v1.0.0-pre.2-291-g4785901
// Last commit: 4785901 (2013-01-05 18:57:16 +0100)
(function() {
/*global __fail__*/
/**
Ember Debug
View ember-working.js
// Version: v1.0.0-pre.2-291-g4785901
// Last commit: 4785901 (2013-01-05 18:57:16 +0100)
(function() {
/*global __fail__*/
/**
Ember Debug
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Model Test',
model() {
return this.store.findAll('meetup')
}
});
@mansona
mansona / controllers.application.js
Last active April 25, 2018 09:45
May I ask a Question - 001
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
filteredModel: Ember.computed('filterValue', 'model.@each.name', function() {
if(Ember.isEmpty(this.get('filterValue'))) {
return this.model;
}
return this.model.filter((test) => test.get('name') === this.get('filterValue'));
View components.edit-instance.js
import Ember from 'ember';
export default Ember.Component.extend({
store: Ember.inject.service(),
router: Ember.inject.service(),
actions: {
createInstance() {
let newInstance = this.get('store').createRecord('instance');
this.set('instance', newInstance);
},
@mansona
mansona / adapters.application.js
Last active September 19, 2018 12:28
Ember Routing Issue
View adapters.application.js
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
host: 'http://localhost:3000/api'
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appData : {
"title" : "First Title",
"subtitles": [
{
"AMount":"4343"
},
{