Skip to content

Instantly share code, notes, and snippets.

View async-await-forEach-alternatives.md

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

View gist:d5e5939b4e2ec2fe9c4f894fe911f36b
#https://blog.expta.com/2017/03/how-to-self-elevate-powershell-script.html
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
View gist:f119a6db6e97e9d7b48083b2847efb94
MPR
ULONG STDCALL WNetGetUniversalNameA( LPASTR, ULONG, LPBINARY, LPULONG ) as winAPI_WNetGetUniversalNameA
ULONG STDCALL WNetGetUniversalNameW( LPWSTR, ULONG, LPBINARY, LPULONG ) as winAPI_WNetGetUniversalNameW
ULONG STDCALL WNetGetUniversalNameW( LPWSTR, ULONG, LPBINARY, LPULONG ) as winAPI_WNetGetUniversalName
Overwrite any existing DLL_MPR.
From the system monitor type: run DECLARE_FCNS "DLL_MPR"
View TEST_REVCAPI.oibp
Function TEST_REVCAPI(method)
/*
** Purpose: Test calling revCapi
**
** Usage:
** run TEST_REVCAPI 'SUB' to test callsubroutine
** run TEST_REVCAPI 'FUNC' to test callFunction
** run TEST_REVCAPI '' to test CreateRequest
**
@jbratu
jbratu / t_Refresh_blank_rdk.oibp
Created Dec 21, 2021
Code from Revelation Software provided as a Works support request when asking how to programatically create an RDK.
View t_Refresh_blank_rdk.oibp
subroutine t_Refresh_blank_rdk(void)
/*
** Build rdks identical to what comes from RDK window, so can be installed with RDKINSTALL
** But, uses a list of items stored in SYSLISTS.
**
** Creates RDK as a subfolder In the base folder
** rdk_LIST_ID_yyyymmdd contains all source And executables
*/
$insert Logical
View Remove GoToAssist Remote Support.reg
REGEDIT4
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LogMeInInc\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\GoToAssist Express Customer]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LogMeInInc\GoToAssist Express Customer]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\LogMeInInc\GoToManage]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\GoToAssist Express Customer]
[-HKEY_LOCAL_MACHINE\SOFTWARE\LogMeInInc\GoToAssist Express Customer]
View CS_TEST_CREATE_USER_ACCOUNTS
Function test_jab(void)
Password = '123456789012345'
Max = 4000
Offset = 0
For i = 1 To Max
Id = i + offset
UserName = 'USER' : Fmt(ID,"R(0)#21")
View CS_DETACH_VOLUMES_STARTING_WITH.oibp
Function CS_DETACH_VOLUMES_STARTING_WITH(void)
StartingPrefix = '\\server\share\'
StartingPrefixLen = Len(StartingPrefix)
declare function Set_FSError
$Insert Logical
*Readnext through the systables which contains a list of currently attached tables.
TABLE_NAME = "SYSTABLES"
View Atlassian Tips.md

project = "CLIENT" and status != closed ORDER BY createdDate

View TEST_DSBFS_EXEC_SQL
Subroutine TEST_DSBFS_EXEC_SQL( connection_name )
/*
**
** Sample program showing how to use the DSBFS_EXEC_SQL program to
** send a update statement
** Send a select, get results
** Send a parameterized select, get results
** Call a stored procedure
** Call a stored procedures, passing in paramters
**