We are an award-winning tech entrepreneurship website where trusted experts can provide value globally.

Since 1998, DevX has helped people start businesses, build websites, and provide enterprise technology to people globally. Interviewing the likes of Microsoft’s co-founder, Steve Ballmer, the publication brings comprehensive, reliable, and accessible insights to the Internet.

devxlogo

Trusted for 26 years

Over 30K Articles

1M+ Readers

Expert-reviewed

10K+ Tech Terms

As seen in:

microsoft logo
business_insider_logo
wired_logo
berkley
arstechnica_logo
hackernoon

The Latest

DevX - Software Development Resource

Understandng toExactInt method in java.lang.Math package

java.lang.Math has numerous methods and our interest here is toIntExact() method.Consider the following example public class MathExact{   public static void main(String args[])   {      MathExact mathExact = new MathExact();      mathExact.proceed();   }      private void proceed()   {      long l = 100000000;      int i = (int) l;       System.out.println(“i: ” + i);            System.out.println(“Math.toIntExact(“+l+”);: ” + Math.toIntExact(l));   }} /* Expected output: [root@mypc]# java MathExacti: 100000000Math.toIntExact(100000000);: 100000000 */

SQL formula for calculating the first day of the current month using DATEADD and DATEDIFF

Get the First Day of the Current Month

Month-start boundaries show up everywhere in reporting queries, billing cycles, cohort aggregations, and partition pruning. Hard-coding a date string works for one run but quickly rots. Deriving the first day

DevX - Software Development Resource

Find error log location

It is quite easy to find the error log location through a quick query such as : SELECT SERVERPROPERTY(‘ErrorLogFileName’) AS ‘Error log file location’   This shows where your Error log file is stored

DevX - Software Development Resource

DBCC SHRINKDATABASE

DBCC SHRINKDATABASE The command shrinks the size of the data and log files in a database. Here is a small example: DBCC SHRINKDATABASE (Database_Name, 10);  –This allows for 10 percent free space in the database.

DevX - Software Development Resource

Monitor Log space in SQL Server quickly

You can use the following command to monitor all your databases’ log file’s free space DBCC SQLPERF (‘LOGSPACE’)

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

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

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) 

DevX - Software Development Resource

Reverse a string in Python

Its pretty ease to reverse a string in Python. ???Devx Jan???[::-1]  gives ???naJ xveD???

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

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