System Design resourcesSystem design is a crucial skill for software engineers, especially in high-scale, production-level applications. Here are some of the best resources for learning system design, ranging from books to online courses and websitesWebsites & BlogsKey Topics to Focus On As you explore these resources, here are some essential topics to focus on when learning...
Table of ContentGetting this simple problem while importing Xgboost on Jupyter notebookIssue: Cannot import xgboost in Jupyter notebookError: Following error seen in Jupyter notebookSolutionInstall libompSummaryGetting this simple problem while importing Xgboost on Jupyter notebookSometimes when we try to import xgboost in Jupyter notebook it does not work and throws error....
Table of Contentnpm and npx npmnpm Commandsnpxnpx CommandsExample ScenarioIf you want to start a new React project, you could use:If you wanted to install create-react-app globally for repeated use, you would use:Summarynpm and npx Both npm and npx are tools that come with Node.js, but they serve different purposes.npmFull Form: Node Package Manager Purpose: npm is used for...
Table of ContentHow to find hamming weight in JavaUsing Simple divide and reminderhammingWeight.javaUsing Bit markinghammingWeightIIFull ExampleHow to find hamming weight in Javahamming weight for a number is the count of bits that are non zero. For instance for 1001 hamming weight is 2. For 100001111 hamming weight is 5. In this article we will see how to find hamming weight...
Table of ContentJava OptionalInt exampleOptionalIntExampleSummaryJava OptionalInt exampleOptionalInt allows us to create an object which may or may not contain a int value. If a value is present, isPresent() will return true and getAsInt() will return the value. Additional methods that depend on the presence or absence of a contained value are provided, such as orElse(). Other...
Table of ContentBucket Sort in JavaWhat is Bucket sortPseudocodeBucketSortExample.javaComplexitySummaryBucket Sort in JavaIn this article we will go though a simple implementation of Bucket sort in JavaWhat is Bucket sortBucket sort is a sorting algorithm that divides the inputs into several buckets. Once the buckets are populated with input data, then all these buckets are...
IntSummaryStatisticsIntSummaryStatistics provides different statistical data like max, min, average. This class is desinged to work with Java streams but can work with with out streams also.ExampleFollowing class shows an example of IntSummaryStatistics used with stream. It is used to print interesting information like max, min, average, sum and count. And then the accept method...
How to convert Java Stream to ListConvert Java Stream to ListFollowing code show how to convert the stream intStream to list using collect. // Converting Streams to Collection Stream<Integer> intStream = Stream.of(1, 2, 3, 4, 5); List<Integer> list = intStream.collect(Collectors.toList()); System.out.println(list); // prints [1, 2, 3, 4, 5] ...

Arduino Humadity

January 31, 2024
#include #include dht DHT; #define DHT11_PIN 7 void setup(){ Serial.begin(9600); } void loop(){ int chk = DHT.read11(DHT11_PIN); Serial.print("Temperature = "); Serial.println(DHT.temperature); Serial.print("Humidity = "); Serial.println(DHT.humidity); delay(1000); }...

Ardino Gas Sensors

January 31, 2024
  //#include #define MQ2pin (0) //https://robu.in/mq2-sensor-interfacing-with-arduino-gas-and-smoke-detection/ float sensorValue; //variable to store sensor value void setup() { Serial.begin(9600); // sets the serial port to 9600 Serial.println("Gas sensor warming up!"); Serial.println("I can detect 300 - 10000ppm"); delay(20000); // allow the MQ-2 to warm up } void...
