Skip to content

Instantly share code, notes, and snippets.

View adojos's full-sized avatar
🔥
Nerdy Resurrection

Tushar Sharma adojos

🔥
Nerdy Resurrection
View GitHub Profile
@adojos
adojos / write-win-envVariables.vbs
Last active March 9, 2023 11:03
VBS: Write Windows Env Variables #vbs
Sub WriteEnvVar(strEnvVarType, strEnvVarName, strEnvVarValue, strWriteType)
Dim strOldVarValue, strNewVarValue
Dim strVarType
Set objShell = CreateObject("WScript.Shell")
Set objEnv = objShell.Environment(strEnvVarType) ' envVarType= System or User
Select Case strWriteType
@adojos
adojos / load-XMLFile.vbs
Last active March 9, 2023 11:03
VBS: Load XML file using MSXML Parser #vbs
' This ParseError property is for errors and warnings during 'Load'method.
' Applies to IXMLDOMParseError interface.
Public Function LoadXML(strXmlPath)
Dim ObjParseErr, ObjXML
Dim IsWait
Set ObjXML = CreateObject ("MSXML2.DOMDocument.6.0")
@adojos
adojos / loadSchemaCache.vbs
Last active March 9, 2023 11:03
VBS: Load XSD Schema from XSD File #vbs
Public Function LoadSchemaCache (objSchemaColl, objXSDFile)
Dim strNsURI
'Get targetNamespace property from XSD
strNsURI = GetNamespaceURI (objXSDFile)
'Load XSD from the Path
objSchemaColl.Add strNsURI, objXSDFile
@adojos
adojos / getNamespaceURI.vbs
Last active March 9, 2023 11:02
VBS: Get target Namespace #vbs
Public Function GetNamespaceURI (ObjXML)
Dim strNsURI
strNsURI = ObjXML.documentElement.getAttribute("targetNamespace")
If strNsURI <> "" Then
GetNamespaceURI = strNsURI
ConsoleOutput "<INFO> Adding 'targetNamespace' " & strNsURI, "verbose", LogHandle
@adojos
adojos / parse-LoadErrors.vbs
Last active March 9, 2023 11:02
VBS: Parse XML Errors on Loading #vbs
' This ParseError property is for errors and warnings during 'Load'method.
' Applies to IXMLDOMParseError interface.
Public Function ParseLoadErrors (ByVal ObjParseErr)
Dim strResult
strResult = vbCrLf & "<ERROR> INVALID XML! FAILED WELL-FORMED (STRUCTURE) CHECK ! " & _
vbCrLf & ObjParseErr.reason & vbCr & _
@adojos
adojos / parse-XSD-ValidationError.vbs
Last active March 9, 2023 11:02
VBS: Parse XSD Validation Errors #vbs
' The .AllErrors contains errors and warnings found DURING validation. Not valid for Load errors.
' Applies to IXMLDOMParseError2 interface which extends the IXMLDOMParseError interface
Public Function ParseValidationError (ByVal ObjParseErr, ObjXMLDoc)
Dim strResult, ErrFound
ErrFound = 0
Select Case ObjParseErr.errorCode
Case 0
@adojos
adojos / setting_automatic_SSH-Agent.md
Last active December 4, 2024 23:54
Git: Set SSH Agent to Run Automatically for GitBash #gitbash #ssh

Setting Automatic SSH-Agent for GitBash


Using below procedure, you shall be able to setup SSH-Agent to run automatically whenever GitBash is launched on Windows. The ssh-agent process will continue to run until you log out, shut down your computer, or kill the process. Also you may need to add your SSH keys separately unless already loaded or available as per your config.

However the main advantage is that no duplicate SSH-Agent process will be created for successive / multiple Gitbash sessions.

👉 Note: ('$HOME/.bashrc' vs XDG Dir)

The automatic ssh-agent launch can be implemented in two ways i.e

  1. By using '$HOME/.bashrc' in this case it applies to your default bash shell/linux terminal (Method A : Bullet A1-A4)
@adojos
adojos / stringToDate-simpleDtFormat.java
Last active March 9, 2023 11:10
Java: Convert String to Date Using SimpleDateFormat #java
private static void convertToDate() throws ParseException {
String strDate = "2015-06-12";
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormatter.parse(strDate);
System.out.println(date);
}
@adojos
adojos / stringToDate-usingCalendar.java
Last active March 9, 2023 11:02
Java: Convert String to Date Using Calendar #java
private static void convertToCalendar() throws ParseException {
String strDate = "2015-06-12";
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormatter.parse(strDate);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
System.out.println(date);
}
@adojos
adojos / stringToDate-usingLocalDate.java
Last active March 9, 2023 11:01
Java: Convert String to Date Using LocalDate class #java
private static void convertToLocalDate() {
String strDate = "2015-06-12";
LocalDate date = LocalDate.parse(strDate);
System.out.println(date);
}