architecture – Predicted ability edge case issue

I am in the process of creating an ability system with client prediction akin to Unreal Engine 4’s Gameplay Ability System.

I found an edge case where the client’s tags that are applied from effects become out of sync with the server.

The prediction method I use is the same as detailed here.

Here is a scenario that illustrates this:

The player has 2 abilities, an ability to unsheathe their weapon, and an ability to sheathe their weapon. Each ability requires a specific tag to activate. For the unsheathe ability, it is the “Sheathed” tag. For the sheathe ability, it is the “Unsheathed” tag.

There also exist two effects that apply these tags. The UnsheatheEffect applies the “Unsheathed” tag and the SheatheEffect applies the “Sheathed” tag.

The unsheathe ability lasts for 1 second and at the end applies the UnsheatheEffect and removes the SheatheEffect. The sheathe ability does the same thing but applies the SheatheEffect and removes the UnsheatheEffect.

In this scenario, the player has a static ping of 1 second.

0 seconds: The client activates unsheathe ability. Tags {"Sheathed"}

1 second: The server activates unsheathe ability.

1 second: The client finishes unsheathe ability. Tags {"Unsheathed"}

1 second: The client proceeds to activate sheathe ability. Tags {"Unsheathed"}

2 seconds: The server finishes unsheathe ability and starts the sheathe ability.
2 seconds: The client finishes the sheathe ability. Tags {"Sheathed"}
2 seconds: The client activates the unsheathe ability. Tags {"Sheathed"}

3 seconds: The client reconciles with what happened on the server as a result of the unsheathe ability. Tags {"Unsheathed", "Sheathed"}.

The issue is that the client has already gone through the process of removing tags after abilities, but they are soon added back because of the reconciliation with the server. I am really not sure what to do about this, because the client should be in sync with the server, but it ends up just messing up the whole system.

Como estructurar Switch Case en Dart?

La idea es que el usuario ingrese su nombre a traves de un Textfield y comparar el nombre con los case presentados, dependiendo del nombre que ingrese lo direccionara a ventanas diferentes, en Dart

``` _navegacionVentana(data) {
setState(() {
  _isLoading = true;
});
final String nombre= "asesor";
//void main(List<String> args) {
//var nombre = "asesor";

switch (nombre) {
  case "asesor":
    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) =>
                ListaChat()));
    //}
    break;
  case "asesorz":
    print("asesork");
    //}
    break;

  default:
    // {
    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => Chat(
                )));
  //}
  // break;
}

} “`

Compute average case with best case

is it correct to compute the average case time complexity of an algorithm by taking the mean of the best and worst cases ? My findings : for binary search, $frac{log (n) +1}{2}in Theta left(log (n )right)implies $ the average case is $log (n).$

sql server – Case statement query

How can this be re-written. somehow not able to make it right. In case statement Then and ELSE are same
would like to change it to single statement.

SELECT t.status_id status_id, (
CASE WHEN t .status_id NOT IN (SELECT status_id FROM firm_return WHERE enabled = ‘D’ and firm_id=t.firm_id)

THEN (cl.category_code + ‘-‘ + s.status_name) ELSE cl.category_code + ‘-‘ + s.status_name END) AS status_type
FROM bla bla

bitcoincore development – How does an individual access the Bitcoin Core repo and contribute to it in the case that GitHub boots Bitcoin Core or the individual off GitHub?

This is a draft answer. Note there have been recent consensus issues with Tor v3 addresses.

Wladimir van der Laan posted this on Mastodon.

My personal bitcoin Git repository, which mirrors upstream branches
and tags is available through a TorV3 service on
http://nxshomzlgqmwfwhcnyvbznyrybh3gotlfgis7wkv7iur2yj2rarlhiad.onion/

(instructions for cloning are on the website)

