Skip to content

Instantly share code, notes, and snippets.

@MiggieNRG
MiggieNRG / index.md
Created January 2, 2022 17:03
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@MiggieNRG
MiggieNRG / Get-LocalAdmins.ps1
Created January 2, 2022 09:24
Get-LocalAdministrators
function Get-LocalAdministrators {
param ([string]$computername=$env:computername,
[System.Management.Automation.CredentialAttribute()]$Credential
)
$computername = $computername.toupper()
$ADMINS = get-wmiobject -computername $computername -Credential $Credential -query "select * from win32_groupuser where GroupComponent=""Win32_Group.Domain='$computername',Name='administrators'""" | % {$_.partcomponent}
foreach ($ADMIN in $ADMINS) {
$admin = $admin.replace("\\$computername\root\cimv2:Win32_UserAccount.Domain=","") # trims the results for a user
@MiggieNRG
MiggieNRG / GetLocalAdmins.yaml
Created January 2, 2022 09:19
Get All Local Admins
name: Custom.GetLocalAdmins
description: |
Gets a list of local admin accounts
reference:
- https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/get-localgroupmember?view=powershell-5.1
# Can be CLIENT, CLIENT_EVENT, SERVER, SERVER_EVENT
type: CLIENT
@MiggieNRG
MiggieNRG / get-admin.bat
Created January 2, 2022 09:14
Sample batch to run itself elevated
@echo off
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
@MiggieNRG
MiggieNRG / hello.csv
Last active January 2, 2022 08:36
hello.csv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 5.
language,code
Language ▼,
1C-Enterprise,"// Hello World in 1C:Enterprise built-in script language
Message(""Hello, World!"");"
4Test,"// Hello World in 4Test
testcase printHelloWorld()
print(""Hello World!"")"
ABAP4,"REPORT ZHB00001.
@MiggieNRG
MiggieNRG / GetWindowsProductKey.vbs
Created January 2, 2022 07:35
Retrieve Windows Product Key
Option Explicit
Dim objshell,path,DigitalID, Result
Set objshell = CreateObject("WScript.Shell")
'Set registry key path
Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
'Registry key value
DigitalID = objshell.RegRead(Path & "DigitalProductId")
Dim ProductName,ProductID,ProductKey,ProductData
'Get ProductName, ProductID, ProductKey
@MiggieNRG
MiggieNRG / hello.js
Created January 2, 2022 00:57
Repro property set before custom element upgrade
customElements.define('hello-world', class extends HTMLElement {
constructor() {
super()
this.innerHTML = '<div>Hello world!</div>'
}
set mode (mode) {
this.querySelector('div')
.setAttribute('style', mode === 'light'
? 'background: white; color: black;'

Keybase proof

I hereby claim:

  • I am miggienrg on github.
  • I am djmiggie (https://keybase.io/djmiggie) on keybase.
  • I have a public key ASCY3x7xpgw-u8zw1JvyVyCZMsh6UmGI2zDpzFiPHA2V4Qo

To claim this, I am signing this object:

@MiggieNRG
MiggieNRG / styles.less
Created January 1, 2022 16:35
Operator Mono and Fira Code working together in Atom
// ...
atom-workspace,
atom-text-editor {
font-family: "Fira Code";
text-rendering: optimizeLegibility;
font-size: 17px;
font-weight: 400;
line-height: 1.8;