- check the cache and return the value if found
- with mutex locked
1. if the ID is currently in flight, get its condition variable
2. if ID is not in flight, check the cache again for the item
- if it was in the cache, return the item
- if not in the cache
- if there's room for another in-flight request 1. add a condition variable to the list of in-flight requests
- if the ID was already in flight, wait on the condition variable we got for it
- when the condition variable signals, return the item from the cache
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
<a href="https://www.ahalogy.com/publishers/"><img src="//badge.ahalogy.com/img/founding_eu_partner.png" title="Ahalogy Founding EU Partner" alt="Ahalogy Founding EU Partner"></a> |
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
# Opens each model file alongside its corresponding spec file, even if the spec file doesn't yet exist. | |
# Waits for you to close the files before loading the next pair. | |
for i in app/models/**.rb; do | |
mate -w $i ${${i/app/spec}/.rb/_spec.rb} | |
done |
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 ProjectNamePageController < BaseEmberCliDeployController | |
def index | |
render_page('index.html') | |
end | |
# This is a page that is needed in our application for integration with PicMonkey. | |
# It is built in our ember-cli project and deployed alongside `index.html`. | |
def picmonkey_done | |
render_page('picmonkey-done.html') | |
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 'github_api' | |
github = Github.new( | |
oauth_token: 'fill-me-in', | |
auto_pagination: true, | |
) | |
# Returns ALL OPEN ISSUES. Learned the hard way that the `label` parameter does nothing here. | |
open_issues = github.issues.list(user: 'lemurheavy', repo: 'coveralls', state: 'open') |
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
brew tap josegonzalez/homebrew-php | |
brew tap homebrew/dupes | |
brew install --enable-cgi php56 |
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 CreateGadgets < ActiveRecord::Migration | |
def change | |
create_table "gadgets" do |t| | |
t.json "info" | |
end | |
end | |
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
class CreateGadgets < ActiveRecord::Migration | |
def change | |
create_table "gadgets" do |t| | |
t.string "info" | |
end | |
end | |
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
module Concerns | |
module HasOneAutoCreated | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def has_one_auto_created(association_name, options = {}) | |
has_one association_name, options | |
alias_method "existing_#{association_name}", association_name |
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
$ wget https://rubygems.org/gems/rake-10.5.0.gem | |
--2016-02-11 21:30:29-- https://rubygems.org/gems/rake-10.5.0.gem | |
Resolving rubygems.org (rubygems.org)... 54.186.104.15 | |
Connecting to rubygems.org (rubygems.org)|54.186.104.15|:443... connected. | |
HTTP request sent, awaiting response... 302 Moved Temporarily | |
Location: https://rubygems.global.ssl.fastly.net/gems/rake-10.5.0.gem [following] | |
--2016-02-11 21:30:30-- https://rubygems.global.ssl.fastly.net/gems/rake-10.5.0.gem | |
Resolving rubygems.global.ssl.fastly.net (rubygems.global.ssl.fastly.net)... 185.31.19.249, 185.31.18.249 | |
Connecting to rubygems.global.ssl.fastly.net (rubygems.global.ssl.fastly.net)|185.31.19.249|:443... connected. | |
HTTP request sent, awaiting response... 200 OK |