Posts

Plugin Registration in OIM

In this blog post, we have covered step by step guide to Plugin Registration in Oracle Identity and Access Management.

Plugin Creation for OIM

In this blog post, we have covered step by step guide on how to create a plugin in Java for OIM.

Useful Linux Commands

Here’s my blog post on some powerful Linux commands that can boost your productivity! Whether you’re a seasoned pro or just starting out, this post has something for everyone

Mastering Docker Essential Commands and Best Practices

Learn how to harness the power of Docker with my comprehensive guide on essential commands and best practices. Whether you’re a seasoned developer or just starting out, this blog post has something for everyone

Mastering Multiplexed Terminals: A Comprehensive Guide to Tmux Commands

learn how to efficiently use tmux for managing multiple terminal sessions in Linux

Configuring Domain for OIG Setup

In this guide, we have covered how to configure the domain to run the WebLogic server and other weblogic-managed servers, after fresh installation of OIG.

Connecting OIM with the Oracle database using RCU

In this guide, we have covered how to connect OIM to the Oracle Database.

Installing Oracle Identity Management (OIM)

In this guide, we’ll cover the key steps for configuring and installing Oracle Identity Governance on Ubuntu. This guide serves as a comprehensive resource.

Configure Jupyter Notebook for Ruby

Unlock the power of Ruby in Jupyter Notebook – a trusted haven for Python developers. Seamlessly integrate with your Rails console for a unified coding experience.

Understanding Shallow Copy vs. Deep Copy in JavaScript

JavaScript developers often need to clone objects, but not all clones are created equal. In this article, we’ll explore two fundamental techniques for object cloning.

Getting State, City, Country By providing the address using Geocoder in Rails

The Geocoder gem in Rails provides geolocation capabilities, allowing you to convert addresses into latitude and longitude coordinates (geocoding) and vice versa (reverse geocoding). It simplifies location-based features in applications, such as mapping, location search, and distance calculations, by providing easy access to geographic data. Additionally, Geocoder supports multiple geocoding providers, including Google Maps, Bing Maps, and more, offering flexibility in choosing the backend service.

Real-time page updates without refreshing using Turbo in Rails

Leverage Turbo Streams to provide real-time updates to your users without page reloads. In this article, we’ll explore how to use Turbo in Rails.

Adding Stimulus into Webpacker for Your Rails Application

Adding Stimulus to Webpacker in Rails empowers your application with enhanced interactivity, providing a dynamic and responsive user experience. In this article, we’ll explore how to add stimulus into rails if you are using Webpacker.

Creating Users Without Password Validation in Devise

In this article, we’ll explore how to create users without password validation using Devise, a popular authentication solution for Ruby on Rails applications. We’ll discuss the reasons behind such an approach and demonstrate two methods to achieve it while maintaining security and flexibility.

Many-to-Many Association Rails

In this tutorial, we’ll explore how to set up a many-to-many association between users and programs in a Ruby on Rails application. We’ll create a middle table to handle the association.

Rolify Gem Rails

Role-based authorization is a critical aspect of many web applications, allowing you to control user permissions and access levels. In this blog post, we will explore how to implement role-based authorization using the popular Rolify gem in a Ruby on Rails application.

Rails Nested Attributes (Nested Form)

Learn how to effortlessly handle associated models and manage complex forms using the combination of fields_for and accepts_nested_attributes_for. Discover the benefits and best practices of working with nested attributes in Rails development.

JQuery DataTables with Rails

jQuery DataTables is a powerful and flexible tool for displaying data in a tabular format on web pages. It provides many features and customization options, making it a popular choice for web developers who need to display large amounts of data on their websites.

How to Perform Data Analysis Using R

In this blog post, I delved into the UK dataset and detailed the methods I used to explore and analyze it. Through the post, I have demonstrated how readers can replicate the exploration and analysis techniques to any dataset, depending on their specific research questions and analysis requirements. The article aims to provide readers with a framework for creating research questions and performing data analysis that is broadly applicable to various datasets.

Cloud Storage Bucket and Deploying Rails App

App Engine in Google Cloud provides effortless scalability, cost-effectiveness, high availability, robust security features, and ease of use for developers, on which you can deploy your web apps without worrying about the underlying infrastructure..

Ubuntu Instance on Google Cloud with Webserver

In this guide, I’ll show you how to create Compute Engine and set up a web server on it.

Ubuntu Instance on AWS with Webserver

In this guide, I’ll show you how to create an Ubuntu instance on AWS and set up a web server to host your website.

Rails Panko Serializer Gem

Panko serializer is a powerful and efficient serialization library for Ruby on Rails that can help you easily customize the JSON output of your models and improve the performance of your application.

Managing States using rails aasm gem

