This file contains hidden or 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
| select pid, application_name from pg_stat_activity; | |
| select pg_terminate_backend(<PID int>); |
This file contains hidden or 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::Matchers.define :have_field_value do |selector, value:| | |
| match do |page| | |
| page.find(selector).value == value | |
| end | |
| failure_message do | |
| <<-MESSAGE | |
| expected #{selector} to have value #{value}, but it was not. | |
| MESSAGE | |
| end |
This file contains hidden or 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 WithTranslation | |
| def initialize(delegate, translator) | |
| @delegate = delegate | |
| @translator = translator | |
| end | |
| def method_missing(method_name, *rest) | |
| translation = @translator.translate_attribute(@delegate, method_name) | |
| return translation if translation.present? |
This file contains hidden or 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 I18nHelper | |
| def i18n | |
| ChainableTranslation.new | |
| end | |
| class ChainableTranslation | |
| attr_reader :options | |
| def initialize(scopes = [], options = {}) | |
| @scopes = Array(scopes) |
This file contains hidden or 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
| FROM hashicorp/terraform:light | |
| MAINTANER "Kaleb Lape <[email protected]>" | |
| RUN apk add --update bash | |
| ENTRYPOINT bash -c 'find . -type f -name "*.tf" -print0 | xargs -0 -n 1 dirname | sort | uniq | xargs -t -n 1 terraform validate' |
This file contains hidden or 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
| #!/bin/sh | |
| # Modified from original implementation: | |
| # https://gist.github.com/liamcurry/2696512 | |
| # Requires ffmpeg with codec plugins | |
| # On Mac: | |
| # brew install ffmpeg --with-libvpx --with-theora --with-libogg --with-libvorbis --with-webp --with-rtmpdump --with-openh264 --with-fdk-aac | |
| # Output file for HTML5 video |
This file contains hidden or 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 StateHandlers | |
| class Base | |
| class_attribute :registered_states | |
| class_attribute :registered_events | |
| extended do | |
| registered_states = {} | |
| registered_events = Hash.new { |hash, key| hash[key] = { before: [], after: [] } } | |
| end |
This file contains hidden or 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 'spec_helper.rb' | |
| describe JobEnqueuer do | |
| it 'enqueues the jobs' do | |
| # Use matchers like 'a_value' in your enqueued assertions. | |
| assert_enqueued_with(job: UsefulJob, args: [resource, data, { option: a_value }]) do | |
| subject | |
| end | |
| end | |
| end |
This file contains hidden or 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
| ([headers = %i(some headers here)] + SomeModel.where(condition: :state).pluck(*headers)).each { |row| puts row.join ', ' }; nil |
This file contains hidden or 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
| def ephemeral_port | |
| unless @ephemeral_port | |
| tcp_server = TCPServer.new('localhost', 0) | |
| @ephemeral_port ||= tcp_server.addr[1] | |
| tcp_server.close | |
| end | |
| @ephemeral_port | |
| end |