Skip to content

Instantly share code, notes, and snippets.

Amit Patel AmitPatel-BoTreeConsulting

Block or report user

Report or block AmitPatel-BoTreeConsulting

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / rails_helper.rb
Created Sep 6, 2019
Configure DatabaseCleaner for Rspec
View rails_helper.rb
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / .rspec
Created Sep 6, 2019
rspec dot file configuration
View .rspec
-- require spec_helper
-- order rand
-- format documentation
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / Gemfile
Created Sep 6, 2019
Basic gems used for rspec integration in Rails
View Gemfile
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] # for debugging
gem 'rspec-rails', '~> 3.8', '>= 3.8.2' # drop-in alternative testing framework for Minitest
gem 'factory_bot_rails' # replaces Rails fixtures
gem 'database_cleaner' # ensures a clean state for testing
end
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / point.rb
Last active Aug 30, 2019
Augment Behaviour by Chaining
View point.rb
class Point
def initialize(x, y)
@x = x
@y = y
end
end
class Point3D < Point
def initialize(x, y, z)
super(x, y) # calls `initialize` method superclass
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / active_transfer.rb
Created Apr 29, 2019
Using CommandExecutable to send file over Firefox Send
View active_transfer.rb
require_relative 'command_executable'
class ActiveTransfer
include CommandExecutable
def initialize(file_path)
@file_path = file_path
end
def transfer
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / command_executable.rb
Created Apr 29, 2019
Execute shell command and read command output
View command_executable.rb
require 'open3'
module CommandExecutable
attr_accessor :error, :output, :command_status
SPLIT_BY_NEW_LINE_REGEX = /\r?\n/
def execute_shell_command(command)
puts "+-+-+-+-+-+ Executing >>>>>>>> $ #{command.join(' ')}"
Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
View my_on_click_listener.java
public interface MyOnClickListener {
void onClick(View v);
boolean onLongClick(View v);
}
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / README.md
Last active Apr 2, 2019
BoTree Technologies Rub on Rails Exercise
View README.md

Build Simple Web Application where an user can:

  1. Self Sign up to Open(create) Account
  2. Deposit money
  3. Get the current balance
  4. With positive balance a. Withdraw money b. Transfer money to another account
  5. View statement of transactions like we receive from Bank

Other Instructions

  • Use Latest Stable Version of Ruby and Rails
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / fix_jsonb.rb
Created Oct 26, 2018
Fix product_info jsonb column values
View fix_jsonb.rb
# Need to run following line in production/stagin rails console after merging https://github.com/gs2589/MarketRx/pull/238
QuarantineCode.all.each do |q|
q.update!(product_info: JSON(q.product_info))
end
@AmitPatel-BoTreeConsulting
AmitPatel-BoTreeConsulting / test.sql
Created Oct 26, 2018
check if an attribute doesn't have null
View test.sql
SELECT * FROM "quarantine_codes" where (product_info->'inventory_group_attributes'->'rxcui')::text IS NOT NULL
You can’t perform that action at this time.