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 / 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
config.around(:each) do |example| do
AmitPatel-BoTreeConsulting / .rspec
Created Sep 6, 2019
rspec dot file configuration
View .rspec
-- require spec_helper
-- order rand
-- format documentation
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
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
class Point3D < Point
def initialize(x, y, z)
super(x, y) # calls `initialize` method superclass
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
def transfer
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
def execute_shell_command(command)
puts "+-+-+-+-+-+ Executing >>>>>>>> $ #{command.join(' ')}"
Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
public interface MyOnClickListener {
void onClick(View v);
boolean onLongClick(View v);
AmitPatel-BoTreeConsulting /
Last active Apr 2, 2019
BoTree Technologies Rub on Rails Exercise

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 / 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
QuarantineCode.all.each do |q|
q.update!(product_info: JSON(q.product_info))
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.