A minimalist masonry function
mason(containerElement,brickElement,brickWidth,brickHeight)
Only works with one size of brick.
The only advantage of using this over using inline-block elements is that you can use css transitions.
| enum DateStride { | |
| case year(Int) | |
| case month(Int) | |
| case day(Int) | |
| var component: Calendar.Component { | |
| switch self { | |
| case .year(_): | |
| return .year | |
| # app/validators/scss_format_validator.rb | |
| class ScssFormatValidator < ActiveModel::EachValidator | |
| def validate_each(object, attribute, value) | |
| begin | |
| # Attempt to parse SCSS | |
| Sass::Engine.new(value, syntax: :scss).render | |
| rescue Exception => e | |
| # Add error if parsing fails | |
| object.errors.add(attribute, :invalid_scss, error: e.inspect) | |
| end |
| # Replace relevant section in config/initializers/devise.rb | |
| # ==> ORM configuration | |
| # Load and configure the ORM. Supports :active_record (default) and | |
| # :mongoid (bson_ext recommended) by default. Other ORMs may be | |
| # available as additional gems. | |
| require 'devise/orm/mongomodel' |
A minimalist masonry function
mason(containerElement,brickElement,brickWidth,brickHeight)
Only works with one size of brick.
The only advantage of using this over using inline-block elements is that you can use css transitions.
| var Model = Backbone.Model.extend({ | |
| /** | |
| * Override main attribute getter to handle mutators. | |
| * Looks for an object on the model called 'mutators', keyed by key name, | |
| * with values of either the getter function or an object like: | |
| * { get: function() {}, set: function() {} } | |
| */ | |
| get: function(attr) { | |
| var val, |
| $ = function (document) { | |
| var element = Element.prototype, | |
| nodeList = NodeList.prototype, | |
| foreach = [].forEach; | |
| element.on = function () { | |
| element.addEventListener.apply(this, arguments); | |
| return this; | |
| }; | |
I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").
Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):
# minitest/spec.rb
module MiniTest::Expectations| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
| # before this file is loaded, a locale should be set: | |
| # | |
| # In a browser environment, you can use: | |
| # ```<script>__locale='en';</script>``` | |
| # | |
| # In a server environment (specifically node.js): | |
| # ```global.__locale = 'en';``` | |
| # normalize in-app locale string to "en" or "de-AT" | |
| parts = @__locale.split('-') |
| /* | |
| This overlay provides a 'liquid' mode to the excellent CodeMirror editor (http://codemirror.net/). | |
| Add something like this to your CSS: | |
| .cm-liquid-tag { | |
| color: #32273f; | |
| background: #ead9ff; | |
| } | |
| .cm-liquid-variable { |