student visas – Refusal to enter Canada to study, two times

During the last 3 years, I applied 2 times to study in Canada, both times they rejected my request for a study permit. Is it logical that I apply for the third time after 2 times of refusal?

The first time I was admitted to college and I did not have IELTS, so my admission was conditional on taking a language course. The second time I offered high financial documents (to prove that I can handle my cost) and I was accepted from the university and I had an IELTS score of 6.5. The reason for my rejection was based on the purpose of visit section both times.

I am developing a plugin, in it user can specify that timer will run for like 30 minutes for a number of times

User can set that timer will be shown for 30 minutes at for example 1200 hrs on 17th April. and after that 30 minutes timer will run again for 30 minutes for like 5 times(number of times specified by the admin). In this regard any help will be appreciated. I have built the remaining logic of the plugin but I can’t manage the timer. I can run it on frontend but it gets disturbed when user refreshes it. I need it so that timer keeps running on server whether a user is loading the website or not and if a user refreshed page timer does not restarts. Thanks.

postgresql – Postgres connection times out on LAN, but not WAN


Postgres 11,
pg-promise npm module

I have a local network of about 5 machines all running on a Class C configuration.

My postgres is running on 192.168.1.A and is accessible by external connection through NAT and firewalling and my heroku API connects to postgres on 192.168.1.A perfectly.

On 192.168.1.B inside my network I have the dev version of the API running similarly to heroku, on a different machine.

The Problem

192.168.1.B one is persistently giving me a timeout error. The machines are in the same physical location. I’m not sure how to track down why I am getting this timeout error. The setup is very simple.

pg_hba.conf has these lines:

host    all             all               md5
host    all             all                  md5
host    all             all             md5

Heroku log says:

2021-04-16T22:46:10.973041+00:00 heroku[router]: at=info method=GET path="/api/locations" host=<host> request_id=<id> fwd="<an ip>" dyno=web.1 connect=1ms service=735ms status=304 bytes=182 protocol=https

Express on the local dev machine says:

GET /api/locations 500 31647.158 ms - 37

I’m stumped as to why this would happen. The WAN connect works, but the LAN connect times out?

postgresql – Same query taking different execution times on equivalent RDS instances

The train table has around 60million records all of which have their updated_at timestamp in the year 2021. The schema of the table is as below.

                         Table "public.train"
     Column     |            Type             | Collation | Nullable | Default 
 id             | uuid                        |           | not null | 
 updated_at     | timestamp without time zone |           | not null | 
 status         | task_status                 |           | not null | 
 status_details | json                        |           |          | 
    "train_id_updated_at_key" UNIQUE CONSTRAINT, btree (id, updated_at)

I have created a temp table train_temp with the same schema but partitioned on updated_at with Partition key: RANGE (date(updated_at))

I ran the below query to add the train table as a partition to train_temp in an RDS instance that is connected to the application server.

  ALTER TABLE train_temp ATTACH partition train FOR VALUES FROM ('2021-01-01') to ('2022-01-01');

The query takes around 5 minute.

Before running the query I had taken a snapshot of the RDS instance. I restored the snapshot on a couple of instances with the same configurations as the original RDS instance.

But when I run the query in the new instances the query takes around 1hr which is very bizarre since it is the same data in an equivalent instance.

Because of the uncertainty in the execution time, I am not able to come up with a concrete plan on how I could take this to production.

Any help would be much appreciated.

code review – display an input string many times

I’d like to create a function that add 2 to an integer as much as we want. It would look like that:

>>> n = 3 
>>> add_two(n)
Would you like to add a two to n ? Yes
The new n is 5
Would you like to add a two to n ? Yes
the new n is 7
Would you like to add a two to n ? No

Can anyone help me please ? I don’t how I can print the sentence without recalling the function.

Modern PnP Search Box Refreshes Search Results Page 2-4 times

I have a PnP Modern v4 Search Bar on the homepage. I’m using the Method = Query string parameter and Parameter name = q (and tried k).

When I search, it redirects to my custom search page with Modern Search Results web part. The results are filtered based on my search query from before.

