Wednesday 13 March 2024

The Git & Github Bootcamp Part 4- Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Undoing Changes & Time Traveling

Checking Out Old Commits

To review or restore your project at a specific point in history:

git checkout <commit-hash>

This moves HEAD to point to the specified commit. Remember, this puts your repository in a “detached HEAD” state, where you’re no longer on a branch.

Re-Attaching Our Detached HEAD!

If you find yourself in a detached HEAD state and want to return to the latest commit on your current branch:

git switch -

Or, if you wish to keep changes from the detached HEAD state, create a new branch from it:

git switch -c new-branch-name
Read more »

Labels:

Friday 4 October 2019

how many types available for getting string variable length in perl?

Method 1:

my $c = map $_, $h =~ /(.)/g;


Method 2:

my $c = split '', $h;


Method 3:

my $count = () = "hello" =~ /./g;


Method 4:

print length $h;


Method 5:

$cnt = "hello" =~ tr/[a-z][A-Z][0-9]//;


Method 6:

$h='hello';
my $v=$h=~ s/[a-z]//g;


Method 7:

print  @_ = push(@_, map $_, (split '', 'hellgo'));


Method 8:

print  @_ = push(@_, grep $_, (split '', 'hellgo'));


Method 9:

print push(@_, grep $_, "hello" =~ /./g);


Method 10:

print push(@_, map $_, "hello" =~ /./g);


Method 11:

print push(@_, grep $_, reverse "hello" =~ /./g);


Method 12:

print push(@_, map $_, reverse "hello" =~ /./g);


Method 13:

print push(@_, map $_, (split '', 'hellgo'));


Method 14:


my $c = grep/./, (reverse split '', 'hello');
print $c;


Method 15:

my $c = map $_, (reverse split '', 'hello');
print $c;


Method 16:

my $c = map $_, (reverse "hello" =~ /./g);
print $c;


Method 17:

my $c = grep/./, (reverse "hello" =~ /./g);
print $c;


Method 18:

my $c = map $_, (reverse split '', 'hello');
print $c;


Method 19:

my $c = grep/./, (reverse split '', 'hello');
print $c;


Method 20:

print scalar map $_, 'hello' =~ /(.)/g;


Method 21:

print scalar grep/./,'helloh' =~ /(.)/g;


Method 22:

print scalar  map $_, (reverse "hello" =~ /./g);


Method 23:

print scalar  map $_, (reverse split '', 'hello');


Method 24:

print scalar  map $_, (split '', 'hello');


Method 25:

print $r = @_= map $_, (split '', 'hello');


Method 26:

print $r = @_= grep $_, (split '', 'hello');


Method 27:

print $r = @_= grep $_, (reverse "hello" =~ /./g);


Method 28:

print $r = @_= grep/./,'helloh' =~ /(.)/g


Method 29:

print $r = @_= map  $_, (reverse "hello" =~ /./g);


Method 30:

print $r = @_= map/./,'helloh' =~ /(.)/g


Method 31:

print $r = @_= map $_, (split '', 'hello');


Method 32:

print $r = @_= grep $_, (split '', 'hello');


Method 33:

print $r = @_= grep $_, (reverse "hello" =~ /./g);


Method 34:

print $r = @_= grep/./,'helloh' =~ /(.)/g


Method 35:

print $r = @_= map  $_, (reverse "hello" =~ /./g);


Method 36:

print $r = @_= map/./,'helloh' =~ /(.)/g


Method 37:

print scalar  map $_, (reverse split '', 'hello');


Method 38:

print length reverse  grep/./,'helloh' =~ /(.)/g;


Method 39:

print length reverse  map $_,'helloh' =~ /(.)/g;


Method 40:

