Skip to content

Instantly share code, notes, and snippets.

@belgotux
belgotux / metered.ps1
Created December 23, 2022 14:11 — forked from nijave/metered.ps1
Powershell check if on metered network
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
$cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost()
$cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")
@belgotux
belgotux / actions_connection_event.ps1
Created December 23, 2022 20:39
lunch actions on connection change on windows Event with Task scheduler or via a loop
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
#Task Scheduler on a event :
# Log : Microsoft-Windows-NetworkProfile/Operationel
# Source : actions_connection_event.ps1
# Event ID : 10000
# Action : powershell.exe C:\Scripts\actions_connection_event.ps1
# Condition : unselect !"Start the task only if the computer is on AC power"
@belgotux
belgotux / wrapper_mail.sh
Created December 24, 2022 13:25
Deluge wrapper notification
#!/bin/bash
torrentId=$1
torrentName=$2
torrentPath=$3
mailBin=/usr/bin/mail
subject="[$HOSTNAME] Deluge finished"
body="File ${torrentPath}/${torrentName} is downloaded"
@belgotux
belgotux / 01 - vm with net access
Last active March 16, 2023 09:25
python pip -install offline librairies
mkdir pipdep && cd pipdep
echo pysocks > requirements.txt
echo pyvmomi >> requirements.txt
pip download -r requirements.txt
#rsync pipdep folder to target vm