Skip to content

Instantly share code, notes, and snippets.

View edgar's full-sized avatar

Edgar Gonzalez edgar

View GitHub Profile
@edgar
edgar / iterm2-solarized.md
Created April 24, 2016 01:03 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX)

Solarized

@edgar
edgar / getBlockLists.sh
Created April 24, 2016 13:19 — forked from johntyree/getBlockLists.sh
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
@edgar
edgar / pg_install_error_mac.txt
Created May 22, 2016 17:18
install error for pg gem in OS X
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
...
Can't find the 'libpq-fe.h header
...
$ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
v1 = '0.3.2'
v2 = '0.10.1'
a1 = v1.split('.').map{|v| v.to_i}
a2 = v2.split('.').map{|v| v.to_i}
(a1 <=> a2) < 0 # v1 < v2
=> true
(a1 <=> a2) > 0 # v1 > v2
=> false
v1 = '0.3.0'
v2 = '0.3'
a1 = v1.split('.').map{|v| v.to_i}
a2 = v2.split('.').map{|v| v.to_i}
(a1 <=> a2) == 0 # v1 == v2
=> false
(a1 <=> a2) > 0 # v1 > v2
=> true
Gem::Version.new('0.3.2') < Gem::Version.new('0.10.1')
=> true
Gem::Version.new('0.3.0') == Gem::Version.new('0.3')
=> true
@edgar
edgar / test.rb
Created February 9, 2017 14:59
config/environment/test.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
...
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = true
...
end
require 'rails_helper'
RSpec.describe 'My API' do
let(:request) do
lambda do
get '/my_api/value-cannot-be-routed-due-to-route-constraints'
end
end
context 'when action_dispatch.show_exceptions is false (default behavior on test env)' do
# frozen_string_literal: true
module ErrorResponses
def rails_respond_without_detailed_exceptions
env_config = Rails.application.env_config
original_show_exceptions = env_config['action_dispatch.show_exceptions']
original_show_detailed_exceptions = env_config['action_dispatch.show_detailed_exceptions']
env_config['action_dispatch.show_exceptions'] = true
env_config['action_dispatch.show_detailed_exceptions'] = false
yield
ensure