## Checking for a new version from WP Repos

I would like to know if there is a new version from the official WP Repos for a specific plugin.

How can I check for this in json/xml format? Or other format maybe?

Something like this: https://api.wordpress.org/core/version-check/1.7/

But for each single plugin in the WP repo

## google sheets – Checking if a value is within one of many possible ranges

I have the following table, with two rows. The first value in each row is the “minimum difference” between terms. The rest is a series of numbers at least that far apart from each other, but could be more, for example the first few numbers in row one can also be like so: `60 | 0 60 140 210 270 ...`.

``````60  | 0 60  120 180 240 300 360 420 480 540 600
90  | 0 90  180 270 360 450 540 630 720 810 900
``````

What my goal here is that given a few external values, offset, time and duration. I would like to check if that time falls within a specified window.

So for example:
If the offset is `4`, and the duration is `15`. Then I would like to check if the time falls in any of the following ranges (for example row `1`):

`4 - 15`, `64 - 79`, `124 - 139`.

However one small issue I am having is I don’t know how to do the next part, which is if the values are separated by a time of minimum difference + offset or more, then we just start at the given time. And discount any offset usage after that fact. So for example:

`60 | 0 60 140 200 280 ...`.

Then the windows would be:

`4 - 15`, `64 - 79`, `140 - 155`, `200 - 215`, `280 - 295`.

How can I accomplish this?

## performance – Checking the type and validity of a credit card with Luhn’s algorithm in C (CS50)

I’m taking CS50 Intro to CS. In this assignment, we’re asked to make a program that can identify what type of credit card (AMEX, Visa, MasterCard) is given in the input (and whether it is valid.) Validity is checked using Luhn’s Algorithm. Here’s how the algorithm works:

1. Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products’ digits together. (We’re not adding the products together, rather the digits of the products!)
2. Add the sum to the sum of the digits that weren’t multiplied by 2.
3. If the total’s last digit is 0, the number is valid!

Then, the type of credit card is checked by checking the first few digits of the credit card. I.e American Express numbers start with 34 or 37, VISA starts with 4, etc etc. Here’s my implementation:

``````#include <stdio.h>
#include <cs50.h>
#include <math.h>
#include <stdlib.h>

bool check_is_card_valid(long card);
int checksum(long card);
bool array_consists(const unsigned int arr(), int val, int arrlen);
string get_card_type(long card);
int get_nth_digit(long card, int digit);
int get_card_length(long card);

const unsigned int accepted_card_length() =
{
15, // AMEX uses 15 digit numbers
16, // MasterCard and VISA uses 16 digit numbers
13  // VISA uses 13 digit numbers
};
const size_t acc_card_len = sizeof(accepted_card_length) / sizeof(*accepted_card_length);
const unsigned int AMEX_first_digits() = {34, 37};
const size_t amex_digits_len = sizeof(AMEX_first_digits) / sizeof(*AMEX_first_digits);
const unsigned int MASTERCARD_first_digits() = {51, 52, 53, 54, 55};
const size_t mc_digits_len = sizeof(MASTERCARD_first_digits) / sizeof(*MASTERCARD_first_digits);
const unsigned int VISA_first_digit = 4;

int main(void)
{
long card_number = get_long("Card number: ");
if (check_is_card_valid(card_number) == true)
{
printf("%sn", get_card_type(card_number));
}
else
{
printf("INVALIDn");
}
}

/*
Luhn's algorithm. Starting from the right, multiply every other digit by 2 and add up the digits
add this sum to the sum of the digits that were not multiplied by 2.
*/

int checksum(long card)
{
int checksum = 0;
for (int i = 0; i < get_card_length(card); i++)
{
if (i % 2 == 0)
{
checksum += get_nth_digit(card, i);
}
else if (i % 2 == 1)
{
int num = get_nth_digit(card, i) * 2;
if (num > 9)
{
num = get_nth_digit(num, 0) + get_nth_digit(num, 1);
}
checksum += num;
}
}
return checksum;
}

bool array_consists(const unsigned int arr(), int val, int arrlen)
{
for (int i = 0; i < arrlen; i++)
{
if (val == arr(i))
{
return true;
}
}
return false;
}

// Luhn's algorithm states that if the last digit of the checksum is 0, it is valid
bool check_is_card_valid(long card)
{
if (array_consists(accepted_card_length, get_card_length(card), acc_card_len) == true)
{
return checksum(card) % 10 == 0;
}
else
{
return false;
}
}

