Skip to content

Instantly share code, notes, and snippets.

View edgar's full-sized avatar

Edgar Gonzalez edgar

View GitHub Profile
module InheritsFromHash
def select(*args, &block)
dup.tap { |hash| hash.select!(*args, &block) }
end
def reject(*args, &block)
dup.tap { |hash| hash.reject!(*args, &block) }
end
end
@edgar
edgar / net-http-debug.rb
Created January 13, 2016 01:13 — forked from ahoward/net-http-debug.rb
a simple way to debug tons of libs that use ruby's net/http
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
@edgar
edgar / single_object_and_array.rb
Created April 7, 2016 02:24
Handling everything as an Array instead of having conditional
Array(1)
=> [1]
Array([1,2])
=> [1,2]
Array(nil)
=> []
[*1]
=> [1]
[*[1,2]]
=> [1,2]
@edgar
edgar / app.yml
Last active April 9, 2016 16:37
Initial docker-compose for Sinatra app accessing ElasticSearch
version: '2'
services:
search:
build: ../
volumes:
- ../:/app
ports:
- "4567:4567"
@edgar
edgar / Makefile
Last active April 9, 2016 16:50
Original makefile for docker sinatra + elasticsearch
IMAGE_NAME := "foo"
docker-build:
@(docker build -t $(IMAGE_NAME) -f Dockerfile .)
test: docker-build
@(docker-compose -f dockercompose/test.yml up -d)
@(docker-compose -f dockercompose/test.yml run search bash -c "rspec")
@(docker-compose -f dockercompose/test.yml down)
@edgar
edgar / Makefile
Created April 9, 2016 16:51
Makefile with sleeo
IMAGE_NAME := "foo"
docker-build:
@(docker build -t $(IMAGE_NAME) -f Dockerfile .)
test: docker-build
@(docker-compose -f dockercompose/test.yml up -d)
@(docker-compose -f dockercompose/test.yml run search bash -c "sleep 15; rspec")
@(docker-compose -f dockercompose/test.yml down)
@edgar
edgar / Makefile
Created April 9, 2016 16:59
Docker compose and makefile using docker-wait
IMAGE_NAME := "foo"
docker-build:
@(docker build -t $(IMAGE_NAME) -f Dockerfile .)
test: docker-build
@(docker-compose -f dockercompose/test.yml up -d)
@(docker-compose -f dockercompose/test.yml run wait)
@(docker-compose -f dockercompose/test.yml run search bash -c "rspec")
@(docker-compose -f dockercompose/test.yml down)
set :logging, true
# NewRelic rpm
# agent_logger.rb#L134-L136
def wants_stdout?
::NewRelic::Agent.config[:log_file_path].upcase == "STDOUT"
end
# The newrelic agent generates its own log file to keep its logging
# information separate from that of your application. Specify its
# log level here.
log_level: 'error'
# Optionally set the path to the log file This is expanded from the
# root directory (may be relative or absolute, e.g. 'log/' or
# '/var/log/') The agent will attempt to create this directory if it
# does not exist.
# log_file_path: 'log'