Skip to content

Instantly share code, notes, and snippets.

View stepw66's full-sized avatar

stepw66

  • thailand
View GitHub Profile
@stepw66
stepw66 / backup.sh
Created November 6, 2024 13:28 — forked from siteslave/backup.sh
Backup/Restore HOSxP database.
#!/bin/bash
# Author: GitHub Copilot (adapted by Satit Rianpit)
# Date: October 2024
# Description: This script performs the dumping of HOSxP database tables.
# Usage: ./backup.sh -f /path/to/config_file
# Parameters:
# - -f: Specifies the configuration file to use.
# Returns: 0 if successful, 1 if an error occurs.
# Notes: This script requires the 'zip', 'openssl' and 'mysqldump' commands to be installed.
@stepw66
stepw66 / prioqos.rsc
Created October 21, 2022 14:02 — forked from raphielscape/prioqos.rsc
Priority-based Quality of Service Service for Mikrotik Routerboard
#Set interface here
:local inboundInterface "bridge1"
:local outboundInterface "ether1"
#Set bandwidth of outgoing interface
:local ingoingInterfaceBandwidth '1000M'
#Set bandwidth of ingoing interface
:local outgoingInterfaceBandwidth '1000M'
@stepw66
stepw66 / qos-all.auto.rsc
Created October 21, 2022 13:02 — forked from Bert-Proesmans/qos-all.auto.rsc
Mikrotik Routerboard QOS script
# Creation Date: November 3, 2018
:local Version "2.0"
:local LASTUPDATE "05/10/2019"
# Tested with RouterOS 6.43.4
#
# Mikrotik script to implement QoS on internet connections.
# The script makes use of Address Lists, Firewall rules (Mangle) for connection tagging, and Queue Trees.
# The script will remove applied rules from previous runs before applying.
#
@stepw66
stepw66 / dual.cfg
Created June 22, 2022 14:03 — forked from marfillaster/dual.cfg
Mikrotik dual/triple dhcp wan recursive failover w/ pcc load balancing
/interface bridge add name=bridge
/interface bridge port
add bridge=bridge interface=ether3
add bridge=bridge interface=ether2
add bridge=bridge interface=ether1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
@stepw66
stepw66 / nginx-tuning.md
Created September 21, 2019 02:15 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

#!/usr/local/bin/python
# -*- coding: utf-8 -*-
def lineNotify(message):
payload = {'message':message}
return _lineNotify(payload)
def notifyFile(filename):
file = {'imageFile':open(filename,'rb')}
payload = {'message': 'test'}
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import requests
url = 'https://notify-api.line.me/api/notify'
token = '9IBnp37LVHj0a6W5HLq2dF7sqIjGyEVn2DQtpQq7wYv'
headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer '+token}
msg = 'ทดสอบภาษาไทย hello'
@stepw66
stepw66 / install.bash
Created January 5, 2019 14:15 — forked from isc30/install.bash
Raspberry Pi Install PHP7 + Nginx + MySQL + PhpMyAdmin (last versions)
#!/bin/bash
# Thanks to https://gist.github.com/Lewiscowles1986/ce14296e3f5222082dbaa088ca1954f7
if [ "$(whoami)" != "root" ]; then
echo "Run script as ROOT please. (sudo !!)"
exit
fi
echo "deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi" > /etc/apt/sources.list.d/stretch.list
echo "APT::Default-Release \"jessie\";" > /etc/apt/apt.conf.d/99-default-release
@stepw66
stepw66 / .htaccess - Prevent Script Injection
Created October 4, 2018 15:12 — forked from unix7/.htaccess - Prevent Script Injection
.htaccess - Prevent Script Injection
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
//Source: http://wp.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/