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
| # frozen_string_literal: true | |
| # Heap Dump Signal Trap | |
| # | |
| # Send CONT signal to the process to trigger a heap dump. | |
| # | |
| # Usage: | |
| # kill -CONT <pid> | |
| # | |
| # Output: |
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
| https://gist.github.com/nicole-ashley/242da6a653faa768d52d5be324f9ee60 |
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
| # same as find_in_batches but with order support | |
| # @usage InOrderedBatches.new(User.where(...), :updated_at, '2015-01-01'.to_time).each{|records| ... } | |
| class InOrderedBatches | |
| def initialize(scope, key, start, batch_size: 1000) | |
| @scope = scope.order("#{key}, id").limit(batch_size) | |
| @key = key | |
| @value = start | |
| @batch_size = batch_size | |
| 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
| current_account.items.update_all(['enabled = (SELECT id IN (?))', Array(params[:ids])]) |
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
| # Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler | |
| if defined?(::Bundler) | |
| $LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib") | |
| 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
| #!/bin/sh | |
| # test input with jq, if ok then show input, otherwise exit with non 0 exit code | |
| # echo '{"success": true}' | jq -e '.success | select(. == true)' # => {"success": true} | |
| # echo '{"success": false}' | jq -e '.success | select(. == true)' # => exit code non 0 | |
| input=`cat`; | |
| if echo "$input" | jq -e "$1" > /dev/null ; then | |
| echo "$input" |
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
| silence_warnings do | |
| ActionDispatch::Request::LOCALHOST = (ActionDispatch::Request::LOCALHOST + ['192.168.0.1']).freeze | |
| end | |
| ActionController::Base.module_eval do | |
| def show_detailed_exceptions? | |
| request.local? | |
| 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
| FROM crystallang/crystal:0.34.0 as builder | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends build-essential \ | |
| apt-transport-https curl ca-certificates gnupg2 apt-utils | |
| RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \ | |
| && apt-get install -y nodejs | |
| RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ |
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 to_permit_rule(h) | |
| scalar = [] | |
| complex = {} | |
| h.each do |k,v| | |
| if v.is_a? Array | |
| complex[k.to_sym] = [] | |
| elsif v.is_a? Hash | |
| if v.keys.all?{|vk| vk =~ /\A\d+\z/ } | |
| complex[k.to_sym] = to_permit_rule(v.values.first) | |
| else |
NewerOlder