The problem is it loads the page initially and then reloads the page 2-4 more times. If use the Search Box on the custom search page and do a search, it doesn’t reload the page like from the homepage. Seems like the only difference I see is that from the homepage, I send to a custom page whereas from the custom search page, I stay on the page.

Error trying to submit webform programatically multiple times: Duplicate entry for key ‘PRIMARY’

I’m trying to programatically send submissions to a webform n times, but when I submit the submission info to the webform for the second time, I get an Integrity constraint violation: 1062 Duplicate entry ‘nnnnn’ for key ‘PRIMARY’ error. It appears the second submission has the same sid as the first submission, but I’m not sure why as I’m submitting NULL for the sid. How can I submit the webform again with the same information, but get a new sid? Drupal 7.

Here is the error in full:

PDOException: SQLSTATE(23000): Integrity constraint violation: 1062 Duplicate entry ‘211-82916-1-0’ for key ‘PRIMARY’: INSERT INTO {webform_submitted_data} (nid, sid, cid, no, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( (:db_insert_placeholder_0) => 211 (:db_insert_placeholder_1) => 82916 (:db_insert_placeholder_2) => 1 (:db_insert_placeholder_3) => 0 (:db_insert_placeholder_4) => Bob ) in drupal_write_record() (line 7471 of /var/www/html/includes/

And the code:

function wildsight_raffle_tickets_webform_submission_insert($node, $submission) {
  if ($submission->nid == 210) {
  $node_out = node_load('211');
  global $user;

  $data = array(
    'first_name' => $submission->data(3)(0),
    'last_name' => $submission->data(4)(0),
    'email' => $submission->data(14)(0),

  module_load_include('inc', 'webform', 'webform.module');
  module_load_include('inc', 'webform', 'includes/webform.submissions');
  // This methods will arrange $data in the right way
  $data = _webform_client_form_submit_flatten($node_out, $data);
  $data = webform_submission_data($node_out, $data);

  $submission_out = (object) array(
    'nid' => '211',
    'uid' => $user->uid,
    'sid' => NULL,
    'submitted' => REQUEST_TIME,
    'completed' => REQUEST_TIME,
    'remote_addr' => ip_address(),
    'is_draft' => FALSE,
    'data' => $data,
  $number_of_tickets = $submission->data(24)(0);
  while ($number_of_tickets > 0) {
    webform_submission_insert($node_out, $submission_out);
    $number_of_tickets -= 1;

algorithms – no of times partion is called in quick sort, assuming array is always halved

In the most even possible split, PARTITION function produces two subarrays, each of size no more than n/2. since one is of size floor(n/2) and one of size ceil(n/2)-1.
The recurrence for the running time will be,

T(n) = 2*T(n/2) + θ(n)

where we tolerate the sloppiness from ignoring the floor and ceiling and from subtracting 1. By case 2 of the master theorem, this recurrence will have the solution

T(n) = θ(nlgn)

My Implementation is as follows:

  if p < r
  q = PARTITION(A, p, r)
  QUICKSORT(A, p, q-1)
  QUICKSORT(A, q+1, r)
  x = A(r)
  i = p - 1
  for j = p to (r - 1)
      if A(j) <= x
          i = i + 1
          exchange A(i) with A(j) 
  exchange A(i+1) with A(r)
  return i + 1

Assuming that the array is always divided into 2 equal halves, how many times is the partition algorithm will be called?

algorithms – Spliting in AVL tree in $O(log n)$ times

Suppose we are given a balanced binary search tree $T$, AVL tree, now
we want split $T$ at a arbitrary node. Can it be done in $O(log n)$?

First i read following links:

  1. Split in AVL tree with complexity $O(log n)$

  2. Trying to understand a way to split an AVL tree in O(log n)

Now i think, because of height of our tree $T$ is $O(log n)$ then after splitting at a arbitrary node, it is sufficient to re-balance our tree $T$ start from one of leaf node, in this manner we do rotation and because of each level want constant number of rotation to be balanced, after $O(log n)$ will be in root of $T$ and our tree $T$ is balanced. Are my argument is true?