Skip to content

Instantly share code, notes, and snippets.

View RobinDaugherty's full-sized avatar

Robin Daugherty RobinDaugherty

View GitHub Profile
@RobinDaugherty
RobinDaugherty / founding_eu_partner.html
Created November 3, 2015 20:53
Ahalogy Partner Badges
<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>
# 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
@RobinDaugherty
RobinDaugherty / app.controllers.projectname_page_controller.rb
Created December 22, 2015 18:54
ember_cli_deploy_redis_ruby v1.0.0 Rails controller implementation
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
@RobinDaugherty
RobinDaugherty / github_api_issues.rb
Last active December 23, 2015 02:49
Close Github issues with a certain label
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')
@RobinDaugherty
RobinDaugherty / gist:3c92f7427794b7ffa22a
Last active January 4, 2016 17:25
Install php-cgi with Homebrew
brew tap josegonzalez/homebrew-php
brew tap homebrew/dupes
brew install --enable-cgi php56
@RobinDaugherty
RobinDaugherty / create_gadgets.rb
Last active October 19, 2022 14:22
ActiveRecord attribute serializer Hashie::Mash stored as JSON in Postgres
class CreateGadgets < ActiveRecord::Migration
def change
create_table "gadgets" do |t|
t.json "info"
end
end
end
@RobinDaugherty
RobinDaugherty / create_gadgets.rb
Created February 1, 2016 04:20
ActiveRecord attribute serializer Hashie::Mash stored as a JSON string in Postgres
class CreateGadgets < ActiveRecord::Migration
def change
create_table "gadgets" do |t|
t.string "info"
end
end
end
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
  1. check the cache and return the value if found
  2. 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
    1. if it was in the cache, return the item
    2. if not in the cache
    3. if there's room for another in-flight request 1. add a condition variable to the list of in-flight requests
  3. if the ID was already in flight, wait on the condition variable we got for it
  4. when the condition variable signals, return the item from the cache
@RobinDaugherty
RobinDaugherty / rubygems-failure-to-connect.txt
Created February 11, 2016 21:43
Rubygems server failing
$ 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