Skip to content

Instantly share code, notes, and snippets.

View Seralahthan's full-sized avatar
🏠
Working from home

Seralahthan Seralahthan

🏠
Working from home
View GitHub Profile
@Seralahthan
Seralahthan / JavaHash.java
Last active July 21, 2019 16:28
Java Cryptographic Hash Functions Code
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
//Java program to calculate MD5,SHA-1,SHA-256 and SHA-512 hash values
public class JavaHash {
//Function to calculate the Cryptographic hash value of an input String and the provided Digest algorithm
public static String getCryptoHash(String input, String algorithm) {
try {
//MessageDigest classes Static getInstance method is called with MD5 hashing
@Seralahthan
Seralahthan / pom.xml
Last active June 2, 2019 13:32
Maven-Generating-SourceCode-Jar
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.application.test</groupId>
<artifactId>maven-package-source-code-sample</artifactId>
<version>1.0</version>
@Seralahthan
Seralahthan / Transaction02Alternative
Created February 17, 2019 10:28
SQL Server Dirty Read Demonstration
-- Transaction 02 Alternative
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
SELECT * FROM Inventory (NOLOCK) WHERE ProductId = 10
@Seralahthan
Seralahthan / TransactionIsolationLevel
Created February 17, 2019 10:15
SQL Server Dirty Read Demonstration
SELECT CASE transaction_isolation_level
WHEN 0 THEN 'Unspecified'
WHEN 1 THEN 'ReadUncommitted'
WHEN 2 THEN 'ReadCommitted'
WHEN 3 THEN 'Repeatable'
WHEN 4 THEN 'Serializable'
WHEN 5 THEN 'Snapshot' END AS TRANSACTION_ISOLATION_LEVEL
FROM sys.dm_exec_sessions
where session_id = @@SPID
@Seralahthan
Seralahthan / Transaction02Modified
Last active February 17, 2019 10:33
SQL Server Dirty Read Demonstration
-- Transaction 02 Modified
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SELECT * FROM Inventory WHERE ProductId = 10
@Seralahthan
Seralahthan / Transaction02
Created February 17, 2019 09:09
SQL Server Dirty Read Demonstration
-- Transaction 02
SELECT * FROM Inventory WHERE ProductId = 10
@Seralahthan
Seralahthan / Transaction01
Last active February 17, 2019 09:18
SQL Server Dirty Read Demonstration
-- Transaction 01
SELECT * FROM Inventory;
BEGIN TRANSACTION
UPDATE Inventory SET QtyInStock = 8
WHERE ProductId = 10
-- Bill the Purchase Order
WAITFOR DELAY '00:00:15'
@Seralahthan
Seralahthan / Transaction01Error
Created February 11, 2019 10:48
Gist created for SQL Server Concurrent Transaction illustration
-- Transfer $200 from Bob's account to Alice's Account
BEGIN TRY
BEGIN TRANSACTION
UPDATE Accounts SET Balance = Balance - 200 WHERE Id = B2
UPDATE Accounts SET Balance = Balance + 200 WHERE Id = 'A'
COMMIT TRANSACTION
PRINT 'Transaction Completed Successfully!'
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
@Seralahthan
Seralahthan / Transaction01
Created February 11, 2019 10:22
Gist created for SQL Server Concurrent Transaction illustration
-- Transfer $200 from Bob's account to Alice's Account
BEGIN TRY
BEGIN TRANSACTION
UPDATE Accounts SET Balance = Balance - 200 WHERE Id = B2
UPDATE Accounts SET Balance = Balance + 200 WHERE Id = B1
COMMIT TRANSACTION
PRINT 'Transaction Completed Successfully!'
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
sudo mkdir /media/usb
sudo mount -t exfat /dev/sdc1 /media/usb
//sudo unmount /dev/sdc1