python – Fast requests to REST or alternative solutions

Allow application to react on the flask

Currently I'm developing a REST API where users submit tasks. These tasks are performed indefinitely, and it is literally impossible for me to guess a time when they are done.

When the users submit a task, I create a simple entry in a Redis cache that contains the start time, the job UUID, the data, and the current status. If a job is received by a group of queuing workers on a separate system, execution may take some time, or may take no time (1 second versus 1 day), as previously mentioned.

My current implementation works fine, but I'm trying to see if there's an alternative solution to tweaking things and reducing the number of calls I need to go from front to back.

The flow is thus essentially:

  1. The user hands over the order
  2. Cache entry created, user immediately confirmed with job UUID
  3. Workers start task
    3A. Employees update the cache entry upon completion
  4. The user asks the endpoint if the job is complete (check cache, STATE var).
  5. Return user data.
    5A. If not completed, ask again and again X times (after completing the previous request)
    5B. When the process is complete, stop asking the endpoint when it is complete

This setup works fine, but it seems very wasteful to send several hundred requests every few minutes to check the status.

Any input would be appreciated. If this is not the right place to post, please let me know and I can remove / move it.

ubuntu – Replace systemd-machine-id-setup with alternative?

We use one Ubuntu 4.18 Template in a virtualization environment. Therefore, we always empty the before you create the template / etc / machine-id File to be recreated on first startup.

The problem is that if multiple Ubuntu 18-based VMs are started at the same time, systemd-machine-id-setup generates the same ID for all, resulting in IP duplicates. I have checked these servers and they all have the same content in the / etc / machine-id File.

IP duplication

When machines are switched on at staggered times, different IPs are assigned, so I assume systemd-machine-id-setup is (possibly) generated based on the current time. This is not acceptable to us because of the problem in the picture above.

Is there a way to let the operating system generate this? / etc / machine-id at boot based on an alternative binary file?

macos – What is a shorter alternative to Press The Key Combo? [modifiers] [keyname] in DragonDictate 5?

I'm using DragonDictate 5 on Mac OS X 10.10. Whenever I want to send a keyboard shortcut that contains keys, eg. command + C, I have to say Press the C key, Is there a shorter alternative with voice commands? For example, on Windows 7 SP1 x64 Ultimate with Dragon NaturallySpeaking 12.5 Professional I just have to say Press the control button C,

Approximation – Alternative criterion for perfect matching algorithms with maximum weight

Is there literature on approximate perfect matches of maximum weight where the approximation criterion is not the factor between the approximate and exact sum of weights achieved by each solution but sets the cardinality of the intersection of the edges in the approximate and optimal solution? The relevant class of diagrams $ G (V_1 cup V_2, E) $ is in two parts and is believed to have perfect matches, i. $ | V_1 | = | V_2 | = N $,

Be clear:

On $ (1- epsilon) $ The approximation algorithm obtains a solution, i. H. a perfect match $ E & # 39; subset E $for some $ epsilon> 0 $is the sum of the edge weights equal to or greater than $ (1- epsilon) $MWM, where MWM is the maximum sum of edge weights among all perfect matches. Accept that $ mathcal {E} $ is the set of optimal solutions. I'm looking for an algorithm that produces a perfect match $ E & # 39; & # 39; $ satisfying $ max_ {E & # 39; in mathcal {E}} | E & # 39; & # 39; cap E & # 39; | geq (1 epsilon) N $, I am willing to limit the problem to the class of graphs for which the optimal solution is unique and hence the complicated term. "$ max_ {E & # 39; in mathcal {E}} $"can be removed from the problem definition.

Randomized algorithms in the sense that the output satisfies the required inequality with probability $ 1 – Delta $, for some $ Delta> 0 $are also welcome.

I know the work of Duan and Pettie and most references in it.

c ++ – shared_ptr Alternative without dependencies

An alternative to shared_ptr to minimize the compile time. Intrusive. Changes to the reference count are not thread safe.

