Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# ABOUT THIS SCRIPT
# This script automates the setup of an email server on Alpine Linux using Postfix, OpenDKIM, and PostSRSd.
# It configures all necessary components to send and receive emails securely and handles virtual mailing lists.
#
# USAGE
# 1. Modify the configuration variables below to match your domain and server settings.
# 2. Run the script as root.
# 3. After running the script, ensure that you see the master process, the postsrsd process and the opendkim process in the netstat output that is shown after the script completes.
@henno
henno / konff.rsc
Created April 6, 2024 14:26
mikrotik hAP AC CAP ei lase 5GHz wifisse seadmeid,aga sama CApsmanageri küljes olev AC3 laseb
MikroTik RouterOS 7.14.1 (c) 1999-2024 https://www.mikrotik.com/
Press F1 for help
[T0nu@MikroTik CRS326-24G-2S+IN] > /caps-man/
[T0nu@MikroTik CRS326-24G-2S+IN] /caps-man> export terse
# 2024-04-06 17:19:39 by RouterOS 7.14.1
# software id = TJ0X-IPUB
#
# model = CRS326-24G-2S+
@henno
henno / duh.sh
Last active March 26, 2024 08:05
Disk Usage of Directory Items with Sizes Sorted
#!/bin/sh
find . -maxdepth 1 -mindepth 1 -exec du -sh {} \; 2>/dev/null | sort -h | sed 's|\./||'
@henno
henno / refreshdb.php
Last active March 29, 2024 07:38
Cross-compatible MySQL/MariaDB script ideal for quick resets and creating new dumps while developing, featuring automatic database name detection from config files or current directory name
#!/usr/bin/env php
<?php
// Set the timer
$start = microtime(true);
// Set the default timezone from the system
date_default_timezone_set(json_decode(file_get_contents('http://ip-api.com/json'))->timezone);
// Show the start time
# Enhanced PowerShell Script for MySQL/MariaDB Database Dump and Restore
#
# This script automates dumping and restoring databases using mysqldump and mysql, with support for configuration
# detection and fallbacks. It checks for database configuration in 'config.php' or 'wp-config.php' files, or uses
# the current directory name if no database name is provided. Users can customize behavior through command-line
# arguments for various parameters.
#
# Usage Examples:
#
# 1. Dumping a Database:
@henno
henno / WindowsComputerSetupCommands.txt
Created January 17, 2024 10:37
Windows computer setup commands
powershell
—---------
Invoke-WebRequest -Uri 'https://ninite.com/7zip-chrome-teamviewer15-vscode-zoom/ninite.exe' -OutFile 'C:\Users\admin\Downloads\ninite.exe'
C:\Users\admin\Downloads\ninite.exe
#$ServiceManager = New-Object -ComObject "Microsoft.Update.ServiceManager"
#$ServiceManager.ClientApplicationID = "My App"
#$NewService = $ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")
#add-computer -domainname hummuli.sise -Credential HUMMULI\henno.taht
@henno
henno / ll.ps1
Last active January 12, 2024 07:49
ll for PowerShell
# First type notepad $profile in powershell
# Then paste the following code in the notepad and save it
# Then restart the powershell or type . $profile in powershell
# Then type ll in powershell to see the linux style directory listing
function Get-LinuxStyleChildItem {
Get-ChildItem -Force | ForEach-Object {
$item = $_
$size = if ($item.Length -ge 1GB) {
"{0:N2} GB" -f ($item.Length / 1GB)
} elseif ($item.Length -ge 1MB) {
Get-ChildItem -Recurse | Where-Object { $_.PSIsContainer } | ForEach-Object {
if (Test-Path $_.FullName) {
try {
Set-Location -LiteralPath $_.FullName
$files = Get-ChildItem -Path ./* -include *.jpg | Where-Object { $_.Length -gt 0 }
if ($files.Count -gt 1) {
$groups = $files | Group-Object { $_.Length }
# Set the desired quality for image compression
$quality = 75
# Set the maximum dimensions for resizing while preserving the aspect ratio
$maxDimension = "1920x1920>"
# Set the minimum file size for resizing and compression (500KB)
$minFileSizeForResize = 500 * 1024
# Function to get the date taken from the image's EXIF data
function Get-DateTaken {
param([string]$imagePath)
@henno
henno / addAllEtherPortsToBridge.rsc
Created March 28, 2023 13:07
Mikrotik command to add all Ethernet ports to bridge1
foreach i in=[interface ether find] do={interface bridge port add interface=$i bridge=bridge1}