Extract content of .war fileA WAR file (Web Application Resource or Web application Archive) is a file used to distribute a collection of files and folders associated with web application. Sometimes we want to look inside the war file to know what files or folders are inside the...
HashMap computeIfPresent() method in Java with ExamplesThe computeIfPresent(Key, BiFunction) method of HashMap class is used to update value in a key-value pair in the map. If key does not exist then it does not do any thing. SyntaxundefinedV computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) ExampleFollowing is an example...
HashMap computeIfAbsent() method in Java with ExamplesThe computeIfAbsent(Key, Function) method of HashMap class is used to enter a new key-value pair to map if the key does not exist. If key exists then it does not do any thing. Syntaxundefinedpublic V computeIfAbsent(K key, Function<? super K, ? extends V> remappingFunction)ExampleFollowing is an example of computeIfAbsent...
Remove all entries in map by valueJava Map is a data structure that holds key->value pairs. In this article we will see how to delete all entries in the map by map values. Using removeAllremoveAll() takes one argument a collection. And entries matching the passed collection will be removed from the original mapUsing removeAllMap<Integer, String> map = new HashMap<Integer,...
Remove all entries from java mapJava Map is a data structure that holds key->value pairs. In this article we will see how to delete all entries in the map in java easily and efficetively.Method clear()clear() method is method that does not return any thing (void return type) and is part of the Map interface. Each implementation subclasses provides an implementation. clear...
When to use Java BigIntegerJava BigInteger class is used to perform arithmetic operation or holding Numbers large enough that Integer cannot hold. In fact BigInteger does not have any limit on the numerical value that it can represent.java.math.BigIntegerInteger Max and Min valueIn Java Integer can hold between 2147483647 and -2147483648. This is denoted by Integer.MAX_VALUE...
Delete .DS_STORE files in all subfolders.DS_STORE file is automatically created in Apple Mac. If we have a git repository it is generally recommended that we remove all .DS_STORE files in the repository folder.We can delete recursively using find command like bellow. Delete .DS_Storefind . -name ".DS_Store" -delete ...
Generate random numberFollowing java code will generate a random number between a given range. For instance if we want to generate a random number between 80, 100 we can use the following codes. In java to generate random number we have two options, using class Math or Random. We will see both examplesUsing Class java.lang.MathMath.random() generates a fraction(double) number...
JDK Module listingGo to Terminal and execute following command (java --list-modules). It will list all the modules available in the JDK.Terminal $java --list-modules java.base@18.0.1.1 java.compiler@18.0.1.1 java.datatransfer@18.0.1.1 java.desktop@18.0.1.1 java.instrument@18.0.1.1 java.logging@18.0.1.1 java.management@18.0.1.1 java.management.rmi@18.0.1.1 java.naming@18.0.1.1 java.net.http@18.0.1.1 java.prefs@18.0.1.1 java.rmi@18.0.1.1 java.scripting@18.0.1.1 java.se@18.0.1.1 java.security.jgss@18.0.1.1 java.security.sasl@18.0.1.1 java.smartcardio@18.0.1.1 java.sql@18.0.1.1 java.sql.rowset@18.0.1.1 java.transaction.xa@18.0.1.1 java.xml@18.0.1.1 java.xml.crypto@18.0.1.1 jdk.accessibility@18.0.1.1 jdk.attach@18.0.1.1 jdk.charsets@18.0.1.1 jdk.compiler@18.0.1.1 jdk.crypto.cryptoki@18.0.1.1 jdk.crypto.ec@18.0.1.1 jdk.dynalink@18.0.1.1 jdk.editpad@18.0.1.1 jdk.hotspot.agent@18.0.1.1 jdk.httpserver@18.0.1.1 jdk.incubator.foreign@18.0.1.1 jdk.incubator.vector@18.0.1.1 jdk.internal.ed@18.0.1.1 jdk.internal.jvmstat@18.0.1.1 jdk.internal.le@18.0.1.1 jdk.internal.opt@18.0.1.1 jdk.internal.vm.ci@18.0.1.1 jdk.internal.vm.compiler@18.0.1.1 jdk.internal.vm.compiler.management@18.0.1.1 jdk.jartool@18.0.1.1 jdk.javadoc@18.0.1.1 jdk.jcmd@18.0.1.1 jdk.jconsole@18.0.1.1 jdk.jdeps@18.0.1.1 jdk.jdi@18.0.1.1 jdk.jdwp.agent@18.0.1.1 jdk.jfr@18.0.1.1 jdk.jlink@18.0.1.1 jdk.jpackage@18.0.1.1 jdk.jshell@18.0.1.1 jdk.jsobject@18.0.1.1 jdk.jstatd@18.0.1.1 jdk.localedata@18.0.1.1 jdk.management@18.0.1.1 jdk.management.agent@18.0.1.1 jdk.management.jfr@18.0.1.1 jdk.naming.dns@18.0.1.1 jdk.naming.rmi@18.0.1.1 jdk.net@18.0.1.1 jdk.nio.mapmode@18.0.1.1 jdk.random@18.0.1.1 jdk.sctp@18.0.1.1 jdk.security.auth@18.0.1.1 jdk.security.jgss@18.0.1.1 jdk.unsupported@18.0.1.1 jdk.unsupported.desktop@18.0.1.1 jdk.xml.dom@18.0.1.1 jdk.zipfs@18.0.1.1 As...
What is package-info.java used for in Javapackage-info.java is a special file which is used for generating package level documentations as well as keeping all package level annotations. For each package we can have one package-info file.Here will see two different examples of package-info.java.Package...