Skip to content

Instantly share code, notes, and snippets.

<div ng-switch on="{{type}}">
<div ng-switch-where="X" ng-include="X-template.html"></div>
<div ng-switch-where="Y" ng-include="Y-template.html"></div>
</div>
<script type="text/x-template" id="X-template.html">
</script>
<script type="text/x-template" id="Y-template.html">
</script>
%button{ng: {click: 'comments.addComment()'}, tbd: {require: {invitee: 'true'}}}
if (typeof window.EDH === 'undefined') {
window.EDH = {};
}
if (typeof window.EDH.Donation === 'undefined') {
window.EDH.Donation = {};
}
var Donation = window.EDH.Donation;
braintree.onSubmitEncryptForm($form, function(event) {
disableSubmitButton(true);
event.preventDefault();
var payment = Payment($form.serialize());
payment.save(function() {
// Success
window.location = payment.thank_you_url;
}, function() {
// Failure
@tatey
tatey / 0_features.html
Created December 20, 2013 01:44
Mixing rails and angular together with lots of little angular apps. Each app has its own classes (Controllers, resources, etc) and is used like a component on any page that needs it.
<div ng-controller="feature.featureController" ng-init="init({projectId: <%= project.id %>})">
<div class="animate-appear" ng-cloak ng-show="features.$resolved">
<div class="cell cell-item cell-form-inline cell-edge-top" ng-repeat="feature in features">
<div class="row" ng-hide="isEditing($index)">
<div class="col-md-4">
<div class="cell-form-inline-text">
{{ feature.name }}
</div>
</div>
<div class="col-md-8 text-right">
@tatey
tatey / new.html.haml
Created December 13, 2013 00:13
Possible solution to bundling templates with AngularJS and Middleman.
%script{type: 'text/x-template', id: 'template-dates-new'}
= partial 'templates/dates/new'
@tatey
tatey / application_controller.rb
Created December 10, 2013 23:21
Splitting out authentication from the controller into a distinct class. Easier to unit test and minimises the footprint in ApplicationController.
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
delegate :user, :user=, to: :authentication, prefix: 'current'
delegate :sign_in, :signed_in?, :sign_out, to: :authentication
helper_method :current_user
helper_method :signed_in?
private
@tatey
tatey / gist:7867043
Last active December 30, 2015 18:19
You *can* have nested describes in Jasmine.
describe('util.Config', function() {
describe('.openerType', function() {
var Config, Device;
beforeEach(function() {
Device = {};
Config = theBestDay.require('widget.Config', {'util.Device': Device});
});
describe('desktop', function() {
module Designate
# Declare an instance method to become the designated method for
# that class. Arguments are correctly passed to instance method
# and initializer.
#
# Example with a desginated method that takes no arguments:
#
# class Generator
# extend Designate
#
[
{
"id": "4d954b06a243a5684965b473",
"provider": "foursquare",
"name": "Hot Dog Vendor on corner of John and Front",
"address": "John Street, Sydney, NSW, AU",
"lat": 40.7001719,
"lng": -74.000928
}
]