Skip to content

Instantly share code, notes, and snippets.

@codykonior
codykonior / test.sh
Last active September 7, 2024 05:14
echo "$SHELL"
import requests
import json
import time
import datetime
import os.path
INTERVAL_TIME = 10
HOST = 'https://...'
CAMERA_NAME = 'Mango'
# Set up an offline username/password in UniFi with Protect read permissions
@codykonior
codykonior / exos.sh
Created March 3, 2024 02:47
Script to compare Seagate EXOS X18 SMART attributes across disks on a Synology device
#/bin/sh
file="/tmp/exos_smartctl"
if [ -f "$file" ] ; then
rm "$file"
fi
sudo smartctl /dev/sata1 -a -v 1,raw48:54,Read_Error_Rate -v 7,raw48:54,Seek_Error_Rate -v 9,msec24hour32,Power_On_Hours -v 188,raw16,Command_Timeout -v 194,raw24/raw32,Temperature -v 240,msec24hour32,Head_Flight_Hours >> "$file"
sudo smartctl /dev/sata2 -a -v 1,raw48:54,Read_Error_Rate -v 7,raw48:54,Seek_Error_Rate -v 9,msec24hour32,Power_On_Hours -v 188,raw16,Command_Timeout -v 194,raw24/raw32,Temperature -v 240,msec24hour32,Head_Flight_Hours >> "$file"
sudo smartctl /dev/sata3 -a -v 1,raw48:54,Read_Error_Rate -v 7,raw48:54,Seek_Error_Rate -v 9,msec24hour32,Power_On_Hours -v 188,raw16,Command_Timeout -v 194,raw24/raw32,Temperature -v 240,msec24hour32,Head_Flight_Hours >> "$file"
sudo smartctl /dev/sata4 -a -v 1,raw48:54,Read_Error_Rate -v 7,raw48:54,Seek_Error_Rate -v 9,msec24hour32,Power_On_Hours -v 188,raw16,Command_Timeout -v 194,raw24/raw32,Temperature -v 240,msec24hour32,Head_Flight_Hours >> "$file"
sudo smartctl /dev/sata5 -
@codykonior
codykonior / How to follow from a drive letter to a physical disk in PowerShell.ps1
Created July 18, 2022 12:22
How to follow from a drive letter to a physical disk in PowerShell
$drive = "C:"
Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object { $_.DeviceID -eq $drive }
$partition = Get-CimInstance Win32_LogicalDiskToPartition | Where-Object { $_.Dependent.DeviceID -eq $drive } | Select-Object -ExpandProperty Antecedent | Select-Object -ExpandProperty DeviceID
$diskDrive = Get-CimInstance -ClassName Win32_DiskDriveToDiskPartition | Where-Object { $_.Dependent.DeviceID -eq $partition } | Select-Object -ExpandProperty Antecedent | Select-Object -ExpandProperty DeviceID
Get-CimInstance -Class Win32_DiskDrive | Where-Object { $_.DeviceID -eq $diskDrive }
let GetPatchTuesday = (timestamp: datetime) {
case(
dayofweek(startofmonth(timestamp) + 07d) == 2d, startofmonth(timestamp) + 07d,
dayofweek(startofmonth(timestamp) + 08d) == 2d, startofmonth(timestamp) + 08d,
dayofweek(startofmonth(timestamp) + 09d) == 2d, startofmonth(timestamp) + 09d,
dayofweek(startofmonth(timestamp) + 10d) == 2d, startofmonth(timestamp) + 10d,
dayofweek(startofmonth(timestamp) + 11d) == 2d, startofmonth(timestamp) + 11d,
dayofweek(startofmonth(timestamp) + 12d) == 2d, startofmonth(timestamp) + 12d,
startofmonth(timestamp) + 13d
)
SELECT DISTINCT
CASE
WHEN ss.EngineEdition = 8
THEN NULL
ELSE d.HostName
END
AS ComputerName,
CASE
WHEN ss.EngineEdition = 8
THEN UPPER(esc.ObjectName)
# As of SQL 2017
/Record @id @type @time
/Record/ConnectivityTraceRecord/ClientConnectionId
/Record/ConnectivityTraceRecord/IsClient
/Record/ConnectivityTraceRecord/LocalHost
/Record/ConnectivityTraceRecord/LocalPort
/Record/ConnectivityTraceRecord/OSError
/Record/ConnectivityTraceRecord/RecordSource
/Record/ConnectivityTraceRecord/RecordTime
@codykonior
codykonior / Get-Interactive.ps1
Last active April 29, 2020 09:58
Determine whether something can accept user input or not
function Get-Interactive {
[CmdletBinding()]
param (
)
-not (
<# Jenkins and other services #>
$false -eq [Environment]::UserInteractive -or
<# Invoke-Command -ComputerName is ASSUMED to be non-interactive #>
$Host.Name -eq 'ServerRemoteHost' -or
<# RSJob, Workflow #>
@codykonior
codykonior / Get-SentryOneLicenseData.ps1
Last active February 10, 2020 08:32
SentryOne License Scrape
$webSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$postValues = @{ Email = "..."; Password = "..."; }
$login = Invoke-WebRequest -WebSession $webSession -Uri "https://my.sentryone.com/login" -Method POST -Body $postValues
$page = Invoke-WebRequest -WebSession $webSession -Uri "https://my.sentryone.com/"
$regex = [regex] 'id="(\d+?)" class="list-group-item serverFriendlyNameContainer sqlSentryItem"'
$ids = $regex.Matches($page.RawContent) | %{ $_.Groups[1].Value }
$keys = @()
$test = @(
[PSCustomObject] @{ IsReady = $false }
[PSCustomObject] @{ IsReady = $true }
)
if ($test.IsReady) {
"Output 1"
}
if ($true -eq $test.IsReady) {
"Output 2"
}