This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSV_FILENAME = 'config/items.csv'.freeze | |
YML_FILENAME = 'config/items.yml'.freeze | |
File.open(YML_FILENAME, 'w') do |f| | |
f.puts(CSV.table(CSV_FILENAME).map(&:to_hash).to_yaml) | |
end | |
YAML.load(File.new(YML_FILENAME)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'csv' | |
require 'json' | |
if ARGV.size != 2 | |
puts 'Usage: csv_to_json input_file.csv output_file.json' | |
puts 'This script uses the first line of the csv file as the keys for the JSON properties of the objects' | |
exit(1) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CorreiosRequest | |
# ... | |
def build_params(package) | |
@params.merge(package.params) | |
end | |
def hash_query_string(params) | |
{ | |
'nCdEmpresa' => params[:company_id], | |
'sDsSenha' => params[:password], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clubhouse marius$ rails generate simple_form:install --bootstrap | |
create config/initializers/simple_form.rb | |
create config/initializers/simple_form_bootstrap.rb | |
exist config/locales | |
create config/locales/simple_form.en.yml | |
create lib/templates/slim/scaffold/_form.html.slim | |
=============================================================================== | |
Be sure to have a copy of the Bootstrap stylesheet available on your | |
application, you can get it on http://getbootstrap.com/. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Steps to install and run PostgreSQL 9.4.1 using Homebrew (Mac OS X) | |
# (if you aren't using version 9.3, change line #9 with the correct version) | |
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
mv /usr/local/var/postgres /usr/local/var/postgres93 | |
brew update | |
brew upgrade postgresql | |
initdb /usr/local/var/postgres -E utf8 | |
pg_upgrade -b /usr/local/Cellar/postgresql/9.3/bin -B /usr/local/Cellar/postgresql/9.4.1/bin -d /usr/local/var/postgres93 -D /usr/local/var/postgres | |
cp /usr/local/Cellar/postgresql/9.4.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |