Skip to content

Instantly share code, notes, and snippets.

View dcalhoun's full-sized avatar

David Calhoun dcalhoun

View GitHub Profile

ember-cli test

testem.json

{
  "framework": "qunit",
  "cwd": "dist",
  "test_page": "tests/index.html",
}
model Rating < ActiveRecord::Base
VALUES = { 0 => 'Worst', 1 => 'Good', 2 => 'Best' }
validate :value, :in => VALUES.keys
end
@joewest
joewest / didRequestRange.js
Created January 13, 2012 20:14
Ember.PaginationSupport
App.collectionController = Em.ArrayProxy.create(Ember.PaginationSupport, {
content: [],
fullContent: App.store.findAll(App.Job),
totalBinding: 'fullContent.length',
didRequestRange: function(rangeStart, rangeStop) {
var content = this.get('fullContent').slice(rangeStart, rangeStop);
this.replace(0, this.get('length'), content);
}
});
@dcalhoun
dcalhoun / spin-jquery.js
Created August 7, 2012 15:58
Spin.js jQuery Function
jQuery.fn.spin = (opts) ->
if opts != false
opts =
className: 'js-spinner'
lines: 13
length: 5
width: 3
radius: 7
speed: 1.2
trail: 50
@toranb
toranb / filtersortpagemixin.js
Created September 24, 2012 02:37
filter/sort/pagination mixin for ember.js
var get = Ember.get;
/**
* @extends Ember.Mixin
*
* Implements common filter / sort / pagination behavior for array controllers
* */
Ember.FilterSortSliceMixin = Ember.Mixin.create({
filterBy: '',
@toranb
toranb / half_baked_pagination.js
Created January 1, 2013 23:59
A half baked ember.js pagination solution using the v2 router api
PersonApp = Ember.Application.create();
PersonApp.SearchField = Ember.TextField.extend({
keyUp: function(e) {
var search = this.get('value');
this.get('controller.target').send('searchUsers', {match:search});
}
});
PersonApp.PersonView = Ember.View.extend({
templateName: 'person',
@bval
bval / .htrouter.php
Created February 19, 2013 21:33
This is a router for Drupal and other PHP apps that rely on mod_rewrite rules for "clean URLs" so that those same apps can be run under PHP 5.4's built-in webserver which doesn't support mod_rewrite.
<?php
/**
* @file
* The router.php for clean-urls when use PHP 5.4.0 built in webserver.
*
* Usage:
*
* php -S localhost:3000 .htrouter.php
*
*/
// just the assignments app, when server does routing
render(<AssignmentsApp params={SERVER_PARAMS}/>, el)
// just the courses app, same AssignmentsApp when server routed
render((
<Router>
<Route path={SERVER_BASE_URL} component={CoursesApp}>
<IndexRoute component={CourseDashboardApp}>
<Route path="assignments" component={AssignmentsApp}>
</Route>
import React, { Component } from 'react'
import logo from './logo.svg'
import './App.css'
import { Route, Link, Redirect } from './Zero'
const paths = [ 'one', 'two', 'three' ]
class App extends Component {
render() {
@jchild3rs
jchild3rs / gist:470be49a4bc4caf3ca8a
Last active April 8, 2020 15:54
Hologram Gulp Plugin
/*
// Usage:
gulp.task('docs', function(cb) {
gulp.src('path/to/your/src')
.pipe(hologram(cb));
});
*/
var gulp = require('gulp'),
notify = require('gulp-notify'),