(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.
| # The $provide service is used to override an injected dependency | |
| # Bad - results in Error: [ng:areq] Argument 'fn' is not a function, got Object | |
| module 'someModule', ($provide) -> | |
| $provide.value "SomeService", SomeMock | |
| # Good | |
| module 'someModule', ($provide) -> | |
| $provide.value "SomeService", SomeMock | |
| null |
| require 'jruby/profiler' | |
| profile_data = JRuby::Profiler.profile do | |
| require 'sinatra' | |
| end | |
| profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data) | |
| profile_printer.printProfile(STDOUT) |
| # Original Rails controller and action | |
| class EmployeesController < ApplicationController | |
| def create | |
| @employee = Employee.new(employee_params) | |
| if @employee.save | |
| redirect_to @employee, notice: "Employee #{@employee.name} created" | |
| else | |
| render :new | |
| end |
(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.
Once upon a time…
I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).
I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).
It seems inevitable to throw Domain Driven Design (DDD) in to the mix.
| # Close Xcode & the iOS Simulator | |
| # http://stackoverflow.com/a/30940055 | |
| # Remove any old runtimes from this directory. | |
| cd /Library/Developer/CoreSimulator/Profiles/Runtimes | |
| # e.g. | |
| sudo rm -rf iOS\ 8.1.simruntime | |
| # http://stackoverflow.com/a/11790983 | |
| # Remove the download receipts for simulators you don't need anymore. |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.