print grep/./, (reverse "hello" =~ tr/[a-z][A-Z][0-9]//);


Method 41:

print map $_, (reverse "hello" =~ tr/[a-z][A-Z][0-9]// );




For More Methods Reach Me:@ letscrackperlinterviewblogspot@gmail.com  

Labels: , , , , ,

Tuesday 31 January 2023

Perl Datastructures - Hash of Hash

Perl hash of hashes is a data structure that consists of a hash that contains other hashes as values. Each hash contained in the main hash can be accessed using a unique key.

Here's an example of how to create a hash of hashes in Perl:

my %HoH = (
   'John' => {
      'age' => 35,
      'occupation' => 'Programmer',
      'salary' => 50000,
   },
   'Mary' => {
      'age' => 27,
      'occupation' => 'Designer',
      'salary' => 40000,
   },
   'Mark' => {
      'age' => 42,
      'occupation' => 'Manager',
      'salary' => 70000,
   },
);
Read more »

Labels:

Wednesday 13 March 2024

The Git & Github Bootcamp Part 5 - Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


GitHub Grab Bag: Odds & Ends

GitHub Repo Visibility: Public Vs. Private

  • Public repositories are visible to everyone on the internet, and anyone can contribute to your project.
  • Private repositories are hidden from the public and only accessible to you and the people you choose to share access with.

Adding GitHub Collaborators

To collaborate with others on private projects, you need to add them as collaborators:

  1. Go to your repository on GitHub.
  2. Click on “Settings” > “Manage access” > “Invite a collaborator.”
  3. Enter their GitHub username and send the invite.
Read more »

Labels:

The Git & Github Bootcamp Part 6 - Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Cleaning Up History with Interactive Rebase

1. Introducing Interactive Rebase

Interactive rebase (git rebase -i) allows you to modify commits in a more controlled manner. It opens a text editor showing a list of commits from the current branch relative to the specified base commit, along with options for how to alter each commit.

2. Rewording Commits With Interactive Rebase

To reword a commit means to change the commit message without altering the snapshot.

  • Start an interactive rebase for the last n commits: git rebase -i HEAD~n.
  • In the editor that opens, change pick to reword (or r) next to the commit you want to reword.
  • Save and close the editor. Git will open a new editor window for each commit you chose to reword.
  • Update the commit message, save, and close the editor to continue.
Read more »

Labels:

Friday 15 January 2021

Accelerate the Software Development Lifecycle with Jenkins

1.Setup the Github Repository 

To begin with, you will need to create an account on Github. (You can skip the registration part if you already have an account). Please ensure that you push the application's source code to a branch called "master". Once the code is in master, you can create another branch (from master) for your tests called "develop".


1. To create the Github account, head to the sign up page and fill out the form to sign up for a new account. (Only applicable if you don't have an account already. If you have one, please use it).

Read more »

Labels:

Sunday 7 April 2024

Navigating Programmatically with React Router


 In modern web applications, navigation isn’t just about clicking links. Sometimes, you need to navigate based on user actions, such as selecting an option from a dropdown or after the completion of a form. React Router, a cornerstone library for routing in React applications, provides a robust solution for this kind of navigation. Let’s explore how to navigate programmatically in React using React Router, going beyond the traditional <Link> component.Read more »

Labels:

Friday 5 August 2022

Given the input string 'hello boss!,where are you?,"how, are you!",hi,"di chellam","welcome"' our objective is to design a Perl program that intelligently separates and extracts each individual word from the CSV-like structure. The complexity lies in correctly handling quoted content containing commas.

CODE:

use strict;
use warnings;
my $input_string = 'hello boss!,where are you?,"how, are you!",hi,"di chellam","welcome"';

# Initialize empty array to store extracted words
my @words = ();

# Use a while loop with a regex to extract words
while ($input_string =~ /((?:(?<=,)|^)\s*"[^"]*"\s*(?=,|$)|[^,]*),?/g) {
    my $word = $1;
    # Remove leading and trailing spaces
    $word =~ s/^\s+|\s+$//g;\
    # Check if the word is quoted

    if ($word =~ /^\"(.*)\"$/) {
        # Extract the word without the quotes
        my $quoted_word = $1;
        # Add the word to the array
        push @words, $quoted_word;
    } else {
        # Add the word to the array
        push @words, $word;
    }
}

# Print the extracted words
print join("\n", @words), "\n";
Read more »

Labels: ,