Skip to content

Instantly share code, notes, and snippets.

View asheroto's full-sized avatar
:electron:
Calculating Universe

asheroto

:electron:
Calculating Universe
View GitHub Profile
@asheroto
asheroto / #Wait-ForKeyOrTimeout.ps1
Last active August 6, 2024 08:36
PowerShell script to wait for a key press or countdown from a specified timeout with in-place countdown display.
Function Wait-ForKeyOrTimeout {
param (
[int]$Timeout = 10
)
for ($i = $Timeout; $i -ge 0; $i--) {
Write-Host -NoNewline "`rPress any key to close... (Closing in $i seconds) "
if ([System.Console]::KeyAvailable) {
[void][System.Console]::ReadKey($true)
@asheroto
asheroto / Get-AdobeAcrobatReaderDCUrls.ps1
Last active August 1, 2024 19:45
Retrieve direct download URLs for Adobe Reader DC by parsing the release notes page.
[CmdletBinding()]
param ()
# Function to get the latest version and download URL of Adobe Acrobat Reader DC
function Get-AdobeAcrobatReaderDCUrls {
[CmdletBinding()]
param ()
# URL of the Adobe Acrobat Reader DC release notes page
$apiUrl = 'https://helpx.adobe.com/acrobat/release-note/release-notes-acrobat-reader.html'
@asheroto
asheroto / Open-GitHubRepo.ps1
Last active August 1, 2024 06:47
Open the GitHub repository for the current folder in your default web browser. Use parameters to open issues, pull requests, and more.
function Open-GitHubRepo {
param (
[switch]$Issues,
[switch]$Branches,
[switch]$PullRequests,
[switch]$Actions,
[switch]$Projects,
[switch]$Releases,
[switch]$Debug
)
@asheroto
asheroto / Disable-WooCommerce-Payment-Method-Message.php
Last active April 18, 2024 06:26
Disable WooCommerce payment method using warning/alert message instead of removing. Show the payment method, just disable it with a warning/alert message.
/****************************************************************************************
* START - Disable a payment gateway and show a custom message in WooCommerce
****************************************************************************************/
/**
* Define constants at the top for easy configuration.
*/
define('DISABLE_GATEWAY_ID', 'plisio');
define('DISABLE_MESSAGE', '<div class="woocommerce-error">Cryptocurrency payments are temporarily unavailable while we improve the payment process.</div>');
@asheroto
asheroto / README.md
Last active August 23, 2024 14:05
Strip PowerShell output that contains spinner, progress bar, or more than one empty line.

Strip-Progress

Strip PowerShell output that contains spinner, progress bar, or more than one empty line. Fixes download progress formatting by effectively removing extra space after the slash, often seen in winget (example 269 MB / 305 MB).

When to use

This function can be beneficial when you're capturing the output stream of a command, but don't want the extra characters in the text. See examples. Works great with winget.

Usage

@asheroto
asheroto / README.md
Last active February 3, 2024 00:16
Easily install and configure GeoIP for use with iptables which enables you to block/allow entire countries.

Configure GeoIP for iptables

This script configures GeoIP for use with iptables. Installs Linux headers, uses xtables-addons, uses latest db-ip.com database, fixes dependencies, loads xt_geoip module.

Supports colored message using ANSI escape codes. 😎

Script Functionality

@asheroto
asheroto / README.md
Last active February 4, 2024 04:28
Example of daemonized teler

Example of daemonized teler

This example turns teler into a service, then implements inotifywatch to monitor the configuration file for changes. This way teler will automatically load on start on boot, and when config.yaml changes the teler service will restart and load the changes.

Steps

  1. Install inotify-tools
apt-get -y install inotify-tools
@asheroto
asheroto / Disable-EdgeAnnoyances.reg
Last active July 21, 2024 03:42
Disable annoying Microsoft Edge first run experience, implicit sign-in, disable shopping, rewards, default browser campaign, auto import, forced sync, sidebar, restore browser reminder. Shows home button, enables SmartScreen.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\Recommended]
"UserFeedbackAllowed"=dword:00000000
"AutoImportAtFirstRun"=dword:00000001
"SmartScreenEnabled"=dword:00000001
"PersonalizationReportingEnabled"=dword:00000000
"ShowRecommendationsEnabled"=dword:00000000
"ForceSync"=dword:00000000
"SyncDisabled"=dword:00000001
@asheroto
asheroto / Install-Font.ps1
Last active January 29, 2024 19:21
PowerShell function to install fonts on Windows. Supports both individual and bulk file installations. Offers wildcard and recursive directory searching. TTF and OTF fonts supported by default.
Function Install-Font {
<#
.SYNOPSIS
Installs fonts from a specified path on Windows systems.
.DESCRIPTION
The Install-Font function supports handling individual font files, directories containing multiple fonts, and wildcard paths. It also supports recursive search for font files in the specified path and all its subdirectories. The function is capable of installing both TTF and OTF font types.
.PARAMETER Path
Specifies the path to the font file(s). This can be a path to an individual font file, a directory containing font files, or a wildcard path. The function accepts both relative and absolute paths.
@asheroto
asheroto / Create-NewOutlookEmail.ps1
Last active July 7, 2024 00:19
Create e-mails in Outlook using PowerShell. Select account, keep default signature, keep original formatting, produce valid HTML.
function Create-NewOutlookEmail {
param (
[Parameter(Mandatory = $true)]
[string]$To,
[Parameter(Mandatory = $true)]
[string]$Subject,
[Parameter(Mandatory = $true)]
[string]$Body, # Expecting HTML formatted string