Skip to content

Instantly share code, notes, and snippets.

@ursuleacv
ursuleacv / quadratic_polynom.php
Created September 10, 2023 19:47
Calculate quadratic polynomial regression
<?php
function quadraticRegression($dataPoints) {
$sumX = 0;
$sumX2 = 0;
$sumX3 = 0;
$sumX4 = 0;
$sumY = 0;
$sumXY = 0;
$sumX2Y = 0;
@ursuleacv
ursuleacv / polyfit.php
Created September 9, 2023 19:44
polyfit equivalent in PHP
<?php
function polyfit($dependentValues, $independentValues, $countOfElements, $order, &$coefficients)
{
// Declarations...
// ----------------------------------
$maxOrder = 5;
$B = array_fill(0, $maxOrder + 1, 0.0);
$P = array_fill(0, (2 * ($maxOrder + 1)) + 1, 0.0);
$A = array_fill(0, (2 * ($maxOrder + 1)) * ($maxOrder + 1), 0.0);
@ursuleacv
ursuleacv / ci.yml
Created February 6, 2021 19:15 — forked from hhamon/ci.yml
Github Actions PHP CI
name: '[PROJECT NAME]'
'on':
push:
branches:
- master
- develop
- 'releases/**'
pull_request: null
env:
working_directory: ./application
@ursuleacv
ursuleacv / System Design.md
Created January 15, 2021 22:46 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@ursuleacv
ursuleacv / nginx.conf
Created July 15, 2020 20:22 — forked from v0lkan/nginx.conf
Configuring NGINX for Maximum Throughput Under High Concurrency
user web;
# One worker process per CPU core.
worker_processes 8;
# Also set
# /etc/security/limits.conf
# web soft nofile 65535
# web hard nofile 65535
# /etc/default/nginx
@ursuleacv
ursuleacv / timezone.html
Created January 29, 2018 15:17
Timezone List
<select name="timezone" id="timezone">
<option>
Africa/Abidjan
</option> <option>
Africa/Accra
</option> <option>
Africa/Addis_Ababa
</option> <option>
Africa/Algiers
</option> <option>
@ursuleacv
ursuleacv / php-fpm.conf
Last active December 18, 2019 04:37
Adjusting child processes for PHP-FPM (Nginx)
Alternate way to find php-fpm size in human readable format.
ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | grep php-fpm
pm.max_children = Total RAM dedicated to the web server / MAXIMUM child process size - in my case it was 85MB
The server has 8GB of RAM, so:
pm.max_children = 6144MB / 85MB = 72
@ursuleacv
ursuleacv / gist:38a8f60b878b3fb5736a5572220fb7c1
Created January 8, 2018 15:10
nginx config tuning for best performance and security
https://www.owasp.org/index.php/SCG_WS_nginx#SSL_Module
https://github.com/denji/nginx-tuning
https://gist.github.com/plentz/6737338
https://gist.github.com/denji/8359866
@ursuleacv
ursuleacv / gist:75cfa7c624d72be3d56894f37c622f7b
Last active June 30, 2017 20:55
Centos Package tuple (…) could not be found in rpmdb
yum clean all
yum update
if doesn't work than
rpm --rebuilddb
yum update
composer dump-autoload
php artisan clear-compiled
php artisan config:cache
php artisan optimize --force