Skip to content

Instantly share code, notes, and snippets.

View mariusbutuc's full-sized avatar
🌏

Marius Butuc mariusbutuc

🌏
  • Toronto, ON
  • 06:06 (UTC -04:00)
View GitHub Profile
@mariusbutuc
mariusbutuc / test_with_cassette.rb
Last active October 7, 2015 19:18 — forked from jrochkind/example.rb
MiniTest and VCR: one cassette per test?
module TestWithCassette
# cribbed from Rails and modified for VCR
# https://github.com/rails/rails/blob/b451de0d6de4df6bc66b274cec73b919f823d5ae/activesupport/lib/active_support/testing/declarative.rb#L9
def test_with_cassette(name, vcr_options = {}, &block)
auto_cassette_name = name.gsub(/\s+/, '_')
test_name = "test_#{auto_cassette_name}".to_sym
if block_given?
group = vcr_options.delete(:group)
group_prefix = "#{group}/" if group.present?
require 'google/api_client'
require 'google/api_client/auth/file_storage'
require 'google/api_client/auth/installed_app'
module Google
class Drive
# https://github.com/google/google-api-ruby-client-samples/blob/master/drive/drive.rb
API_VERSION = 'v2'.freeze
CREDENTIAL_STORE_FILE = Rails.root.join('lib/google/credential_store.json').freeze
@mariusbutuc
mariusbutuc / rails_new_w_pg.log
Created November 14, 2015 15:37
Rails 4.2.2 rails new output Raw
$ rails _4.2.2_ new <app_name> --database=postgresql
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
guard :minitest do
# with Minitest::Unit
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
# with Minitest::Spec
# watch(%r{^spec/(.*)_spec\.rb$})
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
# watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'

Better condos.ca

  • download_slides: get the photos of the unit
  • essence: remove noise, while keeping only unit specific details
@mariusbutuc
mariusbutuc / test_helper.rb
Last active March 14, 2016 14:27 — forked from arax/gist:4226541
VCR - ignore specific requests
# …
VCR.configure do |c|
c.hook_into :webmock
c.cassette_library_dir = 'spec/cassettes'
c.default_cassette_options = { :record => :new_episodes }
## Ignore some requests based on the hosts involved.
c.ignore_hosts 'localhost', '8.8.8.8', 'our.local.test.server.org'
@mariusbutuc
mariusbutuc / 3_mars_rover.rb
Last active April 22, 2016 22:31 — forked from nickhoffman/rover.rb
Mars Rover code kata
class Rover
class InvalidDirection < StandardError
def message
'Vertigoooooo!'
end
end
VALID_DIRECTIONS = %i(north south east west).freeze
attr_accessor :ns_coordinates, :ew_coordinates, :direction
@mariusbutuc
mariusbutuc / cache.rb
Last active April 29, 2016 20:57 — forked from nickhoffman/cache.rb
Code Kata #4: Cache
class Cache
attr_accessor :data
def initialize(data: {})
@data = data
end
def get(key)
return if data.fetch(key, {}).fetch(:expires_at, nil) <= now
source 'https://rubygems.org'
gem 'minitest'
gem 'pry-byebug'