Skip to content

Instantly share code, notes, and snippets.

@elico
elico / RouterOS-Detect-internet-connection.rsc
Last active April 10, 2024 22:09
A demo script to detect by url if a specific interface is up.
{
:do {
:local srcInterface1 "ether1-WAN1";
:local srcInterface2 "ether2-WAN2";
:local srcInterface3 "ether3-LTE";
:local srcInterface4 "pppoe-WAN1";
:local srcInterface5 "pppoe-WAN2";
:local srcInterface6 "pppoe-LTE1";
:local flagInterface "";
@elico
elico / backup-by-email.rsc
Last active March 26, 2024 21:50
RouterOS v7 hardware appliance email backup script
{
:do {
:log info "STARTING BACKUP process";
:local customerNumber "Ac3_Cust.no_1";
:local boardSerial [/system/routerboard/get serial-number];
:local sendMail true;
:local uploadFile false;
:local mailServer "smtp.gmail.com";
:local endpoint www.example.com;
:local wireguardInterface wireguard3;
:local wireguardInterfacePort [/interface/wireguard/get $wireguardInterface listen-port];
:foreach i in=[/interface/wireguard/peers/find where disabled=no endpoint-address=$endpoint] do={
:local LastHandshake [/interface/wireguard/peers/get $i last-handshake];
:if (([:tostr $LastHandshake] = "") or ($LastHandshake > [:totime "5m"])) do={
/interface/wireguard/set 0 listen-port=$wireguardInterfacePort name=$wireguardInterface;
:log warning "fixed wireguard";
@elico
elico / ufdbguard.conf
Created February 12, 2024 10:55
Example ufdbguard
logdir "/var/ufdbguard/logs"
dbhome "/var/ufdbguard/blacklists"
administrator "<a href=mailto:ngtech1ltd@gmail.com> the support desk </a>"
port 3977
interface "all" # only used for TCP sockets
logblock off
@elico
elico / activate-datacenter-2019-vm.ps1
Created November 29, 2023 09:44
Convert Windows Server Evaluation to vm license
# https://learn.microsoft.com/en-us/windows-server/get-started/automatic-vm-activation#avma-keys
# https://stefanos.cloud/kb/how-to-convert-and-activate-windows-server-evaluation-with-purchased-license-keys/
# DISM /online /Get-TargetEditions
DISM /online /Set-edition:ServerDatacenter /ProductKey:H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW /AcceptEula
@elico
elico / wp-htaccess-gen.php
Created November 4, 2023 22:21
Wordpress htaccess generator
<?php
// Define the opening and closing comments to identify the section in .htaccess
$openingComment = "# BEGIN Custom .htaccess Configuration";
$closingComment = "# END Custom .htaccess Configuration";
$requestPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$scriptName = pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_BASENAME);
$requestPath = str_replace('/' . $scriptName, '', $requestPath);
// Decode the percent-encoded characters in the request path
@elico
elico / Dockerfile
Created November 1, 2023 15:02
Redwood simple container build
# Alpine version for the runner contianer
ARG ALPINE_VERSION=latest
# golang builder image
FROM golang:1.21-bullseye AS builder
WORKDIR /build
RUN git clone https://github.com/andybalholm/redwood /build/redwood && \
cd /build/redwood && \
CGO_ENABLED=0 go build -buildvcs=false -pgo=auto -ldflags="-w -s -X 'main.Version=$(git describe --tags)'" -o /build/app . \
&& git clone https://github.com/andybalholm/redwood-config.git /build/redwood-config
@elico
elico / AV.md
Created October 31, 2023 09:23
About Antiviruses
@elico
elico / install-software.ps1
Created October 23, 2023 00:12
An example of installing Chocolatey and using it to install all sort of software by default
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco feature enable -n allowGlobalConfirmation
choco install zoom
choco install everything
choco install virtualbox
choco install adobereader
choco install firefox
choco install googlechrome
@elico
elico / files-in-folder.ps1
Created September 21, 2023 13:15
A helper tool to find duplicate files in a folder
$FirstStageFile = "O:\hashes3.csv"
$SecondStageFile = "O:\hashes3-s.csv"
$Directory = "C:\Users\eliezer\Documents\"
Get-ChildItem -Path $Directory -Recurse -File -Force | ForEach {
[PSCustomObject]@{
FullPath = $_.FullName
Name = $_.Name
Size = $_.Length