Skip to content

Instantly share code, notes, and snippets.

View cmdr-rohit-bang's full-sized avatar
🎯
Focusing

Rohit cmdr-rohit-bang

🎯
Focusing
View GitHub Profile
@cmdr-rohit-bang
cmdr-rohit-bang / fos_user.yaml
Created June 25, 2022 08:56
# config/packages/fos_user.yaml
# config/packages/fos_user.yaml
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: App\Entity\User
from_email:
address: "test@domain.com"
sender_name: "test@domain.com"
@cmdr-rohit-bang
cmdr-rohit-bang / security.yaml
Created June 25, 2022 08:52
/project/config/packages/security.yaml
# config/packages/security.yaml
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
@cmdr-rohit-bang
cmdr-rohit-bang / User.php
Created June 25, 2022 08:49
/src/Entity/User.php
<?php
// src/Entity/User.php
namespace App\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
@cmdr-rohit-bang
cmdr-rohit-bang / recaptcha_integration.md
Last active February 5, 2021 12:21
Using Google reCaptcha in Project

Install this gem in project

gem 'recaptcha', require: 'recaptcha/rails'

Get Recaptcha Pubic and Secret keys from Google Recaptcha Admin and Put the keys vars in your .env file

STRIPE_PUB_KEY='pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSTuV'
STRIPE_SEC_KEY='sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxWXYz'
@cmdr-rohit-bang
cmdr-rohit-bang / api_integration.md
Last active February 8, 2021 05:22
API Integration in Project

Use the below command to create "API Only" project.

rails new my_api_project --api

Install JWT Gem

gem 'jwt'
@cmdr-rohit-bang
cmdr-rohit-bang / application_controller.rb
Created February 5, 2021 11:40
API Only application controller
# Project API application controller module
class ApplicationController < ActionController::API
before_action :authorized
def encode_token(payload)
JWT.encode(payload, ENV['APP_SECRET_TOKEN'])
end
def auth_header
# { Authorization: 'Bearer <token>' }
@cmdr-rohit-bang
cmdr-rohit-bang / meta_header.md
Last active February 5, 2021 11:55
Sub-Header and Meta Title

Install this gem in the project

gem 'metamagic'

In layouts/application.html.erb file

<%=metamagic site: "InitCoders", title: [:title, :site], keywords: [:keywords, "keyword 1", "keyword 2"], description: "", separator: " - " %>
@cmdr-rohit-bang
cmdr-rohit-bang / rails_helper.rb
Created February 4, 2021 12:06
spec/rails_helper.rb
# frozen_string_literal: true
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'rspec/rails'
require 'capybara/rspec'
@cmdr-rohit-bang
cmdr-rohit-bang / .rubocop.yml
Created February 4, 2021 09:56
Rubocop Configuration
require:
- rubocop-performance
- rubocop-rails
- rubocop-rspec
# AllCops:
# Rails:
# Enabled: true
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
@cmdr-rohit-bang
cmdr-rohit-bang / Procfile
Created February 4, 2021 07:05
Procfile
release: ./scripts/release-tasks.sh
web: bundle exec puma -C config/puma.rb
worker: bundle exec rake jobs:work