Skip to content

Instantly share code, notes, and snippets.

View 2-click's full-sized avatar

Jörn "2_click" 2-click

View GitHub Profile
@2-click
2-click / nordvpn-wireguardkeys-powershell.md
Last active November 11, 2024 21:08
Getting NordVPN Wireguard Keys from API with powershell
  1. Go to https://my.nordaccount.com/dashboard/nordvpn/manual-configuration/ and create an access token
  2. Copy token
  3. Use powershell to get Wireguard key
$username = "token"
$password = "<token goes here>"
$pair = "$($username):$($Password)"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$encodedCredentials = [Convert]::ToBase64String($bytes)
$url = "https://api.nordvpn.com/v1/users/services/credentials"
{
"port_table": [
{
"port_idx": 1,
"speed_caps": 1048623,
"op_mode": "switch",
"forward": "all",
"attr_no_edit": true,
"autoneg": true,
"enable": true,
@2-click
2-click / unifi-switch.json
Last active September 15, 2024 09:41
Exxample response UniFi switch
{
"port_table": [
{
"port_idx": 1,
"media": "SFP+",
"port_poe": false,
"poe_caps": 0,
"speed_caps": 1048928,
"op_mode": "switch",
"forward": "all",
@2-click
2-click / gist:46216b77a17e132175a6bb76c4ac42e5
Created August 21, 2024 07:57
Synology surveillance station get MJPEG Streaming path for smarthome
Many smarthome solutions only integrate with MJPEG, not with RTSP. If you have a surveillance station you can use that to "convert" RTSP to MJPEG. One example would be Loxone (https://www.loxone.com/dede/).
Many people don't know this, but while streams can only be shared as RTSP in the GUI of surveillance station, there's a way we can share the stream as MJPEG when using the API.
Login to Synology surveillance station. Then use these links in the browser to get the MJPEG path:
List cameras:
http://synology/webapi/entry.cgi?privCamType=3&version=%228%22&blIncludeDeletedCam=true&streamInfo=true&blPrivilege=false&start=1&api=%22SYNO.SurveillanceStation.Camera%22&limit=2&basic=true&blFromCamList=true&camStm=1&method=%22List%22
# Check for required PowerShell version (7+)
if (!($PSVersionTable.PSVersion.Major -ge 7)) {
try {
# Install PowerShell 7 if missing
if (!(Test-Path "$env:SystemDrive\Program Files\PowerShell\7")) {
Write-Output 'Installing PowerShell version 7...'
Invoke-Expression "& { $(Invoke-RestMethod https://aka.ms/install-powershell.ps1) } -UseMSI -Quiet"
}