Basheer Kharoti

JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
Dec 21, 2021 16:04
The behavior is quite strange because of fixed navbar so when scrollTo is called from top of the page then it almost cuts the section title into half or when it's from any other section of the page, then it scroll properly into the view.
Dec 21, 2021 16:00
window.scrollTo(0, ele.nextElementSibling.offsetTop - document.getElementsByClassName('page-header')[0].offsetHeight)
Dec 21, 2021 16:00
@KevinB If you would paste this twice then you could see the scrollTo works properly so yeah it's not properly scroll to the exact position
Dec 21, 2021 15:56
You can just paste the script into the console to see the current behavior
Dec 21, 2021 15:56
let ele = document.getElementById('faqs');
window.scrollTo(0, ele.nextElementSibling.offsetTop - document.getElementsByClassName('page-header')[0].offsetHeight)
Dec 21, 2021 15:56
Can anyone please let me know why offsetTop - offsetHeight aren't calculated properly? I would like to add navigation on the top of the menu to navigate user to the FAQs section but it seems the FAQs title is cut into half when doing so. Any suggestion?
Nov 24, 2020 10:29
Has anyone setup angular core project on windows 10? up and running?
Nov 11, 2020 06:25
Nov 11, 2020 06:24
Can anyone please explain why Angular directory does not contain any Fesm or esm/esm2015 directories in Github repo?
Oct 9, 2020 05:01
Anyone with ionic experience? Should I choose the blank template or any other to start working on it?
 

PHP

Support group for those afflicted with PHP. Don't ask to ask, ...
Oct 5, 2021 14:45
Hi folks, just a quick simple question. I have an observer class which listens to two events: save and delete. What should I call it? Is the following name fine for it?

ShipmentTrackAfterSaveOrDeleteObserver.php
Sep 23, 2021 09:48
 find . -mindepth 1 -name "pub/media" -prune -o -exec rm -rf {} +
Sep 23, 2021 09:48
Hi folks, does anyone have any idea to remove all the files recursively except one sub-directory? I tried to do it the following but it deletess "pub/media" as well. Thanks
Sep 18, 2021 16:41
@Danack Cool, thanks.
Sep 18, 2021 16:38
It is an object of type Notification
Sep 18, 2021 16:38
@Tiffany That's true
Sep 18, 2021 16:37
$payload = $this->preparePayload($notification);
$this->httpClient->request('POST', $uri, $payload)
Sep 18, 2021 16:37
I will be using it the following way:
Sep 18, 2021 16:37
@Tiffany Thanks for the reply but the question is about naming a method.
Sep 18, 2021 16:34
private function preparePayload($notification): array
    {

        return [
                Some Foo Response
        ];
    }
Sep 18, 2021 16:34
Hi folks, I was a bit confused about naming a method. Should a prepare method return something or not? If not what should I call it? e.g
Aug 1, 2021 10:36
@Dharman Perfect, thanks
Aug 1, 2021 10:30
What could be unexpected in this class?
Aug 1, 2021 10:29
class SomeValidator {
 public function validate(someRequest) {
      // expecting some validation
     return result;
 }
}
Aug 1, 2021 10:29
@Dharman for this
Aug 1, 2021 10:28
?
Aug 1, 2021 10:28
Could you please just give me a simple practical example
Aug 1, 2021 10:25
@Dharman Other reasons like?
Aug 1, 2021 09:56
What I would prefer is just to get back the errors in ABC class and then throw exception there but rather straightly from the validate method
Aug 1, 2021 09:54
class ABC {
  public function test() {
     $this->someOtherClass->validate(someRequest);
 }
}

class SomeOtherClass {
   public function validate(someRequest) {
    throw SomeExceptionBecauseOfInvalidRequest;
}
}
Aug 1, 2021 09:54
Hello folks, I don't like the following approach for validating and throwing an exception. However, I just want to ask if this a good practice or bad if I see it in a project:
Sep 26, 2020 06:17
 J
   ***
     *
Sep 26, 2020 06:17
I J O L T S Z
Sep 26, 2020 06:17
We only have few letters in this case
 

 Python Ouroboros - The Rotating Knives

Messages from the Python room that didn't meet our standards o...
Feb 14, 2021 07:37
Yup but algorithem has no boundries :D
Feb 14, 2021 07:35
I wasn't sure about the concept.. Language is not a big deal
Feb 14, 2021 07:31
function getSumOfNUsingK($n, $k) {
    $arr = array_fill(0, $n + 1, 0);
    $arr[0] = 1;
    $positionArr[0] = $arr;
    for($i = 1; $i <= $k; $i++) {
        for($j = 0; $j <= $n; $j++) {
            if($i > $j) {
                $positionArr[$i][$j] = $positionArr[$i - 1][$j];
            } else {
                $index = ($j - $i);
                $positionArr[$i][$j] = ($positionArr[$i - 1][$j] + $positionArr[$i][$index]);
            }
        }
        unset($positionArr[$i - 1]);
    }
    return $positionArr[$k][$n];
Feb 14, 2021 07:31
Just figured it out
Feb 14, 2021 07:31
@python_user Although the solution is quite easy
Feb 14, 2021 07:31
There are different ways to tell the same thing :p
Feb 14, 2021 06:04
Number of ways to write N as a sum of K non-negative integers
n = 5, k = 2;
1 + 1 + 1 + 1 + 1 = 5
1 + 1 + 1 + 2 = 5
1 + 2 + 2 = 5


OR
n = 8, k = 2;
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 8
1 + 1 + 1 + 1 +  1 + 1 + 2 = 8
1 + 1 + 1 + 1  + 2 + 2 = 8
1 + 1 + 2  + 2 + 2 = 8
2 + 2  + 2 + 2 = 8
Feb 14, 2021 06:04
Hi Folks, I am little bit confused figuring out partitioning numbers. I would appreciate if anyone could suggest me the direction to how it could be solved:
 
Nov 7, 2020 00:18
@joshk132 What does this array.forEach( represent?
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Oct 31, 2020 16:30
@JonClements even if we keep the tables in one database, each tenant will still have a different table which can be identified through a specific company prefix
Oct 31, 2020 16:14
@JonClements It's e-commerce website where one could extend our platform and create his shop. Alike shopify
Oct 31, 2020 16:13
@JonClements Does that make any difference taking the decision?
Oct 31, 2020 16:05
@roganjosh I think each tenant should have one database
Oct 31, 2020 16:04
Hello folks, what you suggest for SaaS project? A database for each tenant or one database with thousand tables?
Oct 27, 2020 08:24
Just a general question regarding CSRF token for Single Page Application(SPA). Do we really need CSRF token for SPA?