Python Request inside Django View stop request when client gets disconnected

I have an DRF API in which a client will call then once called it will pass the data from client to another server (using request package) and returns to client the response of the other server.
In short, I am an API in the middle to sync them. Now, I need to terminate the request to other server (the one that is using request package) from my DRF API once the client got disconnected to my DRF API.

Note. I need to terminate it because the data sending from the client is need to be map by the id being returned from the other server, and the client needs to save the id they received. In case your wondering why my API exist, the client can just sent the request over to the other server directly. Because the other server is a legacy server and it runs SOAP so my API is converting the JSON payloads to SOAP payload then from SOAP payload to JSON payload.

ios – How to draw circles on random position in view borders

Have a nice day fellas,
Help me please to catch how to draw circles on random position in view borders.

Red View options

.background(Color.red)
.padding(40)

Circles:

var body: some View
{    
Circle()
.strokeBorder(Color.blue, lineWidth: 2.0, antialiased: true)
.frame(width: 50, height: 50, alignment: .center)
.overlay(Text(title))
}

I try to add circles on red view in random position using .position option, but you can see its not working:

circles

The main problem is how to know width and height of red view on any device and set .position of circles. my bad english, sorry.

What size lens will give a 2ft by 2 ft view at a range of 2 ft?

The easiest way is put a zoom lens on your camera and figure out what focal length you need empirically.

Since you don’t say what your sensor size or camera model is, you’ll need to do the maths yourself.

Angle of view for your situation is about 2 * arctan(1/2) = 53°.

From a Wikipedia article: angle of view = 2 * arctan(d/(2*f)
Where: d = distance; f = focal length
d, in your case, is 610mm = 2 feet.

Solving for f: focal length = d/(2 * tan({angle of view}/2))
For a full frame sensor and using the 24mm dimension, you’ll need a focal length of 24mm.
For an APS-C sensor, 16mm.

Some caveats:

  • distance is measured from the film (sensor) plane to object. Decent cameras have a marking on the body where the film plane is located.
  • The equation for finding focal length is for a simple lens. Camera lenses aren’t simple, especially when shooting close up.
  • When focusing at closer ranges, the magnification of your lens will change. Unless you calibrate your lens, you’ll be slightly off from the equation.

linux – Is there a way to transfer SMS mesages from a Samsung Galaxy S5) to an Ubuntu PC, in a form in which I can view the SMS messages on my PC?

I want to transfer the SMS messages on my Samsung Galaxy S5 smartphone to my PC (with Linux Ubuntu 20.04.2 LTS), in a form in which I can open and view the messages on my PC as I do on my smartphone.

I know about the apps which can back up smartphone data, such as Kies and Smart Switch for Samsung phones and ADB and Android File Transfer for Android devices. But as far as I can tell, these only back the SMS data up rather than save them as files which can be opened on PC desktop.

applications – Any apps or ways to categories group apps folders in menu view

Question :- Any apps or ways to categories group apps folders in menu view

Is there any apps or way setting to categories group move apps installed icons in folders as there is jumble of apps to search in alphabetical order which cant be moved or.clubed in Android 6.0 unrooted mobile phone.

I had searched Google and.finded smart launcher go launcher x or drawer to. Circle launchers but all just change wallet create widgets folder organizer manager but no one manages the menu view

Yes I know we can create folder in home (mobile desktop views) but making it jumbled slow down booting Android starting and many time it don’t display icon image on reboot of mobiles.

Can we create self menu (as start menu in Windows properly organised) through app and hide the original menu and replace our own menu. I have seen a circle.menu recreated by some apps.

Any stable good app to create organize categorise apps icons shortcuts in a menu or app it’s self.

office365 – How to show “To” field in Outlook 365 as plain text not with the “object” view


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




Is there a way to transfer SMS mesages from a Samsung Galaxy S5) to an Ubuntu PC, in a form in which I can view the SMS messages on my PC?

