Friday, 9 December 2022

Max parallel HTTP connections in a browser to a single website/domain

Untuk Firefox

1. Di address bar firefox ketik about:config

2. Lihat config : network.http.max-connections-per-server dan network.http.max-persistent-connections-per-server  lihat nilainya, bisa dinaikkan sesuai kebutuhan

how to configure maximum number of connections that it will accept from a single client in nginx

Berikut jawaban ChatGPT, jawaban ini perlu divalidasi : 


To configure the maximum number of connections that nginx will accept from a single client, you can use the max_conns directive in the http or server block of your nginx configuration file. For example, to limit the number of connections to 100 for a specific server, you could use the following configuration:

http {

    ...

    server {

        ...

        max_conns 100;

        ...

    }

}

Keep in mind that this directive only applies to connections from individual clients, and not to the total number of connections that nginx will accept. To limit the total number of connections that nginx will accept, you can use the worker_connections directive in the events block of your configuration file. For example:

http {
    ...
    events {
        ...
        worker_connections 1024;
        ...
    }
    ...
}

This will allow nginx to accept a maximum of 1024 connections in total. You can adjust this value as needed to suit your specific requirements.

Please note that this is just an example configuration, and you should adjust the values to suit your specific needs and environment. It is also recommended to consult the nginx documentation for more information on configuring nginx and its various options.

Referensi

  1. Max parallel HTTP connections in a browser?, https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser

Saturday, 3 December 2022

Mengganti seluruh teks yang ada di luar tag.

 Misalkan kita memiliki teks seperti berikut : 

Nusantara_berdikari : [latex]\begin{aligned} \mathrm{Population_t} &= \alpha_1 + \gamma_1 X_{1,t} + \gamma_2 X_{1,t-1} \\ \mathrm{Price_t} &= \alpha_2 + \beta_1 Z_{1,t} \end{aligned}[/latex] Nusantara_sejahtera

Bagaimana mengganti semua "_" menjadi "\_" kecuali yg berada di dalam tag [latex][/latex] ? 

Salah satu solusi dari [1] :

/**
* @param string $text
* @param array $str_to_replace
* @param string $str_replace_with
*/
public static function replaceTextOutsideTags($text = null, $str_to_replace = [], $str_replace_with = ''){
$p = implode('|', array_map('preg_quote', $str_to_replace));
$result = preg_replace("#\[latex\].*?\[\/latex\](*SKIP)(*FAIL)|($p)#i", $str_replace_with, $text);

return $result ;
}

Referensi

  1. preg_replace keywords OUTSIDE of <strong> tags, https://stackoverflow.com/questions/30724791/preg-replace-keywords-outside-of-strong-tags