(#include draws 17k lines of code)

This satisfies my needs, but I'm curious to see how it could be improved (without adding dependencies).

It is not very good at dealing with incomplete types (ref::receive can not be used for an incomplete type). Can you improve that?

// Derive from it to be recounted.
struct refcount {
int rc = 0;
virtual ~ refcount () {}
};

void queued_delete (refcount *);

template
Class reference {

Public:

ref () {}

ref (T * obj): obj (obj) {
if (obj) {
obj-> rc ++;
}
}

~ ref () {
if (obj) {
if (- (obj-> rc) == 0) {
queued_delete (obj);
}
}
}

ref (const ref & r) {
if (r.obj) {
obj = r.obj;
obj-> rc ++;
}
}

template
  ref (const ref& r) {
if (r.get ()) {
obj = r.get ();
obj-> rc ++;
}
}

ref & operator = (const ref & r) {
ref (r) .swap (* this);
return * this;
}

template
  ref & operator = (const ref& r) {
ref (r) .swap (* this);
return * this;
}

T * operator -> () {return static_cast(Obj); }
const T * operator -> () const {return static_cast(Obj); }
T & operator * () {return * get (); }
T & operator * () const {return * get (); }

T * get () const {return static_cast(Obj); }

unsigned long id () const {return (unsigned long) obj; }

Empty swap (ref & p) {
auto tmp = obj;
obj = p.obj;
p.obj = tmp;
}

explicit operator bool () const {
return obj;
}

bool operator == (const ref & other) const {
return obj == other.obj;
}

bool operator! = (const ref & other) const {
return obj! = other.obj;
}

template
  ref Cast () {
return ref(dynamic_cast(Obj));
}

Private:
refcount * obj = nullptr;
};

Optional deletion that can handle deep nesting (can also be done with) shared_ptr with a custom deleter):

// Make sure that deeply nested data structures can
// be deleted without the stack running out.
void queued_delete (refcount * p) {

delete static bool = false;
static std :: vector Stack;

stack.push_back (p);

if (! deleting) {
Delete = true;
while (stack.size ()) {
auto top = stack.back ();
stack.pop_back ();
delete above;
}
Delete = wrong;
}
}

Website Design – The best ux alternative when designing a product variant on the dashboard

I was wondering how the variant can best be viewed when the user clicks Add Variant. I have already designed two alternatives: Display in ascending or descending order. I have tested it with internal stakeholders, but I still hesitate because the results are 50:50, either they have chosen Alternative-A or Alternative-B.

When the user clicks Add Variant on Alternative A, it will be displayed in ascending order. After the user enters the product variant name, variant 1 is automatically changed based on the product variant name and so on. The newest variant will be placed below. Example:

version 1

Variant 2

Variant 3 [this is the latest]

Alternative A:
Enter image description here

Enter image description here

Enter image description here

When the user clicks "Add Variant" on Alternative B, it will be displayed in descending order. After the user enters the product variant name, variant 1 is automatically changed based on the product variant name and so on. However, the newest variant is placed at the top. Example:

Variant 3 [this is the latest]

Variant 2

version 1

Alternative B:
Enter image description here

Enter image description here

Enter image description here

I would be glad if someone could give me an opinion and a strong justification, which alternative from these two possibilities is the best. On the other hand, I want to assign an indicator status to the latest variant, but I have no idea how to render it. Maybe you could give me an idea about the status of the indicator.
Thank you in advance!

c ++ – std :: function Alternative without dependencies

An alternative to std :: function If the compile time is more important than the runtime performance. Does not include headers.

