Skip to content

Instantly share code, notes, and snippets.

View deekshithh's full-sized avatar
🎯
Focusing

Deekshith H deekshithh

🎯
Focusing
View GitHub Profile
class Helper::CurrencyConverter
CACHE_EXPIRY = 1.minute
def initialize(base_currency, target_currency, api_client = OpenExchangeRates::Rates.new)
@base_currency = base_currency
@target_currency = target_currency
@api_client = api_client
end

If you want to add a new GitHub origin with new SSH keys for just one project without affecting your existing projects, Here's how you can do it:

  1. Generate a New SSH Key: If you haven't already, generate a new SSH key for the new GitHub account. You can do this with the following command:

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

    Replace your_email@example.com with your email address. When prompted, specify a file name for the new key (e.g., id_rsa_newuser).

@deekshithh
deekshithh / cron_job.config
Last active June 24, 2020 09:00
Using whenever ruby gem in aws elastic beanstalk. It runs only on production env leader node.
commands:
01_remove_old_cron_jobs:
command: "crontab -r || exit 0"
01_remove_old_cron_job_creator:
command: "rm -f /opt/elasticbeanstalk/hooks/appdeploy/post/99_cron_job.sh"
files:
"/var/tmp/99_cron_job.sh":
mode: "000755"
owner: root
@deekshithh
deekshithh / staging.rb
Created August 8, 2019 13:30
Capistrano set the environment variables.
# Here NODE_OPTIONS is the environment variable.
# Set the NODE_OPTIONS in case of webpacker "CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"
set :stage, :staging
set :user, "ubuntu"
set :default_env, {
"NODE_OPTIONS"=>"--max_old_space_size=2048"
}
@deekshithh
deekshithh / database.yml
Created July 17, 2019 11:46
To add a session variable to mysql in rails using mysql2 gem
default: &default
adapter: mysql2
encoding: utf8
host: localhost
variables:
sql_mode: TRADITIONAL
group_concat_max_len: 100000
development:
<<: *default
@deekshithh
deekshithh / jira_user_api.rb
Last active December 11, 2023 20:01
Ruby code on how to use the Httparty class for the consumption of jira external api.
module Jira
class User
include HTTParty
base_uri 'https://***.atlassian.net/rest/api/3/'
def initialize
jira_auth = Token.find_by(token_type: 'jira')
@options = { headers: {'Content-Type' => 'application/json'},
basic_auth: {:username => jira_auth.try(:username), :password => jira_auth.try(:secret)} }
raise ArgumentError.new("Jira token doesn't exist") unless jira_auth