Some OAuth providers (like Google), limit what hosts can be used for redirect URIs. This can be problematic when using a hostname-based local development server (like Pow or Invoker). This very simple redirection server can be used to work around this restriction.
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 'dry/operation' | |
require 'dry/operation/extensions/active_record' | |
module FixTransactionNotReturningFailure | |
def included(klass) | |
class_exec(@connection, @options) do |default_connection, options| | |
klass.define_method( | |
:transaction, | |
) do |connection = default_connection, **opts, &steps| | |
intercepted_success = nil |
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
# PostgreSQL’s question mark (`?`) jsonb operator can pose an issue when using | |
# Active Record, since `?` is used to denote bind variable substitution. One | |
# way to work around this is to use named bind variable substitution with a | |
# hash instead. | |
Entity.where('metadata ? :key', key: 'profile_url') |
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 StatusLine | |
MAX_LENGTH = 72 | |
FORMAT = "[ ] %.#{MAX_LENGTH}s" | |
BUSY = 'BUSY' | |
DONE = 'DONE' | |
FAIL = 'FAIL' | |
COLOR="\033[%s;%sm" |
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
defmodule AppWeb.CapitalizeHeaders do | |
def init(stream_id, req, opts) do | |
:cowboy_stream_h.init(stream_id, req, opts) | |
end | |
def data(stream_id, is_fin, data, state) do | |
:cowboy_stream_h.data(stream_id, is_fin, data, state) | |
end | |
def info(stream_id, {:response, _status, headers, _body} = info, state) do |
Instagram doesn’t make it easy to enable 2FA unless you’re using Google Authenticator or Duo Security. If you want to use it with another authenticator app—like 1Password—this script will generate the QR code you need to easily set that up.
The Ruby script makes use of Bundler’s inline functionality and will automatically install the depenedncies as system gems.
ruby qr.rb
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 'rspec/core' | |
css = %( | |
<style> | |
html { font-size: 50%; } | |
.unknown, .passed, .pending, .failed { display: inline-block; height: 1rem; width: 1rem; } | |
.unknown { background-color: #999; } | |
.pending { background-color: #FC0; } | |
.passed { background-color: #3F3; } | |
.failed { background-color: #F33; } |
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
ENV['COMPOSE_PROJECT_NAME'] ||= 'citus' | |
ENV['MASTER_EXTERNAL_PORT'] ||= '5433' | |
file 'docker-compose.yml' do | |
`curl -L https://raw.githubusercontent.com/citusdata/docker/master/docker-compose.yml > docker-compose.yml` | |
end | |
namespace :citus do | |
desc 'Start the Citus cluster' | |
task :up, [:workers] => 'docker-compose.yml' do |_task, args| |
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
RSpec.shared_context 'Global ID', :global_id do | |
def global_id_instance_double(doubled_class, stubs={}) | |
instance_double(doubled_class, stubs) | |
.extend(GlobalID::Identification) | |
.tap { |double| | |
unless double.respond_to?(:id) | |
allow(double).to receive(:id).and_return(double.object_id) | |
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 RenderingHelper | |
# Override Rails' #render helper to fix an issue with it not honoring objects | |
# with #to_partial_path definitions that return absolute paths, which is | |
# problematic when rendering partials within a namespaced controller. | |
def render(options={}, locals={}, &block) | |
return super unless options.respond_to?(:to_partial_path) | |
object = options | |
path = object.to_partial_path |
NewerOlder