PHP

Support group for those afflicted with PHP. Don't ask to ask, ...
Aug 6, 2021 14:42
I use Nginx+PHP-FPM, in the case that nginx logs "upstream prematurely closed connection while reading response header from upstream", will nginx pass the request to the next upstream that is in the load balance configuration, or even use the "backup" server that is in the upstream list?
Jun 18, 2021 13:39
In php-fpm configuration, "request_slowlog_timeout" logs the requests when the script stop running or after the script hit slowlog timeout?
Aug 2, 2020 16:13
1949.32% cpu usage, how is this possible? I have 4 CPU Cores and this script only have the exit command
Aug 2, 2020 16:13
Log format: access.format = "%{REMOTE_ADDR}e - %u %t \"%m %r%Q%q\" %s %f %{seconds}d %{kilo}M %C%%"
Aug 2, 2020 16:13
I have a php script with "exit;" at start of the line, i saw in the access logs this: xx.xxx.xxx - 02/Aug/2020:15:06:38 -0000 "POST " 200 /path/to/script.php 0.001 2048 1949.32%
May 9, 2020 18:53
Ok, i will check it.
May 9, 2020 18:46
process manager:      static
start time:           09/May/2020:20:08:58 -0000
start since:          1818
accepted conn:        21646
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       187
active processes:     13
total processes:      200
max active processes: 50
max children reached: 0
slow requests:        601
May 9, 2020 18:46
In php-fpm, does someone have any idea how it's possible to get 601 slow requests with only 13 active procesess? The server normaly get 2-5 active processes per minute, and there's no slow requests, but when it gets +10 active processes per minute i see a lot of slow requests, could some one point out where maybe is the problem?
May 9, 2020 15:22
I want to create a friends table, which one has the best performance in PHP? A) One row per friend (user id|friendid). Or B) One row per user containing all friends id separated by comma in a column.
Dec 2, 2019 14:20
Does someone know how could it be possible to throw a error about `Invalid datetime format` in the sql when there's no column with date type? `*11132 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\x8C\x8C\xF0\x9F...' for column `db`.`users`.`username` at row 1 in /path/data.php:33
Stack trace:
#0 /path/data.php(33): PDOStatement->execute(Array)`
Nov 28, 2019 14:52
Is it secure if i do it to get data from my own site?
Nov 28, 2019 14:52
stackoverflow.com/a/26151993/10286151 These guys said that it's not secure. But only if i use file_get_contents to get data from a site that is not owned by me?
Oct 11, 2019 15:42
This is the first time i try to compile php from souce. I enabled php-fpm in the ./configure, it's working, but i did not found the file to execute php from command line like php /file.php. Do i need to compile php two times? The first time with php-fpm enabled and the second time without php-fpm enabled?
Sep 17, 2019 08:18
I don't know why but the php script hangs when i use php-ffmpeg (to extract frame) in a loop, it usually stops at the third loop, it only happen when i use a url instead of a local file. But i realized that if i put a `sleep()` of 60s everything works, and if i change it to 30s it also works but sometimes i get a error `Symfony\Component\Process\Exception\ProcessTimedOutException: The process <ffmpeg code> exceeded the timeout of 300 s
econds. in /home/lib/vendor/symfony/process/Process.php:1233`, it's so strange.
 

JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
Jun 15, 2021 20:13
I want to update a JSON file, i want to get the best performance, is it better to use exec() function with a bash program like "sed/grep/jq" or it will be the same if i just open the file to update the content inside the js script? The JSON file is around 2-10MB, and my script will need to update the JSON file each some seconds.
Sep 23, 2020 15:34
Dos someone here use SWR with React? I want to know what is the best way to stop the "onErrorRetry" when the user switch the route. Maybe using redux? I'm kinda new. The only option i saw was to use Redux or Context API to store the setInterval id that is used in "onErrorRetry" function, and then call the clearInterval at the beginning of each route component.
Aug 23, 2020 15:50
I use postgresql JSON datatype, so the JSON is already formated
Aug 23, 2020 15:48
All these people that use JSON and JS to display page content, why don't parse the JSON in front-end? I started working with JSON and i saw that i can increase the number of requests per second my app can handle in ~ +30% if i send the JSON in plain/text
Feb 10, 2020 20:23
can you tell me why replacing <> is not enough?
Feb 10, 2020 20:21
@JBis i also need to append some html, so i would need to append the html first then i get the element and use text()? Or there's a better way?
Feb 10, 2020 20:05
function sanitize(string){
    const map = {
        '<': '&lt;',
        '>': '&gt;'
    };
    return string.replace(/[<>]/ig, (match)=>(map[match]));
}

string = sanitize($('textarea').val());
Feb 10, 2020 20:05
i'm building a chat, i get user input this way: string = $('textarea').val(), then i append it to html, i want to prevent xss, replace <> is enough? I'm using this function:
Feb 6, 2020 16:32
Can node run in background? I tried nohup node app.js &, but it does not work as i expected. In app.js i created a connection for mysql and then it sends notification for some users using the web-push module. I don't want to wait for the execution of app.js to finish. I don't know why the nohup is not working, is it suposed to work in node? It is not working only on node.
Jan 27, 2020 21:57
i will try it
Jan 27, 2020 21:54
sad...
Jan 27, 2020 21:47
I can put the video in full screen at the first time when the event is fired, but the second time it's blocked, and show this warning
Jan 27, 2020 21:45
Is it possible to put a video in full screen automatically without showing this warning? Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
Jan 27, 2020 21:41
Do the browser know the diference between a click from a funcion like .click() or a real click made by the user?
Dec 30, 2019 17:52
Is it bad (to performance or something else...) if i change the version of indexeddb on page load? I'm doing it because the browser is not triggering the onupgradeneeded to create the object storages, if i clear the cookies
Dec 6, 2019 16:48
Is it possible to update service worker with background sync? Today i received two push notifications from youtube saying "This website was updated in background"
Nov 29, 2019 11:58
ok, i will use another event to remove this red div
Nov 29, 2019 11:52
only after the .sub_div is removed, so i need to click it twice to trigger the click event
Nov 29, 2019 11:51
i know that it's not working because of the blur event. but as you can see: jsfiddle.net/k6gjrv8b/1 i removed the code that removes the button on blur, and the button still don't trigger the click event
Nov 29, 2019 11:46
the .click_btn is inside the $('input').on('focus', take a look
Nov 29, 2019 11:45
i removed and it did not worked: jsfiddle.net/rbgpkny5
Nov 29, 2019 11:32
could someone tell me why the one('click' is not working? jsfiddle.net/y6L1uk23
Nov 26, 2019 23:02
there's a event called onversionchange for indexedDB, developer.mozilla.org/en-US/docs/Web/API/IDBDatabase/… says that i need to refresh the page or use the new opened tab (after update db), but when i refresh the page the browser does not use the new version of db. It works this way? Or i need to implement some kind of logic to tell the browser to use the new version on refresh?
Nov 22, 2019 16:23
@JBis After i tried to use this http module i realized why it was not working. I got a extra slash in the ProxyPass, so all the requests was goint to //subscribe, and because it was serving the files from the client folder i misunderstood the logic of the nodejs server
Nov 22, 2019 13:11
I'm not sure, but i lost some time trying to implement this in apache, but did not worked. In the github link on index.js, there's this line: app.use(express.static(path.join(__dirname, "client"))); i could not make it work without it, and as you know, this line sets the the path to a static website
Nov 22, 2019 13:08
I want to use service worker api, i saw some tutorials and made it work, but looks like the website needs to be hosted in nodejs server. I want to know if i can run my website on apache/nginx and run only the push api server on nodejs, is it possible? github.com/bradtraversy/node_push_notifications
Nov 11, 2019 03:00
well even if i have a php server, i can cache the page with a service worker, which is in javascript, anyways i did not thought that someone would even know something about, as i said, i did not found it on google
Nov 11, 2019 02:58
php server
Nov 11, 2019 02:57
i'm serving the page from server
Nov 11, 2019 02:57
@JBis do you know what is a service worker, right? In the service worker i can cache everything. Do you if there's another way to cache and serve a page (example: /index.php) from the cache? I did not find nothing about it on google
Nov 11, 2019 02:53
Is there any other way to cache and serve a page from cache, like the service worker do? I don't want to use service worker because it have some problems about out of date content from cache, and i don't want to display a button saying the user to refresh the page to get the new content
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Oct 7, 2019 20:21
@AndrasDeak Not at all. but if i can't resize it, then why the guy in the tutorial does? He is using a dataset with 24K images, and i'm using a dataset with 8K images, his array would be even more bigger then mine
Oct 7, 2019 19:59
does someone know how can i reshape a array using numpy reshape? I mean, in the tutorial i'm following the guy used this code: X = np.array(X).reshape(-1, img_size, img_size, 1), but it's not working because he was using a old version of numpy i think. I tried to reshape it in some different ways but none works. The last thing i tried was: X = np.array(X).reshape(img_size, img_size) but i get this error: ValueError: cannot reshape array of size 80000000 into shape (100,100)
Oct 5, 2019 17:30
i just want to know how to create a a Q Table for a simple environment
Oct 5, 2019 17:29
People don't like Q-Learning? I made a simple question, but there's no answer, could someone help? stackoverflow.com/questions/58243791/…
Sep 24, 2019 21:43
why do i need to import built in modules in python? Is it to make the code to run faster? (If all modules is not used/imported).