Skip to content

Instantly share code, notes, and snippets.

View ani03sha's full-sized avatar
👨‍💻
Web 2.0 --> Web 3.0

Anirudh Sharma ani03sha

👨‍💻
Web 2.0 --> Web 3.0
View GitHub Profile
@ani03sha
ani03sha / ConvertSeconds.java
Created February 8, 2023 05:18
Java program to convert seconds to years, months, days, hours, minutes, seconds, etc. Does not take care of corner cases like leap years and all.
public class ConvertSeconds {
public static void main(String[] args) {
ConvertSeconds convertSeconds = new ConvertSeconds();
System.out.println(convertSeconds.convert(129601));
System.out.println(convertSeconds.convert(86410));
}
public String convert(long inputSeconds) {
long year = inputSeconds / (365 * 24 * 60 * 60);
@ani03sha
ani03sha / MergeLogFiles.java
Created February 12, 2022 15:36
Merge log files into one big log file
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Time complexity: O(m * n * log m)
* Space complexity: O(m * n)
*
var mergeTwoLists = function(l1, l2) {
// If the first list is null then return the second list
// Because there is nothing to compare with the second list
if (!l1) {
return l2;
}
// If the second list is null then return the first list
// Because there is nothing to compare with the first list
if (!l2) {
return l1;
public class MinimumCost {
public static void main(String[] args) {
int[][] matrix = new int[][]{{17, 2, 17}, {16, 16, 5}, {14, 3, 19}};
System.out.println(findMinimumCost(matrix));
}
private static int findMinimumCost(int[][] matrix) {
if (matrix == null || matrix.length == 0) {
return 0;
@ani03sha
ani03sha / CustomFDS.sh
Created September 25, 2019 14:46
Create FDS in AEM using path from system variable - datastore_home
#!/bin/bash
java -jar C:/Users/Admin/Desktop/Shell-Testing/aem-author-p4502.jar -unpack
mkdir crx-quickstart/install
touch crx-quickstart/install/org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore.config
echo "repository.home=${datastore_home}" > "crx-quickstart/install/org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore.config"
echo "path=${datastore_home}" >> "crx-quickstart/install/org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore.config"
echo "minRecordLength=\"16384\"" >> "crx-quickstart/install/org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore.config"
@ani03sha
ani03sha / BinaryDecimalConversion.java
Created March 17, 2019 06:30
This gist demonstrates the methods for binary to decimal and decimal to binary conversion
package org.redquark.help.march19;
import java.util.Scanner;
/**
*
* @author Anirudh Sharma
*
*/
public class BinaryDecimalConversion {
import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.apache.jackrabbit.commons.JcrUtils;
public class GetCRXRepository {
import java.util.Scanner;
public class SumOfDigits {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number between 0 and 1000");
package org.redquark.kickstarter.threads;
public class DaemonImplementation {
public static void main(String[] args) {
DaemonThread daemonThread = new DaemonThread();
daemonThread.start();
try{
package org.redquark.kickstarter.threads;
public class DeadlockResoultion {
public static void main(String[] args) {
DeadlockResoultion deadlockImplementation = new DeadlockResoultion();
final A a = deadlockImplementation.new A();
final B b = deadlockImplementation.new B();