The “aasm” gem is a state machine library for Ruby on Rails applications. It allows you to define states and transitions for your models and provides methods to check the current state, trigger events that cause state transitions and perform actions before or after state changes.

Ruby Adhoc Task(One time Script)

In this blog post, I will be discussing the use of Ruby ad-hoc tasks or one-time scripts, which are commonly utilized to perform specific tasks or sets of tasks that do not require a dedicated application. These tasks are often created to automate processes that are frequently performed or are not part of the regular application flow.

Rails migrations

In this post, I have demonstrated the process of creating a database migration using Ruby on Rails. I have provided step-by-step instructions for generating and running the migration, as well as rolling back changes if necessary. This post serves as a comprehensive guide for developers looking to manage their database schema using Rails migrations.

Tooltip Component (React)
import Tooltipable from './components/tooltipable';

function App() {
  return (
    <div className="App">
      <Tooltipable tooltipText="Hello, thanks to hower">
        <div>My Heading</div>           
      </Tooltipable>
    </div>
  );
}
// you can use other components inside "Tooltipable" as well to display small text on hower for button, div etc
import React, { useState, useEffect } from 'react';
import { v4 as uuidv4 } from 'uuid';
import { Tooltip } from 'reactstrap';
import { PropTypes } from 'prop-types';

const Tooltipable = ({
  className,
  innerClassName,
  children,
  placement,
  tooltipText,
  target
}) => {
  const [isOpen, setIsOpen] = useState(false);
  const [id, setId] = useState(`tooltip-${uuidv4()}`);
  const targetName = target || id;

  useEffect(() => {
    setId(`tooltip-${uuidv4()}`);
  }, []);

  return (
    <span id={id} className={className}>
      <span
        onClick={() => {
          setIsOpen(true);
        }}
        onFocus={(e) => {
          setIsOpen(true);
        }}
        onBlur={(e) => {
          setIsOpen(false);
        }}
        onMouseEnter={() => {
          setIsOpen(true);
        }}
        onMouseLeave={() => {
          setIsOpen(false);
        }}
      >
        {children}
      </span>
      <Tooltip
        placement={placement}
        isOpen={isOpen}
        target={targetName}
        innerClassName={innerClassName}
      >
        <div>
          {tooltipText}
        </div>
      </Tooltip>
    </span>
  );
};

Tooltipable.defaultProps = {
  className: 'd-inline-block',
  placement: 'bottom',
  innerClassName: ''
};

Tooltipable.propTypes = {
  tooltipText: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.object
  ]),
  placement: PropTypes.string,
  className: PropTypes.string,
  target: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func
  ]),
  innerClassName: PropTypes.string
};

export default Tooltipable;
Displaying Error for each field (Rails)
<div class="card form-card">
  <div class="card-body">
    <h5 class="card-title">Editing Ticket</h5>
    <%= form_for @ticket, url: project_ticket_path(@project, @ticket), method: :patch, format: false,data: {turbo: false}, local: true do |f| %>
  <div class="row mb-4">
    <div class="col">
      <div class="form-outline">
        <%= f.label :name, class: "form-label"  %><br />
        <%= f.text_field :name, class: "form-control" %>
        <% invalid = @ticket.errors.include?(:name)%>
        <% if invalid %>
          <div class="invalid-feedback d-block">
            <% @ticket.errors.full_messages_for(:name).each do |error_message| %>
              <%= error_message %>.
            <% end %>
          </div>
        <% end %>
     </div>
    </div>
  </div>
  <div class="form-outline mb-4">
    <%= f.label :description, class: 'form-label' %><br />
    <%= f.text_area :description, class: 'form-control'%>
    <% invalid = @ticket.errors.include?(:description)%>
    <% if invalid %>
      <div class="invalid-feedback d-block">
        <% @ticket.errors.full_messages_for(:description).each do |error_message| %>
          <%= error_message %>.
        <% end %>
      </div>
    <% end %>
  </div>
  <div class="form-outline mb-4">
  <label class="form-label"> Status </label>
  <%= f.select :status, options_for_status_select, {}, {class: 'form-select'}%>
  </div>
  <div class="form-outline mb-4">
    <label class="form-label"> Severity </label>
  <%= f.select :severity, options_for_select_severity, {}, {class: 'form-select'} %>
  </div>
  <div class="form-outline mb-4">
    <label class="form-label"> Priority </label>
  <%= f.select :priority,options_for_select_priority, {}, {class: 'form-select'} %>
  </div>
  <div class="form-outline mb-4">
    <label class="form-label"> Engineer </label>
    <%= f.collection_select(:engineer_id, get_engineers().all, :id, :name, {include_blank: true}, {class: 'form-select'} ) %>
  </div>
  <div class="actions"><%= f.submit "Save Changes", class: "btn btn-primary" %></div>
  <% end %>
  </div>
