This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global angular, Ladda */ | |
(function(module, $) { | |
'use strict'; | |
module.directive('datepicker', function() { | |
return { | |
link: function postLink(scope, element, attrs) { | |
var today = new Date(); | |
var minYear = 1900; | |
var maxYear = today.getFullYear(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var UserSelect = React.createClass({ | |
_changed: function(event) { | |
var value = this.refs.box.getDOMNode().value; | |
this.props.onSelect(value); | |
}, | |
render: function() { | |
var items = this.props.items.map(function(item) { | |
return ( | |
<option value={item}>{item}</option> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./spec/support/save_tracker.rb | |
module SaveTracker | |
extend ActiveSupport::Concern | |
included do | |
class_attribute :_save_tracker_ | |
self.reset_save_tracker! | |
end | |
module ClassMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Timer extends React.Component { | |
constructor(props) { | |
super(props) | |
this._interval = null; | |
this.state = { | |
ticks: 0 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// http://eslint.org/docs/rules/ | |
"ecmaFeatures": { | |
"arrowFunctions": false, // enable arrow functions | |
"binaryLiterals": false, // enable binary literals | |
"blockBindings": false, // enable let and const (aka block bindings) | |
"classes": false, // enable classes | |
"defaultParams": false, // enable default function parameters | |
"destructuring": false, // enable destructuring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
// scan our ajax response for replaceable content blocks then update the HTML | |
var updateContent = function(content) { | |
var $contentKeyElements = $(content).filter('[data-content-key]'); | |
$contentKeyElements.each(function() { | |
var node = $(this); | |
var key = node.attr('data-content-key'); | |
$('[data-content-key=' + key + ']').replaceWith(node); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allow strings to number_to_currency style comma seperate | |
String.prototype.commafy = function () { | |
return this.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) { | |
return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,"); | |
}); | |
} | |
// Convenience method for numbers | |
Number.prototype.commafy = function () { | |
return String(this).commafy(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# your applications main layout file (app/views/layouts/application.html.erb?) | |
# I put this after the normal stylesheet call, so our theme can override what we want instead of the entire stylesheet | |
<% if theme = request.env['rails.theme'] %> | |
<%= stylesheet_link_tag "themes/#{theme}", :media => :all %> | |
<% end %> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra_query_caching_demo' | |
run Demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tempfile' | |
# TODO: do some pre-comparison on a and b so we can skip creating temp files and all that jazz. | |
# NOTE: this is so ghetto ;) | |
module Diffable | |
def diff(b, options = {}) | |
Diff.new(self, b, options).diff | |
end | |
end |