I’m also mirroring it to the radicle (https://radicle.xyz/) P2P code
collaboration platform:

rad:git:hwd1yreyfmyg5my7kskrsc5r33h5jr9anra9635hpncfs9f1wsk1eaf8f9w

UX design case studies – User Experience Stack Exchange

I am looking for well-written and in-depth case study articles of real life UX designs. I’d like to read how other designers tackle design challenges, and how their designs solve those challenges. This can be on any type of UX designs, not limited to web/software.

What I’m not looking for:

digital signature – Proving authenticity of a message from a message app in case of deletion

Say you want to prove that you received a certain message from someone.
This can be difficult because many messaging apps (like facebook messenger) allow the sender to delete messages on the recipient’s end.

Of course, you could screenshot the message, but then you still need to prove 2 things:

  1. The time of the message.
  2. The authenticity of your screenshot.

1 is easy, if you upload a hash to public databases
as described in this question: Proving creation time/date of a screenshot

2 is a bit more difficult. You’d have to prove somehow that you didn’t just forge the screenshot. Note: this is a little different than proving that it was the other person that sent it. This is proving that you received the message from a certain account.

Is there a way establish proof of this?

postgresql – CASE Statement returning unpredictable results

First time using Postgresql and building a query with a CASE statement. I am trying to end up with a collection of data whereby one of the columns in the data (status) qualifies the row based on conditions.

I have 3 tables (in a Posqtgresql DB) as follows:

Table devices:

id serial_number retired last_reported_utc_at other_data
2 1234 FALSE 2020-12-01 15:34:23
5 4567 FALSE 2020-12-01 15:34:23
6 NULL FALSE NULL

Table device_measurements

id device_id reading read_utc_at
1 5 1.36 2020-12-01 15:34:23
2 2 2.45 2020-12-12 18:21:12
3 6 1.87 2020-12-03 20:29:12

Table devices_meters
Note: This table links the device to a meter location. the activated and deactivated dates will sequence the history of the device to meters.

id device_id meter_id reading activated_utc_at deactivated_utc_at
1 5 23 1.36 2018-10-01 15:34:23 NULL
2 2 17 2.45 2019-06-12 18:21:12 NULL
3 6 17 2.45 2019-06-12 18:21:12 NULL

Each device could have the following status:

active, online, offline, inactive, retired 

I have been trying, via a CASE statement in the SELECT to generate a column (status) where I flag the row as one of the above. The query runs, but the result is unpredictable.

My CASE statement is:

   CASE
        // Device has reported back last 24hrs and has non zero readings for data in this period
        WHEN
            devices.retired = false
            AND MAX(device_measurements.reported_utc_at) BETWEEN :yesterdayFilter AND :nowFilter
            AND SUM(device_measurements.flow) > 0
            THEN 'active'

        // Device has reported back last 24hrs and has all zero readings for data in this period
        WHEN
            devices.retired = false
            AND MAX(device_measurements.reported_utc_at) BETWEEN :yesterdayFilter AND :nowFilter
            AND SUM(device_measurements.flow) = 0
            THEN 'online'

        // Device has not reported back last 24 hrs
        WHEN
            devices.retired = false
            AND MAX(device_measurements.reported_utc_at) < :yesterdayFilter
            THEN 'offline'

        // Device with null serial number
        WHEN devices.retired = false
            AND devices.serial_number IS NULL
            THEN 'inactive'

        // Device retired boolean column flag set to true
        WHEN devices.retired = true
            THEN 'retired'
    END AS status,

:nowFilter contains a date of now() in UTC

:yesterdayFilter contains a date of now()->subHours(24)

The above does not fail but returns unpredictable results, such an offline device which has had a data report less than 24 hrs ago.

Any help is really appreciated.

The whole query is below:

select
    "devices".*,
    CASE
        WHEN devices.retired = false
        AND MAX(device_measurements.reported_utc_at) BETWEEN :yesterdayFilter
        AND :nowFilter
        AND SUM(device_measurements.flow) > 0 THEN 'active'
        WHEN devices.retired = false
        AND MAX(device_measurements.reported_utc_at) BETWEEN :yesterdayFilter
        AND :nowFilter
        AND SUM(device_measurements.flow) = 0 THEN 'online'
        WHEN devices.retired = false
        AND MAX(device_measurements.reported_utc_at) < :yesterdayFilter THEN 'offline'
        WHEN devices.retired = false
        AND devices.serial_number IS NULL THEN 'inactive'
        WHEN devices.retired = true THEN 'retired'
    END AS status,
    MAX(device_measurements.reported_utc_at) AS last_reported_utc_at
from
    "devices"
    left join "devices_meters" on "devices_meters"."device_id" = "devices"."id"
    left join "device_measurements" on "device_measurements"."device_id" = "devices"."id"
group by
    "devices"."id"
having
    (
        CASE
            WHEN devices.retired = false
            AND MAX(device_measurements.reported_utc_at) BETWEEN :yesterdayFilter
            AND :nowFilter
            AND SUM(device_measurements.flow) > 0 THEN 'active'
            WHEN devices.retired = false
            AND MAX(device_measurements.reported_utc_at) BETWEEN :yesterdayFilter
            AND :nowFilter
            AND SUM(device_measurements.flow) = 0 THEN 'online'
            WHEN devices.retired = false
            AND MAX(device_measurements.reported_utc_at) < :yesterdayFilter THEN 'offline'
            WHEN devices.retired = false
            AND devices.serial_number IS NULL THEN 'inactive'
            WHEN devices.retired = true THEN 'retired'
        END
    ) = :status
order by
    "devices"."installed_at" desc
limit
    10 offset 0

machine learning – Axis aligned rectangles: why is A an ERM in the case of infinite domain?

I’m working on a problem 2.3a in Shalev-Shwartz/Ben-David’s Machine learning textbook, which states:

An axis aligned rectangle classifier in the plane is a classifier that assigns 1 to a point if and only if it is inside a certain rectangle. Formally, given real numbers $a_1leq b_1, a_2leq b_2,$ define the classifier $h_{(a_1, b_1, a_2, b_2)}$ by
$$ h_{(a_1, b_1, a_2, b_2)}(x_1, x_2) = begin{cases}1&textrm{if $a_1leq x_1leq b_1$ and $a_2leq x_2leq b_2$}\ 0&textrm{otherwise}end{cases} $$
The class of all axis aligned rectangles in the plane is defined as $mathcal{H}_mathrm{rec}^2 = {h_{(a_1, b_1, a_2, b_2)}:textrm{$a_1leq b_1$ and $a_2leq b_2$}}$…rely on realizability assumption.
Let $A$ be an algorithm that returns the smallest rectangle enclosing all positive examples in the training set. Show that $A$ is ERM (empirical risk minimizer).

I don’t understand why $A$ would be ERM, when the domain/instance space is infinite. Below is the counterexample I considered to this claim.

For simplicity, consider the one-dimensional case, where the rectangles would be intervals. Sample instance $xsim mathcal{U}_{(0, 1)}$ from a uniform distribution over $(0, 1)$, where the labeling function $f:(0, 1)to{0, 1}$ is defined by
$$
f(x) = begin{cases}
1 &textrm{x = 0 or x = 1}\
0 &textrm{otherwise,}
end{cases}
$$

then the realizability assumption holds as there exists an $h^*$ whose rectangle described by the singleton ${1}$ has an error set ${0}$ of measure $0$. However, in the case of a particular sample
$$
S = {0, 1/4, 1/2, 3/4, 1},
$$

the smallest rectangle $A$ is the interval $(0, 1)$, and the consequent classifier $h_A$ has an empirical error of $L_S(h_A) = 3/5$. In contrast, the classifier $h^*$ has empirical error $L_S(h^*) = 1/5$, a lower error than the classifier described by $A$, even though it doesn’t contain all positive examples. Therefore $A$ does not minimize empirical error.

Copy protection for Windows software for the case “demo version vs. full version”

I have written a software as a student. All functionality was in the software and it was a 30 days fully functional version. After some years there were cracks around and my income was 10% of before. This was where I decided to switch the paradigm to full version vs. demo version with limited functionality (the function weren’t even in the EXE using compiler switches). This in my case ended all piracy and worked very well.

Now you could ask what if a customer uploads his full version to a crack website? For this case I compiled the customer’s full address visibly and invisibly into the EXE file so that I could see which customer was a bad boy…

After some more years I had a new problem: anti virus software. Since my software can set keyboard shortcuts, the heuristic algorithms of some anti virus apps started complaining. So I sent the demo version EXE to the anti virus companies to mark it as “safe”. This worked very well. But only for the demo version which is fixed in bytesize. When I compile the customer’s personal data into the EXE file, the filesize varies a bit and so the checksum differs and the EXE file isn’t marked as “safe” by the anti virus software anymore and the complaining starts again for the customers.

Does anyone have an idea how I could solve this? I can’t add a separate file because this could be deleted by the customer, of course.

Thanks in advance.