I want to transfer the SMS messages on my Samsung Galaxy S5 smartphone to my PC with Ubuntu (20.04.2 LTS), in a form in which I can open and view the messages on my PC as I do on my smartphone.

I know about the apps which can back up smartphone data, such as Kies and Smart Switch for Samsung phones and ADB and Android File Transfer for Android devices. But as far as I can tell, these only back the SMS data up rather than save them as files which can be opened on PC desktop.

where on earth – From what point could you view the most countries?

I’ll take a stab at answering this.

The near-quadripoint works, you can see four countries. I’ve been there myself:

http://babakfakhamzadeh.com/article/from-zambia-to-botswana-nearly-a-quadripoint

But, there are a few more candidates.

The Wakhan corridor (in Afghanistan, http://en.wikipedia.org/wiki/Wakhan_Corridor) is so narrow (8 miles at its narrowest), that I presume there will be peaks from where you can see Afghanistan, China, Tajikistan and Pakistan.

The eastern edge of Kazakhstan and the western edge of Mongolia nearly meet, separated by a 30km gap where Russia and China border. The border here is fairly mountainous, so it’s likely there will be multiple points along this corridor where you will be able to see four countries.

Technically, if you stand on the south pole, you can see land claimed by 6 or 7 countries: http://en.wikipedia.org/wiki/Territorial_claims_in_Antarctica#mediaviewer/File:Antarctic_Region.png

There’s a road that connects Igdir (in Turkey) to Nakchivan (in an Azeri exclave). The road goes through a Turkish corridor that, at times, is only some 2k wide. There, Iran is one side, Armenia on the other.
Beyond a doubt, you’d be able to see four countries here, from multiple locations.

So, the question is, besides on the south pole, where can you see five countries from the ground?

magento2.4 – How to show a footer link for only specific language store view? – Magento2

How can I make a footer link show only a specific store language view?

For example, I want to show this custom footer link only for English store view, not other language store view. So I can setup different footer links for each store view.

<referenceBlock name="footer_links">
    <block class="MagentoFrameworkViewElementHtmlLinkCurrent" name="custom-link-1">
        <arguments>
            <argument name="label" xsi:type="string">My new footer title</argument>
            <argument name="path" xsi:type="string">path-link</argument>
        </arguments>
    </block>
</referenceBlock>

query performance – How can I achieve predicate pushdown in my view

I have a reporting table (about 1bn rows), and a tiny dimension table:

CREATE TABLE dbo.Sales_unpartitioned (
    BusinessUnit    int NOT NULL,
    (Date)          date NOT NULL,
    SKU             varchar(8) NOT NULL,
    Quantity        numeric(10, 2) NOT NULL,
    Amount          numeric(10, 2) NOT NULL,
    CONSTRAINT PK_Sales_unpartitioned PRIMARY KEY CLUSTERED (BusinessUnit, (Date), SKU)
);

--- Demo data:
INSERT INTO dbo.Sales_unpartitioned
SELECT severity AS BusinessUnit,
       DATEADD(day, message_id, '2000-01-01') AS (Date),
       LEFT((text), 3) AS SKU,
       1000.*RAND(CHECKSUM(NEWID())) AS Quantity,
       10000.*RAND(CHECKSUM(NEWID())) AS Amount
FROM sys.messages
WHERE (language_id)=1033;

--- Artificially inflate statistics of demo data:
UPDATE STATISTICS dbo.Sales_unpartitioned WITH ROWCOUNT=1000000000;

--- Dimension table:
CREATE TABLE dbo.BusinessUnits (
    BusinessUnit    int NOT NULL,
    SalesManager    nvarchar(250) NULL,
    PRIMARY KEY CLUSTERED (BusinessUnit)
);

INSERT INTO dbo.BusinessUnits (BusinessUnit)
SELECT DISTINCT BusinessUnit FROM dbo.Sales;

… to which I’ve added a reporting view used by an application for OLTP-style reporting.

CREATE OR ALTER VIEW dbo.SalesReport_unpartitioned
AS

SELECT bu.BusinessUnit,
       s.(Date),
       s.SKU,
       s.Quantity,
       s.Amount
FROM dbo.BusinessUnits AS bu
CROSS APPLY (
    --- Regular sales
    SELECT t.BusinessUnit, t.(Date), t.SKU, t.Quantity, t.Amount
    FROM dbo.Sales_unpartitioned AS t
    WHERE t.BusinessUnit=bu.BusinessUnit
      AND t.SKU LIKE 'T%'

    UNION ALL

    --- This is a special reporting entry. We only
    --- want to see today's row. In case of duplicates,
    --- get the row with the first "SKU".
    SELECT TOP (1) s.BusinessUnit, s.(Date), s.SKU, s.Quantity, s.Amount
    FROM dbo.Sales_unpartitioned AS s
    WHERE s.BusinessUnit=bu.BusinessUnit
      AND s.(Date)=CAST(SYSDATETIME() AS date)
      AND s.SKU LIKE 'S%'
    ORDER BY s.BusinessUnit, s.(Date), s.SKU
) AS s

The idea is that the user application will query this view with a SELECT query that filters on a range of dates and one or more BusinessUnits. For this purpose, I’ve chosen a CROSS APPLY pattern, so that the query can “loop” over each BusinessUnit, seek to a range of Date, and apply a residual filter on SKU.

Example app query:

DECLARE @from date='2021-01-01', @to date='2021-12-31';

SELECT *
FROM dbo.SalesReport_unpartitioned
WHERE BusinessUnit=16
  AND (Date) BETWEEN @from AND @to
ORDER BY BusinessUnit, (Date), SKU;

I would expect a query plan that looks like this:
Desired query plan with predicate pushdown and no Filter operator
Desired plan

However, the plan turns out like this:
Actual query plan seeks only on BusinessUnit with residual predicate on SKU, adds Filter to the end of the plan
Actual plan

I expected SQL Server to do a “predicate pushdown” on the Date column, allowing the Clustered Index Seek to look for a single BusinessUnit and a range of Date, then apply a residual predicate on SKU. This works on the Seek in the “s” branch (the one with TOP) – probably because it has a hard-coded Date predicate in the query – but not on the “t” branch.

However, on the “t” branch SQL Server only seeks to the specific BusinessUnit with a residual predicate on SKU, effectively retrieving all dates. Only at the end of the plan does it applies a Filter operator that filters on the Date column.

In a large table, this has a very significant performance penalty – you could end up reading 20 years of data from disk when all you’re looking for is a week.

Things I’ve tried

Workarounds:

  • Converting the view to an inline table valued function with @fromDate and @toDate parameters that filter the “s” and “t” queries will enable a Seek on (BusinessUnit, Date) as desired, but requires rewriting the app code.
  • Moving the UNION ALL out of the CROSS APPLY (from CROSS APPLY (UNION) to CROSS APPLY() UNION CROSS APPLY()) will enable predicate pushdown. It makes one more seek on the BusinessUnit table, which is perfectly acceptable.

Fixes the Seek, but changes the results:

  • Surprisingly, removing the TOP (1) and ORDER BY for the “s” query makes predicate pushdown work on “t”, but can give return too many rows from “s”.
  • Eliminating UNION ALL by either removing the “s” or “t” query will enable predicate pushdown, but generate incorrect results.

No change or not feasible:

  • Replacing TOP (1) with a ROW_NUMBER() pattern does not change the Seek.
  • Changing the CROSS APPLY to a forced INNER LOOP JOIN fixes the Seek on “t”, but actually changes “s” to a Scan instead, which is even worse.
  • Adding trace flag 8780 to allow the optimizer to work on a plan for longer does not change anything. The plan is already optimized FULL with no early termination.

A common thread seems to be that changing/simplifying the “s” query (removing TOP, ORDER BY) fixes the problem on the “t” query, which feels counter-intuitive to me.

What I’m looking for

I’m trying to understand if this is a shortcoming of the optimizer, if it’s the result of a deliberate costing/optimization mechanism, or if I’ve simply overlooked something.