Skip to content

Instantly share code, notes, and snippets.

View adojos's full-sized avatar
🔥
Nerdy Resurrection

Tushar Sharma adojos

🔥
Nerdy Resurrection
View GitHub Profile
@adojos
adojos / stringToDate-usingDtTimeFormatter.java
Last active March 9, 2023 11:01
Java: Convert String to Date Using DateTimeFormatter #java
private static void convertToLocalDateWithDateFormatter() {
String strDate = "06/12/2015";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
LocalDate date = LocalDate.parse(strDate,formatter);
System.out.println(date);
}
@adojos
adojos / git-commands-reference.md
Last active September 18, 2023 03:01
Git: Common Git Commands #git

Git Configuration Commands


Commands Description
git config --list Prints all your git configuration settings
git config --list --show-origin Prints all git configuration settings along with file name and path to git configuration files. You would see which configuration is set where?
@adojos
adojos / usingCollectionsSort.java
Last active March 9, 2023 11:01
Java: Sort List Using Collections.sort without Comparator #java
public static void usingCollectionsSortNoComparator() {
List<Integer> input = Arrays.asList(34,12,67,8,91,54,24);
Collections.sort(input);
System.out.print("Sorted List:");
input.forEach(num -> System.out.print(num+" "));
}
@adojos
adojos / usingCollectionsSortWithComparator.java
Last active March 9, 2023 11:01
Java: Sort List Using Collections.sort with Comparator #java
public static void usingCollectionsSortWithComparator() {
List<Integer> input = Arrays.asList(34,12,67,8,91,54,24);
Collections.sort(input,(num1,num2) -> num2-num1);
System.out.print("Sorted List:");
input.forEach(num -> System.out.print(num+" "));
}
@adojos
adojos / usingListSortWithStrings.java
Last active March 9, 2023 11:01
Java: Sort List Using Using List.sort #java
public static void usingListSortWithStrings() {
List<String> input = Arrays.asList("Horse","Cat","Elephant","Giraffe");
input.sort((str1,str2) -> str1.compareTo(str2));
System.out.print("Sorted List:");
input.forEach(num -> System.out.print(num+" "));
}
@adojos
adojos / usingStreamSort.java
Last active March 9, 2023 11:01
Java: Sort List Using Using Stream API #java
public static void usingStreamSort() {
List<Integer> input = Arrays.asList(34,12,67,8,91,54,24);
Stream<Integer> inputStream = input.stream();
Stream<Integer> sortedStream = inputStream.sorted();
List<Integer> output = sortedStream.collect(Collectors.toList());
System.out.print("Sorted List:");
output.forEach(num -> System.out.print(num+" "));
}
@adojos
adojos / sortListOfObjects.java
Last active March 9, 2023 11:00
Java: How-To Sort a List of Objects #java
List<Student> input = new ArrayList<Student>();
input.add(new Student("Bill",76));
input.add(new Student("Jane",94));
input.add(new Student("George",68));
input.sort((s1,s2) -> s1.getMarks() - s2.getMarks());
System.out.print("Sorted List:");
input.forEach(s -> System.out.print(s.getName()+" "));
@adojos
adojos / change-default-linux-Shell.md
Last active May 22, 2024 06:21
Linux: Changing Default Linux Shell #linux

Changing Default Linux Shell

Use one of the below listed methods to change your default shell.

👉 Note:

You should already have more then one shell installed on your system in order to switch to another shell. Use the below commands to check the installed shells and current default shell on your system:

1. List all Installed Shells : cat /etc/shells
@adojos
adojos / oh-my-posh_WinPS_Install.md
Last active May 18, 2024 15:11
Oh-My-Posh Installation on Win PowerShell v5.1 #powershell

Oh-My-Posh Installation on Windows PowerShell v5.1


1. Installation

There are number of ways you can install Oh-My-Posh. But commonly you install Oh-My-Posh either from PSGallery by using PowerShell's 'Install-Module' command or with Oh-My-Posh supplied platform-specific install instructions like 'Winget' on their website. Hence you can choose to run any one of the following.

If you want to use 'winget', run following:

winget install JanDeDobbeleer.OhMyPosh -s winget
@adojos
adojos / oh-my-posh_Jandedobbeleer_json.md
Last active March 13, 2023 21:34
Oh-my-posh - Jandedobbeleer Theme Config (Windows PowerShell v5.1) #powershell

Oh-my-posh - Jandedobbeleer Theme Config Windows PowerShell v5.1

My 'Jandedobbeleer Theme' json config for Oh-my-posh on Windows PowerShell

👉 PowerShell Profile Path

AllUsersAllHosts -       C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

AllUsersCurrentHost -    C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1