Skip to content

Instantly share code, notes, and snippets.

View parsibox's full-sized avatar

Mohsen Davari parsibox

View GitHub Profile
```
for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done
or
echo "- - -" | tee /sys/class/scsi_host/host*/scan
lsblk
@parsibox
parsibox / csf_release_no_packet_ip.sh
Created January 28, 2025 16:51
unblocked no droped packet blocked ip from iptables with csf
#!/bin/bash
# Temporary file to store IPs dropped by iptables in DENYIN chain
TEMP_DROPPED_IPS="/tmp/dropped_ips.txt"
# Function to extract IP blocks/ranges being dropped in the DENYIN chain
get_dropped_ips() {
# Extract IP blocks/ranges that are actively being dropped in the DENYIN chain
iptables -vL DENYIN -n | grep 'DROP' | awk '{if ($1 > 0) print $8}' | sort | uniq > "$TEMP_DROPPED_IPS"
}
@parsibox
parsibox / notepad++.reg
Created December 12, 2024 07:25
notepad++.reg for windows 11
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Notepad++]
@="Edit With Notepad++"
"Icon"="C:\\Program Files\\Notepad++\\notepad++.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Notepad++\command]
@="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\""
@parsibox
parsibox / gist:263d0b2a813702064f6ce949b2314351
Created November 1, 2024 17:26
nginx error log get clientip
grep -oP '(?<=client: )[\d.]+(?=,)' /var/log/nginx/error.log | sort | uniq -c | sort -nr | head -n 20
@parsibox
parsibox / gist:557a8e914637d9665f036466a3d5dec8
Created October 17, 2024 09:06
iptables remove duplicated rule
/sbin/iptables-save | awk '/^COMMIT$/ { delete x; }; !x[$0]++' > /tmp/iptables.conf
/sbin/iptables -F
/sbin/iptables-restore < /tmp/iptables.conf
/sbin/iptables-save
@parsibox
parsibox / httpd.conf
Created October 12, 2024 10:02
Apache multipe php
<Directory "D:/wamp64/bin/php/php8.2.18">
Require all granted
</Directory>
ScriptAlias /php-cgi-8.2 "D:/wamp64/bin/php/php8.2.18/php-cgi.exe"
Action application/x-httpd-php8 /php-cgi-8.2
<FilesMatch "\.php8$">
SetHandler application/x-httpd-php8
AllowOverride All
@parsibox
parsibox / linux.bat
Created September 25, 2024 20:10
build compress linux output fast with one click in windows
@echo off
REM Find the first Go file in the folder
for %%f in (*.go) do (
set GOFILE=%%f
goto :found
)
:found
if not defined GOFILE (
echo No Go file found in the current directory.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\NewGoFile]
"Icon"="C:\\Program Files\\Go\\bin\\go.exe"
"MUIVerb"="New Go File"
"Position"="Top"
[HKEY_CLASSES_ROOT\Directory\Background\shell\NewGoFile\command]
@="cmd /c \"echo. > \"%V\\newfile.go\" && notepad \"%V\\newfile.go\"\""
@parsibox
parsibox / CentOS-Base.repo
Created September 21, 2024 14:47
centos 7 repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
@parsibox
parsibox / MyService
Created September 9, 2024 08:03
go windows service
go build -ldflags "-s -w"
PS C:\> sc.exe create MyService <path to your service_app.exe>
PS C:\> sc.exe start MyService
PS C:\> sc.exe delete MyService
// file: main.go
package main
import (