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
| const dgram = require('dgram') | |
| const assert = require('assert'); | |
| const SERVER_IP_ADDRESS = '127.0.0.1' | |
| const SERVER_PORT = 6789 | |
| function MonkeyBusinessTester(pipe) { | |
| this.pipe = pipe | |
| } |
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 'active_support' | |
| require 'active_support/core_ext/object/blank' | |
| def fetch(key, default: nil, scope: :rails) | |
| value = fetch_with_scope(key, scope, default: default) | |
| value.presence || raise(KeyError, "value for key #{key} cannot be blank") | |
| end | |
| def fetch_with_scope(key, scope, default: nil) | |
| ENV.fetch("#{scope.to_s.upcase}_#{key}") do |
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
| docker run --rm --env-file .env busybox sh -c "printf \$$1" |
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
| Rails.application.routes.draw do | |
| # ... | |
| get 'sidekiq-health' => SidekiqHealthMiddleware | |
| # ... | |
| 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
| instance_id = Net::HTTP.get URI('http://169.254.169.254/latest/meta-data/instance-id') | |
| instance = ec2.instance(instance_id) | |
| name = instance.tags.find { |tag| tag.key == 'tag:Name' }.value | |
| instances = ec2.describe_instances(filters:[ | |
| { name: 'instance-state-name', values: ['running'] }, | |
| { name: 'tag:Environment', values: [Rails.env] }, | |
| { name: 'tag:Name', values: [ENV['EC2_NAME_TAG']] }, | |
| ]) |
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 check(value) | |
| uri = URI.parse(value) rescue nil | |
| case uri | |
| when URI::HTTP, URI::HTTPS | |
| uri.host && true | |
| else | |
| false | |
| 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
| function purty(object, indent = 2) { | |
| return JSON.stringify(object, null, indent) | |
| } | |
| function pp(object, ...rest) { | |
| console.log(purty(object, ...rest)) | |
| } |
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
| # Sort files by line length | |
| find spec -name *_spec.rb -type f -exec wc -l {} + | sort -rn |
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
| functionName = (func) -> | |
| stringified = func.toString() | |
| name = _.words(stringified.slice(0, stringified.indexOf('(')))[1] || '~anonymous~' | |
| params = _.words(stringified.match(/\(.*\)/)[0]).join(', ') | |
| "#{name} (#{params}) { ... }" | |
| getCallstack = (caller) -> | |
| caller = arguments.callee.caller if arguments.length == 0 | |
| if caller? | |
| try |