The Latest

Browsers warn that synchronous XHR on the main thread is deprecated and hurts UX

How to Trigger a Synchronous GET Request

Java’s modern HttpClient (introduced in Java 11, fully stable through Java 21 and 25) is the canonical way to issue HTTP requests from server-side Java. For a simple synchronous GET,

DevX - Software Development Resource

Check for finite numbers in Python

Use the math module???s isfinite method to determine if a value is finite or not.  If it is not a number, the function returns false.  See below for an example:math.isfinite(10) returns True Related Posts OnePlus Watch 2R impresses with affordabilityCloudFoundry Announces PaaS Certification ProgramGitHub Adds Project Management FeaturesIBM Cloud Computing Revenue Climbs 30%Accessing and Managing Third-Party Libraries

DevX - Software Development Resource

How to detect Python version at runtime

At times, we want to run our code only if the version of Python engine is above a certain version. See below for sample code. Import sysversion = sys.version Related Posts Using FILEPROPERTY to Check for Free Space in a DatabaseDatabricks Adds Deep Learning and GPU Acceleration to SparkLiquid Web Buys Rackspace’s Cloud Sites UnitHP Debuts Distributed

DevX - Software Development Resource

Return multiple values from a function in python

Python can return multiple values at a time. See below for a simple example. def multipleValueFunc():     z = 11     b = 22    return z, b  j,k  = multipleValueFunc () print(j, k)  Related Posts Is anyone faster than Devart? Support for MySQL v8.0 is already in dbForge StudioAvoid Repeated Execution of LINQ Queries in C#Getting the Last ID in MySQLComparing

DevX - Software Development Resource

Remove occurrences of a characters trailing within a given string

Use the rstrip method to return the string with all occurrences of the trailing characters removed.  For e.g. inputString = “devxyyy”inputString.rstrip(???y???) gives ???devx??? Related Posts IBM Launches Globalization Pipeline App Translation ServiceAsync Query ResultsFormat the Currency for a Culture in C#Apple announces iPhone 16 event for SeptemberEFCC raids night clubs in

DevX - Software Development Resource

Reverse a string in Python

Its pretty ease to reverse a string in Python. ???Devx Jan???[::-1]  gives ???naJ xveD??? Related Posts Docker 1.12 Offers Full Mac and Windows VersionsImprove Performance of Web Pages with CSS3 StylesRESEED Identity Columns of All TablesMicrosoft Releases Team Foundation Server 2015Tech Sector Turmoil:

Modern Java null-handling: explicit null, Objects.requireNonNull, Optional

Simplifying Null Check in Java

A tiny refactor that has survived every Java version from 8 to 25: flip the null check. To guard against a NullPointerException when comparing a string to a literal, most

FIND_IN_SET returns the position of a value within a comma-separated list

Using Find_in_Set in MySQL

MySQL has several ways to locate a substring, and FIND_IN_SET is the right pick when your data is stored as a comma-separated list in a single column. It returns the

Get All the Tables with a Count of Their Records

Get all the tables with a count of their records with the following query: CREATE TABLE #Temp ( TableName VARCHAR(MAX), Rows INT ); EXEC sp_MSForEachTable @command1 = ‘INSERT INTO #Temp(TableName,

How to Compute the Fibonacci Number Recursively

The following code shows you how to compute the n Fibonacci number recursively: int fibonacci(int k) { if (k return k; } return fibonacci(k – 2) + fibonacci(k – 1);}

Using AUTO_INCREMENT in MySQL