(#include Attracts 19k lines of code.)

This satisfies my needs, but I'm curious to see how it could be improved (without adding dependencies).

template
Class func;

// alternative to std :: function for the time of compilation
// more important than the runtime performance. Does not feed
// any headers.
template
great func {

Structure holder {
virtual owner () {}
virtual result call (arguments ...) = 0;
virtual owner * clone () = 0;
};

template
  lambda_holder struct: public owner {
virtual ~ lambda_holder () {}
Lambda lambda;
lambda_holder (lambda l): lambda (l) {}
Overwrite result call (arguments ... arguments) {
Return lambda (arguments ...);
}
holder * clone () override {
return new lambda_holder(Lambda);
}
};

Public:

func () {}

func (const func & f) {
holder = f.holder-> clone ();
}

func & operator = (const func & f) {
if (owner) {delete owner; }
holder = f.holder? f.holder-> clone (): nullptr;
return * this;
}

// create from a lambda.
template
  func (F f) {
holder = new lambda_holder{F};
}

~ func () {
if (owner) {delete owner; }
}

Result operator () (Arguments ... Arguments) const {{}
claim (owner);
return holder-> call (arguments ...);
}

Operator bool () const
Return owner;
}

Private:

holder * holder = nullptr;

};

Would you rather pay more for cPanel or a cheaper alternative?

Quote Quote by Sensei Steve
Show contribution

As a new provider I would still pay extra for cPanel. That does not mean that I would not think any further while growing up.

Hello SenseiSteve,

Thank you for your comment, I definitely agree with that, but I would also like to hear what resellers think about it, as it concerns them most. As a hosting provider, we have been able to override reseller options at any time, as this has no impact on shared hosting customers with a 1 cPanel account. However, we started our business specifically to provide better service to resellers, and now this bomb has dropped. <

In our country, resellers really do not get great service or choice (I was one before I started this business).

I see that cPanel is announcing more changes, so it would be nice to allow more than 100 accounts per $ 45 license. I do not think there would be such a big uprising if the accounts were limited to 500 per license … cPanel would still be murdering.

Alternative to Python Pip Bitcoin

This Python pip package https://pypi.org/project/bitcoin/ was originally developed by Vitalik Buterin (the Ethereum type) but is no longer maintained. Is there an alternative equivalent Pip package that can work with Segwit addresses? Many Thanks.

Found these https://github.com/1200wd/bitcoinlib. And it is crap. Not even installed with pip or pipenv.

Is this a factory pattern or strategy pattern? c / c ++ and suggest an alternative solution

The idea is that if we want to create an object of one type, we will use only one robot creator and one enumeration of the interface. I'd like to understand which template design I used because sometimes it looks like a factory and sometimes it's a strategy.

Should I use define or not? I'm also happy about new ideas for implementation.

InterfaceRobot.h

    Class InterfaceRobot
{
Public:
InterfaceRobot ();
enum RobType {Y = 0, C = 1, D = 2, F = 3};

virtual void open () = 0;
virtual void close () = 0;
};

#endif // INTERFACEROBOT_H

RobotCreator.h

Class RobotCreator: public interfaceRobot
{
Public:
RobotCreator (InterfaceRobot :: RobType _robType);
not open ();
void ();
~ RobotCreator ();

Private:
Interface Robot * Robot; / ** pointer to InterfaceRobot ** /
};

RobotCreator.cpp

RobotCreator :: RobotCreator (InterfaceRobot :: RobType _robType)
{
switch (_robType)
{
case InterfaceRobot :: C:
this-> Robot = new c ();
break;
case InterfaceRobot :: Y:
this-> Robot = new y ();
break;
case InterfaceRobot :: D:
this-> Robot = new D ();
break;
case InterfaceRobot :: F:
this-> Robot = new F ();
break;
}
}

void RobotCreator :: open ()
{
this-> Robot-> open ();
}

void RobotCreator :: close ()
{
this-> Robot-> close ();
}

RobotCreator :: ~ RobotCreator ()
{
cout << "d & # 39; tor of RobotCreator" << endl;
    if (this->Robot! = NULL)
{
Clear[]  this-> dlRobot;
this-> Robot = NULL;
}
}

Use in the main:

int main ()
{

RobotCreator rob (InterfaceRobot :: Y);
rob.open ();
rob.close ();

RobotCreator rob2 (InterfaceRobot :: C);
rob2.open ();
rob2.close ();
}