(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(function(root, factory) { | |
if (typeof define === 'function' && define.amd) { | |
define(['backbone.marionette', 'backbone.radio', 'underscore'], factory); | |
} else if (typeof exports !== 'undefined') { | |
module.exports = factory(require('backbone.marionette'), require('backbone.radio'), require('underscore')); | |
} else { | |
factory(root.Backbone.Marionette, root.Backbone.Radio, root._); | |
} | |
}(this, function(Marionette, Radio, _) { | |
'use strict'; |
Photos = {} | |
class Photos.App | |
constructor: -> | |
@gui = new Photos.Gui($("#photos-list")) | |
@backend = new Photos.Backend() | |
start: => | |
@backend.fetchPhotos() | |
.done( |
# From http://railscasts.com/episodes/287-presenters-from-scratch?view=comments | |
# I added spec/support/presenters.rb file and I require it from spec_helper.rb: | |
RSpec.configure do |config| | |
config.include ActionView::TestCase::Behavior, example_group: {file_path: %r{spec/presenters}} | |
config.include RSpec::Rails::Matchers::RenderTemplate, example_group: {file_path: %r{spec/presenters}} | |
end | |
# Example: | |
presenter.method.should render_template('blah/_blah') |
&:hover { | |
position: relative; | |
&:before { | |
content: " "; | |
height: 24px; | |
width: 24px; | |
left: 0; | |
top: 0; | |
position: absolute; |
class ApplicationController < ActionController::Base | |
# stuff | |
private | |
# These groups are equivalent: | |
# | |
# render action: :new, locals: { item: x } | |
# render :new, locals: { item: x } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.
TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/
For async JavaScript file requests, we have the async
attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).
Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:
#!/usr/bin/env ruby | |
# From: http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html | |
require 'capybara' | |
require 'capybara/poltergeist' | |
require 'csv' | |
require 'gdbm' | |
class NickBot | |
include Capybara::DSL |
// Brightness math based on: | |
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx | |
$red-magic-number: 241; | |
$green-magic-number: 691; | |
$blue-magic-number: 68; | |
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number; | |
@function brightness($color) { | |
// Extract color components |
Rails as it has never been before :) | |
Rails 3 AntiPatterns, Useful snippets and Recommended Refactoring. | |
Note: Some of them are collected from different online resources/posts/blogs with some tweaks. |