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
#!/usr/bin/env bash | |
function get_headphones_index() { | |
echo $(pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}') | |
} | |
function get_headphones_mac_address() { | |
local temp=$(pacmd list-cards | grep bluez_card -C20 | grep 'device.string' | cut -d' ' -f 3) | |
temp="${temp%\"}" | |
temp="${temp#\"}" |
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
Article: https://github.com/puma/puma/blob/master/docs/systemd.md | |
#1 nano /etc/systemd/system/puma.service | |
#2 paste from puma.service | |
Commands: | |
# After installing or making changes to puma.service | |
systemctl daemon-reload | |
# Enable so it starts on boot | |
systemctl enable puma.service |
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
# from gitlab/spec/support/matchers/exceed_query_limit.rb | |
RSpec::Matchers.define :exceed_query_limit do |expected| | |
supports_block_expectations | |
match do |block| | |
@subject_block = block | |
actual_count > expected_count + threshold | |
end | |
failure_message_when_negated do |actual| |
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
# Usage: | |
# | |
# class Mail | |
# include SimpleStateMachine | |
# | |
# self.initial_state = 'unread' | |
# self.transitions_map = { | |
# read: {from: 'unread', to: 'read'}, | |
# unread: {from: 'any', to: 'unread'}, | |
# delete: {from: 'any', to: 'deleted'}, |
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 SimpleRailway | |
class Result | |
attr_accessor :success, :data | |
def initialize(success, data) | |
@success = success | |
@data = data | |
end | |
def success?; !!success; end | |
def failure?; !success?; 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
# FOR BUSY JOBS | |
# take the process_id from the /busy page in sidekiq and kill the longest running one. | |
workers = Sidekiq::Workers.new | |
long_process_id = 'integration.3:4:71111aaa111' # Eg: 'integration.3:4:71d1d7f4ef5a' | |
workers.each do |process_id, thread_id, work| | |
process = Sidekiq::Process.new('identity' => process_id) | |
process.stop! if process_id == long_process_id | |
end | |
# FOR SCHEDULED JOBS |
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
1. Change rails version in Gemfile | |
> gem 'rails', '~> 5.1', '>= 5.1.4' | |
2. Remove Gemfile.lock | |
> git rm Gemfile.lock | |
3. Run bundle install command | |
> bundle install --jobs=5 | |
4. Run rails' app update to apply changes to app |
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
# While having issues with to_partial_path on a view model giving inconsistent results under differing name spaces of controllers | |
# I use the below to see that the look up path and view paths were on an controller and modify. | |
# I've never put the below into production. This is merely something I found while experimenting. | |
# To sort my issue I used the prefixes avaialable and changed name spacing to give correct behaviour | |
class SomeController < ApplicationController | |
# Prepending (or appending) the view path allows you to add the location of view files | |
before_filter :prepend_view_paths |
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :development
Then you'll want to rebuild your Docker container to install the gems
NewerOlder