Skip to content

Instantly share code, notes, and snippets.

View snmmaurya's full-sized avatar
💭
Programming...

Sandeep Maurya snmmaurya

💭
Programming...
View GitHub Profile
@snmmaurya
snmmaurya / rails google 2fa.md
Last active March 19, 2021 02:38
Rails how to implement google 2fa (using rotp gem)

Step - 1

Install rotp gem

In my case I am using an user model to add google 2fa.

Setp - 2

@snmmaurya
snmmaurya / gist-6.md
Last active September 26, 2019 20:36
rails simple cryptography to encode and decode a payload based on OpenSSL::Cipher

A simple cryptography to encode and decode a payload based on OpenSSL::Cipher

class SimpleCryptography
  SECRET = "secretkey"

  def self.encode payload
    cipher = OpenSSL::Cipher.new('AES-128-CBC').encrypt
 cipher.key = Digest::SHA1.hexdigest(SECRET).unpack('B16').first
@snmmaurya
snmmaurya / gist-5.md
Last active February 7, 2020 11:37
rails dynamodb implementation
@snmmaurya
snmmaurya / rails + mongoid
Last active October 25, 2018 09:02
rails mongodb implementation
References: https://github.com/mongodb/mongoid
mongoid is one of the best ODMs
Install mongodb - Reference: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Ruby and Ruby on Rails version-
Rails - 5+
Ruby - 2.5+
@snmmaurya
snmmaurya / node + dynamoose
Created October 25, 2018 09:04
node dynamodb implementation
References: https://www.npmjs.com/package/dynamoose and https://dynamoosejs.com/api
Steps to start with dynamoose-
install dynamoose
npm install dynamoose
configure your dynamodb under aws DynamoDB service.
@snmmaurya
snmmaurya / node + mongoose
Created October 25, 2018 09:04
node mongodb implementation
References: https://mongoosejs.com/
Steps to start with mongoose-
install mongoose
npm install mongoose
create file config/dynamodb.rb
@snmmaurya
snmmaurya / gist-7.md
Last active September 26, 2019 20:31
Bitbucket pipeline for multiple AWS account (rails app with rspec)

Setup bitbucket pipeline to deploy rails app on beanstalk with multiple AWS account.

My application based on-

Postgres
Redis
Rspec

I am using two environment for my rails application

@snmmaurya
snmmaurya / master.config
Last active May 14, 2020 06:36
How to deploy node application on AWS beanstalk (proxy - NGINX)
container_commands:
00_node_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
00_npm_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
50-run-database-migrations:
command: "./node_modules/.bin/sequelize db:migrate"
leader_only: true
@snmmaurya
snmmaurya / myScript.ts
Created January 31, 2022 11:54
Type Script Object is of type 'unknown'.
Object is of type 'unknown'.
for ex -
catch (err) {
logger.error("CoindcxVpcAPI", url, err);
if (err.response) {
throw new ServiceError(
err.response.data && err.response.data.message || "Invalid Request",
err.response.status,
@snmmaurya
snmmaurya / phonepe.rb
Last active February 16, 2024 10:21
PhonePe Ruby on Rails Implementation
@api_key = '099eb0cd-02cf-4e2a-8aca-3e6c6aff0399'
@merchant_id = 'PGTESTPAYUAT'
@key_index = 1
# Step 2
@payment_params = {
'merchantId' => @merchant_id,
'merchantTransactionId' => "MT7850590068188104",