Skip to content

Instantly share code, notes, and snippets.

View geek-id's full-sized avatar
🌏
Bali

Adhitya R. K. Putra geek-id

🌏
Bali
View GitHub Profile
@geek-id
geek-id / nginx-tuning.md
Created March 19, 2024 05:22 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

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.

wget https://download2.mikrotik.com/routeros/6.38.3/chr-6.38.3.img.zip -O chr.img.zip && \
gunzip -c chr.img.zip > chr.img && \
mount -o loop,offset=33554944 chr.img /mnt && \
ADDRESS=`ip addr show eth0 | grep global | cut -d' ' -f 6 | head -n 1` && \
GATEWAY=`ip route list | grep default | cut -d' ' -f 3` && \
echo "/ip address add address=$ADDRESS interface=[/interface ethernet find where name=ether1]
/ip route add gateway=$GATEWAY
" > /mnt/rw/autorun.scr && \
umount /mnt && \
echo u > /proc/sysrq-trigger && \
@geek-id
geek-id / read_file_hash,py
Created August 2, 2018 13:45
Read all file in directory and create hash
import glob
import hashlib
import time
import os
userdata = glob.glob('/home/geekid/Github/ssl/*')
userdata.sort(key=os.path.getmtime)
def new():
data = ''
@geek-id
geek-id / combined
Last active July 6, 2018 08:01
read_copy.py
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAtVYNkkOkn807L7DwLWU8XdoJar2GpE/i29enFGzTgFTEuYDS
mQCs3crfMmFraTjiMMAKqiFz3ONGmoBchbSgITSAnIZgmxq58ok+LQs67weRzwRd
IK+eZefTjqRuJlnhfFU5qmQYDnf4fsttGHdPjljOZAxoL79Xwvg0lPN/5+CmC11e
jYqoR30n0a9Zvp3i6tk1IJZRTM0HTPoKAA03lilGBK42zPcl1bpC/hW0FVdzlc+Y
ckToJ1RmquNCKx7kOy0E4fGD9ETpnCZbFEbQ8IwSCJu2K+qQCXkcEqUOsFT2MBsp
8dZnaeyaB70JTTYhpIm/Lcokr3K9f+SC/ibn7QIDAQABAoIBADn99kMjjN9qRBZh
cL4j1SVymHZhfFDKF5QVKKLYlt9AvNVShIdX9vDLc4vqKe6xuWy7ze1Q23v111uL
14sPE/LqloL4Wqbf6j3NdGv1XniZJCFflOTiJTcT582DepKbRgh8PP/oGOVvqrHq
Hs6nQXMVpZPLf/pdKBT7Sd2k7e/al4aar+SRFBb8UqSjTW1hDLTjJMFJ9mVDXu8I
@geek-id
geek-id / testing.py
Created March 11, 2017 12:46
Read and write 2 line different location with module fileinput error can't read first line edit and just edit another line
import re, sys, os, fileinput
configFile = 'sshd_config'
if os.path.isfile(configFile) and os.access(configFile, os.R_OK):
# code here
try:
# config = open(configFile, 'r')
with open(configFile, 'r') as searchconfig:
for config in searchconfig:
if 'Port' in config:
@geek-id
geek-id / Rails Note
Created March 8, 2017 15:51
Rails command basic
#### If you want to use SQLite (not recommended)
rails new myapp
#### If you want to use MySQL
rails new myapp -d mysql
#### If you want to use Postgres
# Note that this will expect a postgres user with the same username
# as your app, you may need to edit config/database.yml to match the
# user you created earlier
@geek-id
geek-id / Problem Solving
Last active December 3, 2018 16:25
Problem Solving in Linux
[error]
ImportError: No module named '_gdbm'
[solved]
sudo apt-get install python3.5-gdbm
[error]
ImportError: No module named 'apt_pkg'
[solved]
locate apt_pkg.so
sudo ln -s /usr/lib/python3/dist-packages/apt_pkg.cpython-34m-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/apt_pkg.so
@geek-id
geek-id / config ssh with python
Created March 7, 2017 09:20
Configuration SSH Server with python scripting
import socket, os, re, sys, fileinput
sshFile = 'sshd_config'
bannerFile = 'issue.net'
if os.path.isfile(sshFile) and os.access(sshFile, os.R_OK):
# code here
try:
with open(sshFile, 'r') as searchconfig: