Skip to content

Instantly share code, notes, and snippets.

View kjlape's full-sized avatar
🤝
nice to meet you

Kaleb Lape kjlape

🤝
nice to meet you
View GitHub Profile
@kjlape
kjlape / monkey-business-client.js
Created March 3, 2018 18:01
Pure node.js Monkey Business client
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
}
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
docker run --rm --env-file .env busybox sh -c "printf \$$1"
Rails.application.routes.draw do
# ...
get 'sidekiq-health' => SidekiqHealthMiddleware
# ...
end
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']] },
])
@kjlape
kjlape / monkey_biz.md
Last active January 29, 2018 18:48
Monkey Biz Related Repos
def check(value)
uri = URI.parse(value) rescue nil
case uri
when URI::HTTP, URI::HTTPS
uri.host && true
else
false
end
end
function purty(object, indent = 2) {
return JSON.stringify(object, null, indent)
}
function pp(object, ...rest) {
console.log(purty(object, ...rest))
}
@kjlape
kjlape / fun.sh
Created September 14, 2017 19:44
Fun
# Sort files by line length
find spec -name *_spec.rb -type f -exec wc -l {} + | sort -rn
@kjlape
kjlape / get-callstack.coffee
Created September 6, 2017 21:08
Stack Extractor for old IE/Safari
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