Skip to content

Instantly share code, notes, and snippets.

View komputronika's full-sized avatar

Komputronika komputronika

View GitHub Profile
@komputronika
komputronika / tcp_tweaks.txt
Created April 15, 2024 07:35 — forked from n4ss1m/tcp_tweaks.txt
High performance tuning of Nginx
## From a post on the ML, apropos this:
## http://lowlatencyweb.wordpress.com/2012/03/20/500000-requestssec-modern-http-servers-are-fast.
## For sysctl.conf
net.ipv4.tcp_slow_start_after_idle = 0
echo "1768 64512" > /proc/sys/net/ipv4/ip_local_port_range
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery => Vanilla JS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
php -v
pecl version
sudo apt-get install php7.4-dev -y
sudo apt-get install php-pear
sudo apt-get -y install gcc make autoconf libc-dev pkg-config -y
sudo pecl channel-update pecl.php.net
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.3 # 7.4
# php 7.4
@totoprayogo1916
totoprayogo1916 / customPagination.php
Last active January 10, 2024 08:36
Codeigniter 4 Pagination (manual setting $limit & $offset)
$page = (int) $this->request->getGet('page'); //
$limit = config('Pager')->perPage; // see Config/Pager.php
if (!isset($page) || $page === 0 || $page === 1) {
$page = 1;
$offset = 0;
} else {
$offset = ($page - 1) * $limit;
$page = $page;
}
@jgodson
jgodson / Cookies.js
Created June 21, 2020 15:27
Functions to manipulate cookies for various purposes
window.Cookies = window.Cookies || {};
// Prevent IE8-9 silent errors
if (!window.console) {
  window.console = {
    warn: function() {}
  }
}
/*
@terryupton
terryupton / page.twig
Created April 5, 2020 18:34
Ajax Request using alpineJS
<button
@click="showModal = !showModal | fetch('{{ entry.url() }}', {
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XmlHttpRequest'
},
}).then(res => res.text()).then(text => { html = text })"
class="flex justify-center animate-grow-on-hover--small"
>
@lantip
lantip / save_screenshot_with_select.py
Last active May 17, 2019 10:41
Script untuk menyimpan tangkap-layar dari laman KPU, dengan terlebih dulu memilih TPS
# Sebagai kelanjutan dari script saya sebelumnya (save_screenshot.py)
# Script ini membuka laman kpu, memilih berurutan Propinsi, Kabupaten, Kecamatan, Kelurahan dan TPS
# Di penghujung proses, dilakukan penyimpanan screenshot.
# Sebagai POC, saya batasi saja 5 TPS
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from datetime import datetime
import time
@mohanpedala
mohanpedala / nginx_performance_tuning.md
Last active October 29, 2024 13:01
NGINX Performance tuning

NGINX Performance Tuning

Content Compressions and Decompression

  • Documentation
    • NGINX http_gzip module
    • NGINX http_gunzip module
  • Enable gzip. by default, we’re not going to compress the responses that we’re getting from proxied servers or any piece of content that isn’t HTML.
  • But if one of our proxied servers happens to send us a pre-compressed response then we probably want to decompress it for clients that can’t handle gzip. In this situation, we’ll use the gunzip module
    $ vim /etc/nginx/nginx.conf
@aliesbelik
aliesbelik / benchmarking-tools.md
Last active October 28, 2024 15:03
Benchmarking & load testing tools
@Ashrafdev
Ashrafdev / nginx-tuning.md
Created February 13, 2019 08:33 — 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.