This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-CertChain { | |
param ( | |
[string]$computername, | |
[int]$port = 443 | |
) | |
#Create a TCP Socket to the computer and a port number | |
$tcpsocket = New-Object Net.Sockets.TcpClient($computerName, $port) | |
#test if the socket got connected | |
if (!$tcpsocket) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# README | |
:' | |
Credit to redditor /u/jvinch76 https://www.reddit.com/user/jvinch76 for creating the basis for this modification. | |
I had been thinking of a script like his to keep my primary and secondary pihole raspberry pis in sync, but could not find the motivation to create it. | |
/u/jvinch76 did the heavy lifting and I made changes I hope you find useful. | |
I modified the code to increase the frequency of the sync to every 5 minutes and reduce the file writes by using rsync to compare the files and only transfer changes. | |
Furthermore, gravity will be updated and services restarted only if files are modified and a sync occurs. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fill in details to remember them. Or use them during setup. Whatever | |
$address = "vpn.vpn.io" | |
$psk = "verysecurepsk" | |
Add-VpnConnection -Name "veryvpn" -ServerAddress $address -TunnelType L2tp -RememberCredential -L2tpPsk $psk -AuthenticationMethod MSChapv2 -EncryptionLevel Required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Check logs in /var/log/unifi/ for clear errors | |
2) stop unifi service (systemctl stop unifi) | |
3) Potentially recover the crashed mongodb database (was crashed in my case) by starting it once from cmdline with a custom data directory (mongod --dbpath /var/lib/unifi/data/db). Then check the output of it to see if the DB was recovered. If it was, continue. If there was no problem, continue. | |
4) Connect to the database (mongo mongodb://127.0.0.1:27017( and run the following command: | |
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ) | |
That should give you the output | |
{ "ok" : 1 } | |
5) Stop the mongodb database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Unzip | |
{ | |
param([string]$zipfile, [string]$outpath) | |
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GToFNKey(keyName) | |
return "F" .. (keyName + 12) | |
end | |
function OnEvent(event, arg) | |
if event == "G_PRESSED" then | |
local key = GToFNKey(arg) | |
PressKey(key) | |
end | |
if event == "G_RELEASED" then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make install of modules a little bit more easier | |
$PSDefaultParameterValues['Install-Module:Scope'] = 'CurrentUser' | |
# For VS:Code | |
$ErrorActionPreference = "Silentlycontinue" | |
# Make the shell nice and h4x0r-style | |
$Shell = $Host.UI.RawUI | |
$Shell.BackgroundColor="Black" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save Factorio-Mod-Pack and probably upload it to a http server via sftp | |
# Assume "normal" installation | |
$SftpServer = 'server.blah.com' | |
$UserName = 'username' | |
$KeyFile = '$env:userprofile\key.pem' # Make sure the keyfile has no password, because posh-ssh is not ready yet | |
$SftpPath = '/var/www/mods.server.blah.com' | |
$FilePath = "$env:appdata\factorio\_mods.zip" | |
# Create an empty Credential-Object because reasons. (to be honest: posh-ssh is not ready yet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove duplicate lines | |
^(.*)(\r?\n\1)+$ -> Replace with $1 | |
# Get the third octett of an IP-Adress: | |
\b\d{1,3}\.\d{1,3}\.\K\d{1,3}(?=\.\d{1,3}\b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Mac = "1A:2B:3C:4D:5E:6F" | |
$MacByteArray = $Mac -split "[:-]" | ForEach-Object { [Byte] "0x$_"} | |
[Byte[]] $MagicPacket = (,0xFF * 6) + ($MacByteArray * 16) | |
$UdpClient = New-Object System.Net.Sockets.UdpClient | |
$UdpClient.Connect(([System.Net.IPAddress]::Broadcast),7) | |
$UdpClient.Send($MagicPacket,$MagicPacket.Length) | |
$UdpClient.Close() |
NewerOlder