android studio – Adjust theme in real time

With the following method I change the colors of the theme of the app through buttons, however I still need to assign the new value of the Accent color (example of the checkbox change).

   public void AjusteColor(String primaryDark, String Accent){
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(primaryDark)));


I do it from a menu

   public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == {
            Toast.makeText(this, R.string.Main_logout2, Toast.LENGTH_SHORT).show();
            startActivity(new Intent(MainActivity.this, LoginActivity.class));
        if (id == {
            String primaryDark="#008577";
            String Accent="#4CAF50";

        if (id == {
            String primaryDark="#F5E91E63";
            String Accent="#E9F1598A";


        return super.onOptionsItemSelected(item);

time series: LSTM cannot predict well when the basic truth is close to zero

While training the LSTM model, I ran into a problem that I couldn't solve. To start, let me describe my model: I used a Pytorch stacked LSTM model with 3 layers, 256 hidden units in each layer to predict human joint angles and pairs from EMG features. After training, the model can predict well when the fundamental truth is far from 0, but when the fundamental truth is near zero, there is always a shift between the predicted value and the fundamental truth. I suppose the reason would be that the great value of basic truth will have more impact during the training process to reduce the loss function. You can see the result here

I have tried different loss functions but the situation did not improve. Since I am a beginner in this field, I hope someone can point out the problem in my method and how to solve it. Thank you!

operator does not exist: time stamp with time zone + integer in PostgreSql

I ran into a strange problem in postgres. I have two databases created in two different periods.
They both run on the same PostrgreSql 9.6 version on the same machine. When I run the query SELECT now() + 30 in database 1 -> It works correctly.
The same query that I copy and paste into the second database is giving error: operator does not exist: timestamp with time zone + integer in PostgreSql

Can someone guide me on this?

enter the image description here

complexity theory: validity of a simple polynomial time reduction

Let's say P is a NP-hard optimization problem and Q is a problem with unknown complexity. Also, we have an algorithm to solve problem Q. We can solve problem P with input x as follows:

    max = -inf - the optimal value for P 
    n = size of x
    for (i = 1; i <= n; i++)
         val = solveQ(x, i)
         if (val > max) max = val

Is this a proof that Q is also NP-hard? If so, can this be shown more formally? Is this a valid polynomial time reduction?

performance: speed up the execution time of large document text tokenization through Python and RegEx

I am currently trying to process a large number of very large text files (> 10k words). In my data channel, I identified the gensim tokenize function as my bottleneck, the relevant part is provided in my MWE below:

import re
import urllib.request
import time


PAT_ALPHABETIC = re.compile(r'(^Wd)+')

def tokenize(text):
    for match in matches:

def preprocessing(doc):
    tokens = (token for token in tokenize(doc))
    return tokens

start_time = time.time()
print("--- %s seconds ---" % (time.time() - start_time))

I managed to reduce the runtime performance by about 50% using PyPy. It takes approximately 0.40 seconds to run the preprocessing function on my mid 2010 Consumer Notebook.

However, is there anything I can still optimize in my code?
I'd also be interested in the runtimes of people with newer hardware (or hardware suggestions in general).

Thanks in advance

Time difference on the phone while sending text messages

My boyfriend is in Russia and I am in the USA. USA When I texted him, the time is here on my phone, and he texted me from Russia.

c # – Since more messages can be added when receiving byte data, can I tell the time difference between them?

For context, I am implementing a server application with a simple chat system. I was wondering how I could make the server detect spammers and I naively thought that this would work:

 public void Chat(string message)
            long diff = DateTime.Now.Ticks - LastMessageTime.Ticks;
            if (diff < 100000)

While it worked great on my local machine, I am getting falsely rejected messages (they are rejected as if they were sent too close to each other, while in fact they were not) on a slower virtual server. I think the problem is that the data is stored in the buffer since more messages from the same client can be added in a received fragment and therefore this method doesn't really work.
How would you solve this correctly?

Online sharepoint: Flow creates multiple email notifications every time the file is modified

I'm trying to create a flow that will generate a single email notice when three separate columns in a SharePoint document library are modified. However, I cannot prevent multiple email alerts from being generated each time the file is modified. There is an initial notice when the & # 39; Complete Employee Review & # 39; column is set to & # 39; Yes & # 39; (the employee changes this column). The second warning should be triggered when the administrator changes the column & # 39; Approved by Suzanne & # 39; to & # 39; Yes & # 39 ;. The last warning should be generated when the column & # 39; Will Approved & # 39; is set to & # 39; Yes & # 39 ;. The original email notice is generated with each subsequent notice each time the file is modified.

I'm using the trigger when creating or modifying a file (properties only) for files in the document library. I added a parallel branch to Flow with 3 conditions. In an attempt to stop multiple email notices with each file modification, I added a Finish control to the first condition with a status & # 39; Canceled & # 39 ;. It works great for the first two conditions, the first and second email alerts are generated as expected without duplication. However, the flow ignores the third condition and the last email warning fails. I have tried several approaches to this flow and I am unable to stop repeated email alerts. Thanks in advance for any help or suggestion.

First condition
Second condition
Third condition

unity – Instantiating only 1 Prefab at a time with a counter in the Update Function

I have a hard time getting the timer to work properly and then instantiating for x seconds at a time.
My problem with my script is that Prefab installs as unlimited and doesn't stop after instantiating. The second problem is that _spawnTime is not equal to _resetTime, so it might start again after reaching 0.
I came up with this script so far:

(Header("Spawn Object"))
public GameObject _SplatterRock;
public GameObject IvanChar;
(Header("Spawn Position"))
public Vector3 _spawnPosition;
(Header("Spawn Options"))
public float _spawnTime = 2f;
public float _resetTime = 0f;
public bool _stopSpawning = false;

private void Update()
    if(_spawnTime >= _resetTime)
        _spawnTime -= Time.deltaTime;

        if (_spawnTime <= 0f && !_stopSpawning)
            _spawnTime = _resetTime;
            GameObject _spawnedSplatterRocks = Instantiate(_SplatterRock, _spawnPosition, Quaternion.identity) as GameObject;
            _stopSpawning = false;