Skip to content

Instantly share code, notes, and snippets.

View gregolsen's full-sized avatar

Inokentii (Kesha) Mykhailov gregolsen

View GitHub Profile
language: ruby
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
before_script:
- cp config/database.travis.yml config/database.yml
- RAILS_ENV=test bundle exec rake db:create db:migrate
notifications:
email:
- interstellar.team@railsware.com
@gregolsen
gregolsen / gist:5378320
Created April 13, 2013 13:01
simple way to get routes info
require 'rails/application/route_inspector'
all_routes = Rails.application.routes.routes.select { |r| r.defaults[:controller] =~ /api\/v1/ }
inspector = Rails::Application::RouteInspector.new
pp inspector.format(all_routes, 'api/v1/inboxes').map { |x| x.split(' ') }
# [["api_v1_inbox",
# "POST",
# "/api/v1/inboxes/:id(.:format)",
# "api/v1/inboxes#update"],
# ["api_v1_inboxes",
def to_lambda &block
obj = Object.new
obj.define_singleton_method(:_, &block)
return obj.method(:_).to_proc
end
def with_file(name, &block)
l = to_lambda(&block)
puts "Open file"
f = File.open(name, "r")
@gregolsen
gregolsen / gist:3377065
Created August 17, 2012 08:37
send numbered emails to mailtrap
require 'net/smtp'
(0..9).each do |i|
message = <<-END.split("\n").map!(&:strip).join("\n")
From: Private Person <me@fromdomain.com>
To: A Test User <test@todomain.com>
Subject: #{i} message
This is a test e-mail message.
END