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 / 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
View search_issue.rb
# Search product by show_name
p = Product.filter_by(show_name: 'Sildenafil').results
# Collect uniq drug names for search products
p.each_with_object([]) { |p, o| o << p.drug.name }.uniq
# => ["sildenafil 20 MG Oral Tablet", "sildenafil 100 MG Oral Tablet"]
# Search all drug with name `sildenafil`
Drug.where("name ilike '%sildenafil%'").pluck :name, :id
# => [["sildenafil 20 MG Oral Tablet", 1024], ["sildenafil 100 MG Oral Tablet", 1723], ["sildenafil 25 MG Oral Tablet", 2062], ["sildenafil 50 MG Oral Tablet", 4139], ["sildenafil 10 MG/ML Oral Suspension", 5588]]
View settings.local.yml
data_source_dir:
dispensation:
mms: '/home/amit/Downloads/market_rx_csv/MMS/'
qs1: '/home/amit/Downloads/market_rx_csv/QS1/'
offline_sandbox_ftp: '/home/amit/Downloads/market_rx_csv/offline_data/'
View access_google_driver.rb
require 'google/apis/drive_v3'
require "googleauth"
credentials =
Google::Auth::UserRefreshCredentials.new(
client_id: "854280762506-lrrj2ajqh9b.apps.googleusercontent.com",
client_secret: "jWiGrijiFCNRmig1s3aQt",
scope: ["https://www.googleapis.com/auth/drive"],
additional_parameters: { "access_type" => "offline" })
View google_drive.rb
require 'google/apis/drive_v3'
# Create object of the drice service
service = Google::Apis::DriveV3
# Authorize it with the help of credentials generated
service.authorization = credentials
You can’t perform that action at this time.