TIL attr_* methods are optomized.
class Whatever
def foo
@foo
end
attr_reader :bar
end
REQUIRE_DATA = {} | |
BUNDLED_GEMS = `bundle show | grep "*" | awk '{print $2}'`.split("\n").sort | |
require 'bigdecimal' | |
def require(name) | |
start = Time.now | |
ret = super | |
stop = Time.now | |
total = BigDecimal(stop-start, 6) | |
REQUIRE_DATA[name] = total if BUNDLED_GEMS.include?(name) |
// Noty - http://ned.im/noty/#/about | |
// Best in place - https://github.com/bernat/best_in_place | |
$(document).on('best_in_place:error', function (event, request, error) { | |
'use strict'; | |
// Display all error messages from server side validation | |
$.each(jQuery.parseJSON(request.responseText), function (index, value) { | |
if (typeof value === "object") { | |
value = index + " " + value.toString(); | |
} |
TIL attr_* methods are optomized.
class Whatever
def foo
@foo
end
attr_reader :bar
end
class CreateUserForm | |
include ActiveModel::Model | |
attr_accessor :email | |
attr_accessor :name | |
def initialize | |
@user = User.new | |
end | |
module Publisher | |
extend self | |
# delegate to ActiveSupport::Notifications.instrument | |
def broadcast_event(event_name, payload={}) | |
if block_given? | |
ActiveSupport::Notifications.instrument(event_name, payload) do | |
yield | |
end | |
else |
This is a collection of links, examples and rants about Presenters/Decorators in Rails.
The "Decorator" pattern slowly started gaining popularity in Rails several years ago. It is not part of core Rails, and there's many different interpretations about how it should work in practice.
Jay Fields wrote about it in 2007 (before he switched back to Java and then Clojure): http://blog.jayfields.com/2007/03/rails-presenter-pattern.html
Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.
For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.
But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.
SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil
(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.
Originally taken from here, cached as a gist so I can find it later. "Angolmois" is a music video game, that plays real BeatMania files, so it's a pretty full-featured game. At least, as full as you're gonna find in Rust from as long ago as it was started.
Angolmois Rust edition went through six different Rust releases without almost no change on the features, and the changes are as follows:
Here's what I did to get things working.
Yep, over at: https://developer.apple.com