Skip to content

Instantly share code, notes, and snippets.

@mean-cj
mean-cj / numberFormat.php
Last active April 14, 2021 12:28
Javascript/PHP numberFormat not round
View numberFormat.php
<?php
// numberFormat not round, PHP Version
// https://stackoverflow.com/questions/3833137
public static function numberFormatNoRound($number, $decimals = 2, $decPoint = '.', $thousandsSep = ',')
{
$negation = $number < 0 ? -1 : 1;
$coefficient = pow(10, $decimals);
$number = ($negation * floor((string) (abs($number) * $coefficient))) / $coefficient;
return number_format($number, $decimals, $decPoint, $thousandsSep);
}
@mean-cj
mean-cj / nginx-tuning.md
Created September 13, 2020 14:54 — forked from denji/nginx-tuning.md
NGINX tuning for best performance
View nginx-tuning.md

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.

View Proxmox_Physical_Disk_Passthrough
# Install if lshw not found
apt-get update
apt install lshw
# Check disk info
lshw -class disk -class storage
# Do this again for every disk
qm set <disk_id> -virtio<number from 2 to 999, remember that you cannot use 1!> /dev/disk/by-id/<disk_long_id>
# (this prints: update VM <disk_id> -virtio2 /dev/disk/by-id/<disk_long_id>)