Tuesday, August 6, 2024

Windows: Setting a shortcut to a launch a java jar file

Create a shortcut and edit the properties -> Target to; javaw.exe -jar yourjava.jar 

In the example below I'm using fakeSMTP , an smtp server emulator I've mentioned in a previous post.





Friday, August 2, 2024

A couple of PowerShell scripts for IIS I've found handy

 A couple of handy IIS Dumps of sites and virtual directories.

Sites

Import-Module Webadministration
Get-ChildItem -Path IIS:\Sites > d:\allsites.txt

 Virtual Directories

$SiteVirtualDirectories = @()
$Sites = gci IIS:\Sites
foreach($Site in $Sites)
    {
    $VirtualDirectories = gci "IIS:\Sites\$($Site.Name)" | ?{$_.NodeType -match "virtualDirectory"}
    foreach($VirtualDirectory in $VirtualDirectories)
        {
        $SiteVirtualDirectories += @([pscustomobject]@{Site=$Site.Name;VirtualDirectory=$VirtualDirectory.Name;PhysicalPath=$VirtualDirectory.PhysicalPath})
        }
    }

Out-File -FilePath D:\VirtualDirectories.txt -InputObject $SiteVirtualDirectories -Encoding ASCII


Monday, May 20, 2024

ColdFusion: List of common elements between two lists

 A udf for obtaining common list elements courtesy of  https://www.isummation.com/blog/list-common-and-list-compare-in-coldfusion/


<cffunction name="listCommon" output="false" returnType="string">
	<cfargument name="list1" type="string" required="true" />
	<cfargument name="list2" type="string" required="true" />

	<cfset var list1Array = ListToArray(arguments.List1) />
	<cfset var list2Array = ListToArray(arguments.List2) />

	<cfset list1Array.retainAll(list2Array) />

	<!— Return in list format —>
	<cfreturn ArrayToList(list1Array) />
</cffunction>

Friday, November 17, 2023

ColdFusion: Comparing a selected list vs an existing list and determining which needs to be inserted and deleted.

I've seen implementations in code, where in a database update all the records are deleted and new ones are inserted.   Here's a simple method in ColdFusion using underlying Java array methods for determining from a given selection list and current list, which items need to be deleted and inserted. 
<cfscript>
selectedList = "1,2,6"; 
currentList  ="1,2,3,4,5";
selectedArray = ListToArray(selectedList);
currentArray = ListToArray(currentList);
deleteArray = currentArray.clone();
deleteArray.RemoveAll(selectedArray);
insertArray = selectedArray.clone();
insertArray.RemoveAll(currentArray);
WriteOutput("selected");
WriteDump(selectedArray);
WriteOutput("Current");
WRiteDump(currentArray);
WRiteOutput("Deleted");
WriteDump(deleteArray.ToList());
WriteOutPut("Inserted");
WriteDump(insertArray.ToList());
</cfscript>

Wednesday, March 15, 2023