Skip to content

Instantly share code, notes, and snippets.

View muhdkhokhar's full-sized avatar

Giri G Seku muhdkhokhar

View GitHub Profile
@echo off
setlocal enabledelayedexpansion
echo Getting JVM parameters from ConfigClient...
for /f "delims=" %%A in ('java -jar C:\scripts\ConfigClient.jar project-1') do (
set JVM_PARAMS=%%A
)
echo JVM Params: !JVM_PARAMS!
import java.util.concurrent.*;
public class InternalQueue {
private final String queueName;
private final BlockingQueue<Message> queue = new LinkedBlockingQueue<>();
private final ExecutorService executorService;
private final MessageListener listener;
private final int concurrentConsumers;
public InternalQueue(String queueName, MessageListener listener, int concurrentConsumers) {
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.ColumnMapRowMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
SELECT s.session_id, s.status, s.login_name, s.host_name, r.cpu_time, r.start_time, r.total_elapsed_time,
r.blocking_session_id, q.text AS sql_text
FROM sys.dm_exec_sessions s
LEFT JOIN sys.dm_exec_requests r ON s.session_id = r.session_id
CROSS APPLY sys.dm_exec_sql_text(s.most_recent_sql_handle) AS q
WHERE s.session_id IN (SELECT session_id FROM sys.dm_exec_requests)
ORDER BY r.start_time DESC;
private int getSessionId(Connection connection) throws Exception {
try (PreparedStatement ps = connection.prepareStatement("SELECT @@SPID");
ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
return rs.getInt(1);
}
}
throw new RuntimeException("Failed to retrieve session ID.");
}
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.40.0</version> <!-- Use latest version -->
<configuration>
<activeRecipes>
<!-- Upgrade to Java 21 -->
<recipe>org.openrewrite.java.migrate.Java8toJava21</recipe>
SELECT
t.resource_type,
t.resource_database_id,
t.resource_description,
t.request_mode,
t.request_status,
t.request_session_id,
s.login_name,
s.host_name,
s.program_name,
public class StringReplaceByIndex {
public static void main(String[] args) {
String original = "Hello, World!";
int startIndex = 7; // starting index of the substring to replace
int endIndex = 12; // ending index (exclusive) of the substring to replace
String replacement = "Java";
String result = replaceSubstring(original, startIndex, endIndex, replacement);
System.out.println(result); // Output: Hello, Java!
}
SELECT
p.name AS ParameterName,
t.name AS DataType,
p.max_length AS MaxLength,
p.precision AS Precision,
p.scale AS Scale,
p.is_output AS IsOutputParameter,
CASE
WHEN p.is_nullable = 1 THEN 'Optional'
ELSE 'Mandatory'
<#macro setAttr name value>
@${name}=${value?if_exists?string('null', value)!'null'}
</#macro>