Navigation Menu

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
@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;
}
@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 March 25, 2024 06:03
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 April 17, 2024 04:47
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

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.

@amantheroot
amantheroot / dom.js
Created February 1, 2019 19:19
JavaScript DOM Manipulation cheat sheet by Traversy Media
// EXAMINE THE DOCUMENT OBJECT //
// console.dir(document);
// console.log(document.domain);
// console.log(document.URL);
// console.log(document.title);
// //document.title = 123;
// console.log(document.doctype);
// console.log(document.head);
// console.log(document.body);
@Srushtika
Srushtika / server.js
Last active October 13, 2019 16:55
WebSockets server tutorial
function parseMessage (buffer) {
const firstByte = buffer.readUInt8(0);
const isFinalFrame = Boolean((firstByte >>> 7) & 0×1);
const [reserved1, reserved2, reserved3] = [ Boolean((firstByte >>> 6) & 0×1), Boolean((firstByte >>> 5) & 0×1), Boolean((firstByte >>> 4) & 0×1) ];
const opCode = firstByte & 0xF;
// We can return null to signify that this is a connection termination frame
if (opCode === 0×8)
return null;
// We only care about text frames from this point onward
if (opCode !== 0×1)
@n4ss1m
n4ss1m / tcp_tweaks.txt
Last active April 15, 2024 07:35 — forked from perusio/gist:2154235
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