</div>

Access Inner Class (Rails)
# let we have a Model class
class Lead < ApplicationRecord
  has_many :emails, dependent: :destroy, inverse_of: :lead

  class << self
    def all_closest_office_names
      joins(:relitix_attributes)
        .where("lead_relitix_attributes.closest_office_name != ''")
        .distinct
        .pluck(:closest_office_name)
        .compact
    end
end
end

# now for accessing inner class method from controller action

class LeadsController < ApplicationController
  def all_closest_offices
    render json: current_team.leads.all_closest_office_names
    # here the codes seem very clean, as our queries are executed in the inner class of model.
    # current_team.leads contains the association array of all multiple records
    # and remaining queries are executed in the model

    # it is similar to
    # current_team.leads.joins(:relitix_attributes)
    #    .where("lead_relitix_attributes.closest_office_name != ''")
    #    .distinct
    #    .pluck(:closest_office_name)
    #    .compact

    # but much cleaner
  end
end

Bootstrap Toast Messages
function show_toast()
{

	$('#mytoast').toast({delay: 5000})
	$("#toast-text").text("new comment added")
	$('#mytoast').toast('show')
} 

<div role="alert" aria-live="assertive" aria-atomic="true" id="mytoast" class="toast" data-bs-autohide="true">
  <div class="toast-header">
    <img src="..." class="rounded me-2" alt="...">
    <strong class="me-auto">Bootstrap</strong>
    <small>11 mins ago</small>
    <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  </div>
  <div class="toast-body">
    <p id="toast-text">Hello, world! This is a toast message.</p> 
  </div>
</div>

// execute the function show_toast for displaying toast message

Rbenv Cheatsheet
# Install rbenv
$ brew install rbenv

# Completely uninstall rbenv
$ brew uninstall rbenv

# list all available versions
$ rbenv install -l

# install a specific Ruby version
$ rbenv install 2.3.0

# Sets a local application-specific Ruby version
# by writing the version name to a `.ruby-version`
$ rbenv local 2.2.2

# Sets the global version of Ruby to be used in all shells
# by writing the version name to the `~/.rbenv/version` file
$ rbenv global 2.2.1

# Sets a shell-specific Ruby version by setting the
# RBENV_VERSION environment variable in your shell.
$ rbenv shell 2.2.1

# Lists all Ruby versions known to rbenv
$ rbenv versions

# Displays the currently active Ruby versions
$ rbenv version

# Run this command after you install a new version of Ruby,
# or install a gem that provides commands.
$ rbenv rehash

# Displays the full path to the executable that rbenv will
# invoke when you run the given command
$ rbenv which irb
Reduce Noise from Video

Here is a quick method on my Channel to reduce noise from your video using two open-source applications.
= Audacity(easily installable in windows or Linux) will be used to remove the noise from audio
= Then we will mute the original audio from our video using Shotcut(easily installable in windows or Linux)
=Then we will embed that noiseless audio to our muted video using Shotcut

Git
$ git branch
# Staging all files
$ git add .

# Stage specific files
$ git add first-file second-file

# Commit to a local directory
$ git commit -m "My temp Message"

# Push to the remote branch, (latest commit will be pushed) 
$ git push origin "temp-branch-name"

# Pull from a remote branch
$ git pull origin "temp-branch-name"

# Creating a new branch
$ git checkout -b "temp-branch-name"

# Switching to another branch
$ git checkout "temp-branch-name"

# Checking the commit history
$ git log 

# Rollback to a specific commit
$ git log  #(grab the hash of a specific commit and paste it below)
$ git reset 0117d536842b850a5ceb0e7ecf7585c33b5e0c1b

# When you switch branches and you have unstaged changes, it will ask for a commit, (even if we don't want to commit now)
git stash save "hold my changes"
$ git stash list  # (showing all saved stash) 
$ (first-branch)-> git checkout "temp-branch-name"
$ git checkout first-branch
$ git stash pop     # (continue where you left off)
$ git stash <specific stash> # use stash list to select stash)

# Commit to the previous commit 
$ git commit --amend 
$ git push origin "temp-branch-name" -f # (now you have to force push)

# Merge another branch with the current one
$ git merge "temp-branch-name" # (possibly you will get merge conflicts, that should be resolved)

# Creating patch file for(tracking difference of current commit with master branch and saving to a file)
$ git diff master --patch > api-diff.patch
Handling Multiple Requests in Controller Actions (Rails)
 def update
    respond_to do |format|
      format.html do
        if @ticket.update(ticket_params)
          flash[:notice] = 'Ticket Updated Successfully'
          redirect_to project_tickets_path
    
        else
          redirect_to root_path, alert: 'Error while creating ticket' # redirecting to index path of ticket
        end  
      end

      format.js do
        if @ticket.update(ticket_params)
          render json: {notice: 'Ticket Updated Successfully'}, status: 200            # returning json response
        else
          render json: {alert: 'Error while creating ticket'}, status: 422
        end
      end
    end
  end