We know that AUTO_INCREMENT is used to have a sequential value auto incremented by itself for the records that we insert. CREATE TABLE AUTO_TABLE (ID INT NOT NULL AUTO_INCREMENT,PRIMARY KEY

Tip: SQL Injection, Part 2

SQL injection is probably the most common and easiest hacking technique out there. Now, don’t think I condone it, I’m just trying to make you aware of some of the

SQL Injection Tips, Part 2

SQL injection is probably the most common and easiest hacking technique out there. Now, don’t think I condone it, I’m just trying to make you aware of some of the

Automation of Tasks

Automation of tasks is a good concept. Consider the example below in which you create a task and schedule it at your convenience to execute the needed actions. There are

How to Increase the Size of an Array in Java

Java arrays are not resizable. But we can work around this constraint with the following trick. int[] newArr = Arrays.copyOf(arr, arr.length + 1); Related Articles Automation of Tasks Terminating the

Show an Image Inside a Circle in HTML

Just add a border-radius over the image element. See below for an example. . round {width: 100px;border-radius: 100%;} Related Articles Use ngSwitch Directive to Set the Contents of an Element

Using the Locate Command in MySQL

Amid tons of data, finding a particular string’s presence in the data is extremely tedious. MySQL has a command named LOCATE that can be used with certain conditions and the

Tip: SQL Injection, Part 1

SQL injection is probably the most common and easiest hacking technique out there. Now, don’t think I condone it, I’m just trying to make you aware of some of the

SQL Injection Tips, Part 1

SQL injection is probably the most common and easiest hacking technique out there. Now, don’t think I condone it, I’m just trying to make you aware of some of the

Get the Abstract Methods of a Class

With the Java Reflection API, we can isolate the abstract methods from a class via the following snippet of code: List abstractMethods = new ArrayList();Class clazz = Foo.class;Method[] methods =

Finding the Current User in MySQL

MySQL provides you a mechanism to find the current user. SELECT USER(), CURRENT_USER(); This command comes handy when you have associated a proxy privilege to a user. Sample: mysql SELECT

DevX - Software Development Resource

Understandng Objects.deepEquals

We understand how equals() method works. There is a more elaborate method deepEquals() which compares in depth details during comparison.Basic usage is described below. Let us explore more using these as examples. import java.util.Objects; public class DeepEquals{   public static void main(String args[])   {      DeepEquals deepEquals = new DeepEquals();      deepEquals.proceed();   }      private void proceed()   {      System.out.println(“Objects.deepEquals(1,1): ” + Objects.deepEquals(1,1));      System.out.println(“Objects.deepEquals(1,2): ” + Objects.deepEquals(1,2));      System.out.println(“Objects.deepEquals(“abc”,”abc”): ” + Objects.deepEquals(“abc”,”abc”));      System.out.println(“Objects.deepEquals(“aa”,”ab”): ” + Objects.deepEquals(“aa”,”ab”));   }} /* Expected output: [root@mypc]# java DeepEqualsGetting handle of runtime ConsoleGot handle of runtime ConsoleYou can now use runtimeConsole object to perform actions of your choice on java.io.Console */ Related Articles Get the Abstract Methods of a Class Automation of Tasks Terminating the Current Java Runtime Programmatically Related Posts Booking.com reports 900%

DevX - Software Development Resource

Getting console of the current runtime environment.

The Runtime class provides mechanism to get the console of the current runtime environment. Using this, we can perform needed actions on the console. import java.io.*; public class SystemConsole{   public static void main(String args[])   {      SystemConsole systemConsole = new SystemConsole();      systemConsole.proceed();   }      private void proceed()   {      System.out.println(“Getting handle of runtime Console”);      Console runtimeConsole = System.console();      System.out.println(“Got handle of runtime Console”);      System.out.println(“You can now use runtimeConsole object to perform actions of your choice on java.io.Console”);   }} /* Expected output: [root@mypc]# java SystemConsoleObjects.deepEquals(1,1): trueObjects.deepEquals(1,2): falseObjects.deepEquals(“abc”,”abc”): trueObjects.deepEquals(“aa”,”ab”): false */ Related Articles Automation of Tasks How to Increase the Size of an Array in Java Get the Abstract Methods of a Class Related

Unit Test Non-Public Methods in C# Unit Tests

To expose non-public methods to the test project, you need to mark the assembly with an attribute called InternalsVisibleTo in the asemblyinfo.cs file?? For example: [assembly: InternalsVisibleTo(“testProjectName”)] You need to

DevX - Software Development Resource

Converting Base 10 numbers to Binary numbers

Programming needs vary. You may have a requirement to convert a Base 10 value to binary as part of a complex logic. Java has easier mechanism to achieve the same. public class Base10ToBinary{   public static void main(String args[])   {      Base10ToBinary base10ToBinary = new Base10ToBinary();      base10ToBinary.proceed();   }      private void proceed()   {      int num = 10;       String binaryNum = Integer.toString(num, 2);         System.out.println(“Binary value of ” + num + ” : ” + binaryNum);    }} /* Expected output: [root@mypc]# java Base10ToBinaryBinary value of 10 : 1010 */ Related Articles Automation of Tasks Terminating the Current Java Runtime Programmatically Get the Abstract Methods of a Class Related Posts Can’t use the

DevX - Software Development Resource

Finding out the Java version.

This is generally useful, specifically if you want to perform some operations based on Java version and so on. public class JavaVersion{   public static void main(String args[])   {      JavaVersion javaVersion = new JavaVersion();      javaVersion.proceed();   }      private void proceed()   {      //This works in Java 8 and prior      //For Java 9, there is a new api available in Runtime class      String javaVersion = System.getProperty(“java.version”);        System.out.println(“Java Version: ” + javaVersion);    }} /* Expected output: [root@mypc]# java JavaVersionJava Version: 1.8.0_221 */ Related Articles Automation of Tasks Terminating the Current Java Runtime Programmatically Converting Base 10 numbers to Binary numbers Related Posts How to Join (Combine)

DevX - Software Development Resource

Updating a JAR file

At times, requirement to update an already delivered JAR file will need to be handled. Of course, JAR file is a way of packaging and delivering Java class file and related metadata files in a package. But having an easier way is always welcome by the developer group. The following command when executed on a command line will achieve updating a JAR file with 1 or more files as needed jar uf jar-file input-file-name(s) where uf          :    indicates update and filejar-file    :   the jar file that needs to be updatedinput-file-name(s)   :   the name of file(s) that needs to be updated in the jar file. Related Posts Warehouse Interview Questions You Should Be Ready ForRevolutionizing Finance: Plaid’s Bold AmbitionsNetChoice sues Georgia over new online lawCross-platform Development in C# with XamarinTelegram founder