string get_card_type(long card)
{
int card_length = get_card_length(card);
int first_digit = get_nth_digit(card, card_length - 1);
int second_digit = get_nth_digit(card, card_length - 2);
int first_two_digits = (first_digit * 10) + second_digit;
if (first_digit == VISA_first_digit)
{
return "VISA";
}
else if (array_consists(AMEX_first_digits, first_two_digits, amex_digits_len) == true)
{
return "AMEX";
}
else if (array_consists(MASTERCARD_first_digits, first_two_digits, mc_digits_len) == true)
{
return "MASTERCARD";
}
else
{
return "INVALID";
}

}

// gets nth digit from the right, starting with 0, using modulo
int get_nth_digit(long card, int digit)
{
return fmod(floor(card / pow(10, digit)), 10);
}

int get_card_length(long card)
{
return floor(log10(card)) + 1;
}

``````

I would like some feedback on my code and how I could improve it; things like style, readability, cleanness, efficiency, etc. Is my code easily understandable? What about the comments – is there not enough comments? I try not to comment on my code when the function of something seems obvious. How do I improve the style, and are there any code conventions I’m not following? Can I optimize this to make it a faster process? Or maybe there’s a better way to do the same thing? Basically, how do I improve my code?

## c++ – What’s the maths behind checking line of sight

I understand in unity there is Phsyics.LineCast(Vector A, VectorB). What’s the maths behind doing that, the only thing i can think of is going along the line at small intervals and seeing whether it collides with an object or setting the line as a cuboid with a small width and height but depth equal to vector1-vector2 but then that would be non-axis aligned cuboid collision which seems pretty expensive.

Could anyone help me on this?

## Checking uniqueness of a maximum unweighted matching on a bipartite connected graph

Given a maximum unweighted matching $$M$$ on a bipartite connected graph $$G = (A cup B, E)$$, a maximum matching is unique exactly when for all matchings $$M’ neq M$$, the following is true: $$|M’| < |M|$$

1. Given the maximum matching $$M$$, find an efficient algorithm that checks, if the maximum Matching is unique. Prove the correctness of your approach.

2. Given a perfect matching $$M’$$ in $$G$$ ($$|M’| = |A| = |B|$$) – Describe an efficient algorithm that checks for a given edge $$e in M’$$ whether there is an alternate maximum matching, which does not contain $$e$$

My ideas:

I think for the first one, it’s probably something using an augmenting Path. I figure if you find a path where every other edge is matched, that either ends in a cycle or on a node with no matched edge connecting to it, you would be able to get it, but I have no idea to turn that idea into an efficient algorithm.

For the second question, I guess you would probably also use an augmenting path, starting with $$e$$, probably something similar to the first one, I imagine

## model checking – Is there a tool that can check whether m |= p holds, where m and p are both ltl formula

Yes, you can use an LTL-to-Buchi-automaton translator for this.

Let’s assume that you want to check if $$psi rightarrow psi’$$ is a valid LTL formula, i.e., every word satisfying the LTL property $$psi$$ also satisfies the LTL property $$psi’$$. This case is equivalent to finding out if $$psi wedge neg psi’$$ is satisfiable. Your $$psi models psi’$$ notation is another way of writing this, but I would avoid it since the $$models$$ relation is often defined differently in current research papers on the topic.

If we translate $$psi wedge neg psi’$$ to a Buchi automaton, we can easily check if its language is empty. In fact, optimizing LTL-to-Buchi translators remove states with an empty language, and hence you only need to check if the resulting automaton has no accepting state.

On example LTL-to-Buchi translator is ltl3ba. For instance, if you want to check if $$mathsf{F G },a$$ implies $$mathsf{G F},a$$, you can do that as follows:

``````./ltl3ba -f "(F G a) && !(G F a)"
``````

Here, “-f” stands for “translate this formula that is given as a parameter”.

The result is given in SPIN never claim form:

``````never {    /* (F G a) && !(G F a) */
T0_init:
false;
}
``````

There is no state ending with “_accept” in the name, which means in the SPIN never claim notation that there is no accepting state. So $$(mathsf{F G },a) wedge neg (mathsf{G F},a)$$ is not satisfiable.

There is also at least one LTL-to-Buchi translator with a web interface, namely the one from the SPOT framework.

## python – Confusing behavior when checking for values in a pandas series which contains both strings and integers

I have a pandas series of `dtype: object` that contains both numbers and characters. When I wanted to check if a certain value exists in that series I got confused by the way how the existence of a certain value is checked.

For the example below, I would intuitively expect, that `'a'` is in the series and also `'1'`. Furthermore, I wouldn’t expect that the (integer) value `1` exists in the series, because AFAIK the `dtype: object` in pandas can be (roughly?) compared with python’s string type.

