Skip to content

Instantly share code, notes, and snippets.

View mhf-ir's full-sized avatar

Mohammad Hossein Fattahizadeh mhf-ir

View GitHub Profile
@mhf-ir
mhf-ir / xml_validator.py
Created November 12, 2024 08:29
python server xml validator via xsd
from flask import Flask, request, jsonify
from lxml import etree
app = Flask(__name__)
def validate_xml_against_xsd(xml_content, xsd_content):
# Attempt to parse the XML content
try:
xml_doc = etree.fromstring(xml_content)
except etree.XMLSyntaxError as e:
fs.file-max = 2097152
kernel.core_uses_pid = 1
kernel.msgmax = 65536
kernel.msgmnb = 65536
kernel.panic = 10
kernel.printk = 4 4 1 7
kernel.shmall = 4194304
kernel.shmmax = 4294967296
kernel.sysrq = 0
net.core.netdev_max_backlog = 262144
@mhf-ir
mhf-ir / namespace.py
Last active May 31, 2023 07:56
Namespace generator base on URL
import argparse
import string
import re
import random
from urllib.parse import urlparse
def main():
parser = argparse.ArgumentParser(description='Namespace Generator')
@mhf-ir
mhf-ir / nginx_error.vrl
Last active January 13, 2023 09:41
VRL helpers
nginx_error , err = parse_nginx_log(.message, "error")
if err == null {
if is_string(nginx_error.request) {
method_path, err = parse_regex(nginx_error.request, r'^(?P<method>[A-Z]+) (?P<path>[^\s]+)')
if err == null {
nginx_error.method = method_path.method
nginx_error.path = method_path.path
}
}
@mhf-ir
mhf-ir / sample-event.js
Last active December 22, 2022 06:57
Send sample event
// you must add analytics script into your project first
// put this script any where you like into your js of project, in callback, on load, on click or etc you want
aai.event({
// requirement fields
c: "news", // must be regex: /^[a-z0-9_]{1,31}$/ ... All lowercase include number and `_` min 1 character until 31 character
a: "viewed", // must be regex: /^[a-z0-9_]{1,31}$/ ... All lowercase include number and `_` min 1 character until 31 character
// optional fiedlds
l: "Any thing yo like", // any string you like
@mhf-ir
mhf-ir / hetzner-cloud.yml
Created November 25, 2022 18:59
netplan samples
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
routes:
- to: 0.0.0.0/0
via: 172.31.1.1
on-link: true
addresses: [ 5.5.5.5/32 ]
@mhf-ir
mhf-ir / mime.types.conf
Created October 28, 2022 09:10
nginx mimetype
default_type application/octet-stream;
types {
# essentials
application/xhtml+xml xhtml;
application/xml xml;
application/xslt+xml xsl;
text/calendar ics;
text/css css;
text/csv csv;
@mhf-ir
mhf-ir / ipmi_log.py
Created July 6, 2022 10:03
IPMI Log to json
#!/usr/bin/env python3
import csv
import subprocess
import re
import json
from datetime import datetime
def map_entry(s: str) -> str:
@mhf-ir
mhf-ir / main.go
Created February 8, 2022 15:06
ldap cli test
package main
import (
"crypto/tls"
"errors"
"fmt"
"log"
"os"
"strings"