Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / winrm-https-self-signed-cert.ps1
Created November 11, 2016 23:33
Configure WinRM HTTPS w/ self-signed certificate
# configure
$cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName $env:COMPUTERNAME
Enable-PSRemoting -SkipNetworkProfileCheck -Force
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In)" -Name "Windows Remote Management (HTTPS-In)" -Profile Any -LocalPort 5986 -Protocol TCP
# connect
Enter-PSSession -ComputerName {X.X.X.X} -Credential (Get-Credential) -SessionOption (New-PsSessionOption -SkipCACheck -SkipCNCheck) -UseSSL
@gregjhogan
gregjhogan / gpu-burn.py
Last active March 21, 2024 06:26
gpu burn
import time
import torch
torch.backends.cuda.matmul.allow_tf32 = True
def get_flops(bs, n, t):
flops = (n ** 2) * (2 * n - 1) / t * bs
print(f"{flops/1e12:.2f} TFLOP/s")
def burn_pytorch(dt, n, bs, runtime=10):
@gregjhogan
gregjhogan / jstatd-in-logstash-docker-container.sh
Created February 8, 2024 18:18
run jstatd in logstash docker container
/usr/share/logstash/jdk/bin/jstatd -p 1099 -J-Djava.security.policy=<(echo 'grant codebase "jrt:/jdk.jstatd" { permission java.security.AllPermission; }; grant codebase "jrt:/jdk.internal.jvmstat" { permission java.security.AllPermission; };')
@gregjhogan
gregjhogan / random-string-generator.ps1
Last active February 6, 2024 13:39
Generate random string in powershell
#lowercase letters/numbers only
-join ((48..57) + (97..122) | Get-Random -Count 32 | % {[char]$_})
# all characters
-join ((33..126) | Get-Random -Count 32 | % {[char]$_})
@gregjhogan
gregjhogan / pip-downgrade.sh
Created October 18, 2018 22:00
downgrade pip to a specific version
sudo python -m pip install pip==18.0 --upgrade
@gregjhogan
gregjhogan / install-ghidra-v850-extension-into-flatpak-installation.sh
Created January 14, 2024 21:41
Install Ghirdra v850 extension into flatpak installation
cd /var/lib/flatpak/app/org.ghidra_sre.Ghidra/current/active/files/lib/ghidra/Ghidra/Extensions/
sudo git clone https://github.com/esaulenka/ghidra_v850
sudo ./lib/ghidra/support/sleigh ./ghidra_v850/data/languages/v850e[23].slaspec
cd ghidra_v850/
# TODO: install appropriate version of openjdk first
sudo make
@gregjhogan
gregjhogan / XS748T-disable-short-reach-energy-detect.txt
Last active January 13, 2024 00:15
Netgear XS748T ProSAFE 48-Port 10G switch disable Short Reach Mode and Energy Detect Mode
# short reach mode and energy detect mode can cause ports to turn off even when an ethernet cable is plugged in
# note that this cannot be disabled from the web management interface under System -> Management -> Green Ethernet
# (changing "Auto Power Down Mode" and "Short Cable Mode" settings is disabled)
# enabled telnet from web interface under Maintenance -> Trouble Shooting -> Remote Diagnostics -> Enable
# connect via telnet: `telnet <switch-ip> 60000` (same username/password as web interface)
# only needed if your prompt doesn't end with '#'
enable
# enter config mode
@gregjhogan
gregjhogan / windows-vm-disable-host-time-sync.ps1
Created May 7, 2017 02:41
Windows VM disable the VM IC Time Synchronization Provider
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider -Name Enabled -Value 0
Restart-Service "Windows Time"
# check if domain controller is being used for time
# (you don't want to see VM IC Time Synchronization Provider as the source)
w32tm /query /source
w32tm /query /status
@gregjhogan
gregjhogan / curl-push-azure-storage-blob.sh
Created April 20, 2017 18:13
Push a file to a blob in an Azure storage account
curl -X PUT -T ./{file.dat} -H "x-ms-date: $(date -u)" -H "x-ms-blob-type: BlockBlob" "https://{storageaccount}.blob.core.windows.net/backups/{file.dat}?{sas-token}"
@gregjhogan
gregjhogan / self-extracting_script.sh
Last active November 6, 2023 01:53
self-extracting shell script
# create files in an otherwise empty directory
mkdir files
cd files
touch setup.sh # entry point after extraction
touch file.txt # supporting data used by setup.sh
# create archive
tar -pczf ../archive.tar.gz *
cd ..