Does anyone has an an explanation for this behavior?

``````s = pd.Series(('a',1,2))

if 'a' in  s:
print('a is in s')
else:
print('a is not in s')
if '1' in s:
print('string 1 is in s')
else:
print('string 1 is not in s')
if 1 in s:
print('integer 1 is in s')
else:
print('integer 1 is not in s')
``````

Output:

``````a is not in s
string 1 is not in s
integer 1 is in s
``````

## Google Sheets – Checking values for specific criteria based on another cell’s value

I have some raw data and I’m looking to create a “dashboard” of sorts that would list out the learner and whether or not they’ve completed a learning plan based on their worksite. In the “inputs” tab I’ve noted which learning plan (and thus which courses) is required per site. So, for example, if a learner’s worksite is “BP” then they should either have completed the learning plan titled ‘HC – Refresher Training – BP – V3 (Chinese Subtitles)’ or ‘HC – Refresher Training – BP – V3’ since those are the only two learning plans that can be assigned at the “BP” worksite per the inputs tab. I’m not really sure what steps to take to get to my end result, if that makes sense. Is there a way to set up this spreadsheet so that I am able to list out the learners and the progress of the entire learning plan (based on the inputs sheet) for each individual learner? I would also like this spreadsheet to be flexible. So, for example, maybe I’d like to display the progress of all learners with the worksite “BP” and list their progress with their current learning plan and a date (so that it can be sorted with the most recent dates listed first). My mind is just as flustered as this question so please don’t hesitate to ask follow up questions!

Quick Update: This formula sort of works

``````=IF(ISBLANK(\$G2),"",IF(AND(SUMPRODUCT(--(\$G2=Inputs!\$J\$2:\$J\$40))>0&SUMPRODUCT(--(\$A2=Inputs!\$G\$2:\$G\$40))>0&SUMPRODUCT(--(\$H2=Inputs!\$H\$2:\$H\$40))>0,\$J2="Complete"),"Complete","Incomplete"))
``````

G2 = worksite, A2 = learning plan, H2 = course title, J2 = training
status

The “inputs” reference is just a unique list so, essentially, the formula checks that the worksite, learning plan, etc, fall within values on the list (inputs tab) but the problem with this formula is it doesn’t necessarily identify if one of those courses isn’t complete. It’s only checking to make sure those courses listed are on the list.

## type checking – Does strong typing contribute to better performance optimization by compiler?

Do guarantees provided by the type systems enable better performance optimizations by the modern compilers? I found a 20+ year article suggesting that it would. Also, intuitively speaking, knowing more about the code in advance should also be useful. However, a friend claims that modern JIT compilers make such claim irrelevant. In his words:

This is a paper from 1998. Today, JIT compilers eliminate many of the cases mentioned in the paper for dynamically typed systems. For example, JavaScript uses integer arithmetic for integer types, without knowing the type declarations in advance. I doubt if predeclared types are as significant for performance today as they were two decades ago. Native instruction set and memory management mechanisms seem to have much more influence on performance to me.

What’s the situation in modern compilers?

## Checking for software vs. hardware keyboard problems.? Lenovo A12 YB-Q501F Android 6.0.1

I’ve got the tablet listed above, and discovered that the built-in keyboard (called the Halo Keyboard) now barely functions.

A few keys on the left side of the keyboard work, but not consistently. None on the right half of the keyboard respond at all.

It all worked fine a few months ago.

The tablet has an attached keyboard and operates almost like a laptop, but the keys are pressure-sensitive buttons rather than physical keys. The keyboard lights up when it’s in a configuration to be used.

I use it mostly in tablet-only mode, and the keyboard is on the other side of the device in that mode, not active.

I tried checking for system updates but haven’t found anything.

A lot of searching doesn’t turn up my problems, and often gather in responses from a Windows version of this same machine. They usually refer to reinstalling drivers but I can’t determine if that’s applicable from the posts.

One error that I’ve noticed is after many attempts at hitting keys on the physical board, and then going to use the android keyboard, many of these random presses will show up later. When I start typing in a search bar, I will get hit with a long string of ‘aaaaaa’ or ‘zzzzzz’ etc.

I’ve rebooted the machine twice; I’m also going to try a factory reset, though there is data on the machine I want to get off first.

I’d love to see if I can determine if this is a software problem or if the keyboard itself has become faulty. I’m familiar with Linux but I’m not an expert with Android! Is there any kind of diagnostic that I can do?