Skip to content

Instantly share code, notes, and snippets.

View ahmetozer's full-sized avatar
🖐️
Hi , thank you for visiting.

Ahmet ÖZER ahmetozer

🖐️
Hi , thank you for visiting.
View GitHub Profile
@ahmetozer
ahmetozer / IPv4-IPv6-domain-regex.go
Last active December 14, 2023 22:28
Ipv4 - IPv6 - domain Regex Golang
ipv6_regex := `^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$`
ipv4_regex := `^(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})`
domain_regex := `^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$`
match, _ := regexp.MatchString(ipv4_regex+`|`+ipv6_regex+`|`+domain_regex, host)
if match {
fmt.Println("Input is valid")
} else {
fmt.Println("Given input does not match")
re
@ahmetozer
ahmetozer / mirror-wordpress-with-httrack.sh
Created November 30, 2023 14:06
convert or backup your wordpress website with httrack
#!/bin/bash
httrack https://www.yourwebsite.com -i -O "/Users/ahmet.ozer/websites/yourwebsite" \
"*yourwebsite.com*" "-*wp-json*" "-*replytocom*" "-*p=*" "-*/feed*" \
--connection-per-second=50 --sockets=80 --keep-alive --display --verbose \
--advanced-progressinfo --disable-security-limits -s0 -o0 \
-F 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' \
--max-rate=0 --cache 1 --do-not-recatch --purge-old 0
@ahmetozer
ahmetozer / aws-cloud-trail-2-iam-actions.py
Created November 22, 2023 22:20
AWS Cloud Trail Events to IAM actions
import json
f = open('event.json')
data = json.load(f)
actions = {}
for i in data['Records']:
service=i["eventSource"].split(".")[0]
@ahmetozer
ahmetozer / Fix-Screen-Permission-Issue-on-Windows10-WSL.md
Created April 18, 2020 13:50
Fix "Cannot make directory '/run/screen': Permission denied" error

I applied permission to /run/screen folder but every restart requires this fix. So I change the SCREENDIR to home folder. To fix for all users at WSL run below command.

echo 'export SCREENDIR="$HOME/.screen"'

if you start screen outside of bash like command line or scheduled task run with environment variables.

C:\Users\ahmet>bash -c 'SCREENDIR=$HOME/.screen screen'
@ahmetozer
ahmetozer / openvpn-cert-generate.go
Created April 30, 2023 11:11
openvpn certificate creation with golang
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"log"
"math/big"
@ahmetozer
ahmetozer / multiple-exec-at-go-example.go
Created April 20, 2020 16:23
Golang Multiple exec.Command at same time with pipelining
package main
import (
// "fmt"
"os/exec"
"os"
)
func main() {
topCommand := exec.Command("top","-d 0.5", "-b", "-n 5")
@ahmetozer
ahmetozer / time-update.sh
Created March 27, 2022 14:38
Update date and time with curl
#!/bin/sh
function updateDate {
date -s"@$(curl ahmetozer.org/cdn-cgi/tracert -s | grep ts= | cut -d"=" -f2 | cut -d"." -f1)"
if [ "$?" == "0" ]
then
updated="true"
fi
}
if [ "$1" == "service" ] || [ "true" == "$service" ]
@ahmetozer
ahmetozer / Windows-10-custom-theme-fix-color-after-login.md
Created April 14, 2020 07:21
Fix for custom theme color issue after logged in windows

If you install custom theme on your system you might suffer from each login for the re appliying your theme.
To fixing delete Default Colors folder on HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\ path on regedit. Now I hope you not able to get same issue on your computer.

@ahmetozer
ahmetozer / disable-ttyS0_service.sh
Created June 17, 2021 17:04
Timed out waiting for device dev-ttyS0.device.
#/bin/bash
rm /lib/systemd/system/serial-getty\@.service
@ahmetozer
ahmetozer / bash-send-command-telnet.sh
Created May 23, 2021 00:03
Telnet send command without expect
#!/usr/bin/env bash
pipe_loc="/tmp/telnet1"
if [ ! -p $pipe_loc ]; then
mkfifo $pipe_loc
fi
tail -f $pipe_loc | telnet 10.0.0.3 23 &
PID1=$!