Skip to content

Instantly share code, notes, and snippets.

@jbratu
jbratu / .bashrc color changes
Created March 31, 2023 17:37
bash color changes
View .bashrc color changes
LS_COLORS=$LS_COLORS:'di=0;97;104:' ; export LS_COLORS
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;37m\]\w\[\033[00m\]\$ '
View gist:e580f78d27bc018921025180268be5e5
run attach_table "Z:\OpenInsight\datavol", "REVMEDIA", "SYSPROG", ""
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:

@jbratu
jbratu / gist:d5e5939b4e2ec2fe9c4f894fe911f36b
Created March 24, 2022 14:21
elevate powershell script
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 December 21, 2021 13:10
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"