Ability Cancancan Sample (Rails)
class Ability
  include CanCan::Ability

  def initialize(user)
    case user.role
    when 'ADM'
      can :manage, Project, creator: user
      cannot :assign_unassign, Project

    when 'MNG'
      can :destroy, Comment, owner: user, ticket_id: user.created_tickets.ids
      can :update, Comment, owner: user,  ticket_id: user.created_tickets.ids
      can :create, Comment, ticket_id: user.created_tickets.ids

      can :manage, Ticket, manager: user

      can :read, Patch, ticket_id: user.created_tickets.ids
      can :update, Patch, ticket_id: user.created_tickets.ids

      can :read, Project, manager: user
      can :update, Project, manager: user
      cannot :edit, Project
      can :assign_unassign, Project, manager: user

    when 'ENG'
      can :manage, Patch, ticket_id: user.assigned_tickets.ids

      can :destroy, Comment, owner: user, ticket_id: user.assigned_tickets.ids
      can :update, Comment, owner: user,  ticket_id: user.assigned_tickets.ids
      can :create, Comment, ticket_id: user.assigned_tickets.ids

      can :read, Ticket, engineer: user
      can :update, Ticket, engineer: user

      can :read, Project, id: user.assigned_projects.ids
    end

    can :destroy, Comment, owner: user
  end
end

Inserting Element Using JS (Stimulus)
listenForCommentUpdates(payload) {
            
$("#my-element").prepend(this.buildCommentContent(payload));
}

buildCommentContent(payload) {
      const { comment, owner } = payload;

      return (
        `<div class="card mb-3" data-comment-id="${comment.id}">
          <div class="card-body" id="comments-card">
            <div class="comments-header">
              <div class="commenter-info">
                <div class="commenter-image">
                  <img 
                    class="rounded-circle shadow-1-strong me-3"
                    width="40" height="40" 
                    src="/assets/profile-ed7614a0047a0768e6dbf9d405f0ecc967246f08587073c6a57d8cb27f29cd58.png"
                  >
                </div>
                <div id="name-and-times-ago">
                  <div class="comment-owner-name">${owner.name}</div>
                  <div class="times-ago">
                    <i class="far fa-clock"></i>
                    <span class="ms-1">
                      ${payload.comment.created_at}ago
                    </span>
                  </div>
                </div>
              </div>
      
              <div class="comment-controls"></div>
            </div>    
            <div id="hidden-before-update" class="d-flex flex-start">
                <div id="comment-block">
                  <div class="comment-input" id="comment-content-${comment.id}">
                    ${comment.content}
                  </div>
                  <div id="comment-${payload.comment}-edit-controls" class="hide-block">
                  <button
                    class="btn"
                    data-comment-id="${comment.id}"
                    id="submit-${comment.id}"
                    data-action="click->comments#submitCommentForm"
                  >
                    <i   data-comment-id="${comment.id}"
                      class="fa-solid fa-check"></i>
                  </button>
                  <button
                    class="btn"
                    value="${comment.id}"
                    data-comment-id="${comment.id}"
                    id="comment-cancel-${comment.id}"
                    data-action="click->comments#cancelEditAction"
                  >
                    <i   data-comment-id="${comment.id}"
                        class="fa-solid fa-xmark"></i>
                  </div>
                </button>
              </div>
            </div>
          </div>
        </div>`
      );
    },
Ajax Post Request (Stimulus)
requestHeaders()
  {
    return {'X-CSRF-Token': document.head.querySelector(`meta[name="csrf-token"]`).content}
// csrf token can be fetched from header of current document

//csrf token is required(manually) if you want to send form data without actual rails forms   
}

  requestUrl(commentId="")
  {
    const ticketId = this.currentTicketTarget.dataset.ticketId;
    return `/tickets/${ticketId}/comments/${commentId}` 
  }

  createComment()
  {
    const commentText = $("#new-comment-body").text();
 
    $.ajax(this.requestUrl(), {
      type: "POST",
      dataType: "script",
      data: { comment: {content: commentText} },
      headers: this.requestHeaders(),
      success: function (data) {},
      error: function (jqXHR, textStatus, errorThrown) {},
    });
  }
Connecting PHP with Mysql
<?php
$username = "username";
$password = "password";
try {
$conn = new PDO("mysql:host=localhost;dbname=myDB", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
BST in Python with Visualization
This is my own youtube channel
Using Lambda in Python
C++
Docker
Design a site like this with WordPress.com
Get started