jquery – Lazy Loading WP API Data is both better or multiple request?

Context: I am working on a Cordova mobile application that will retrieve data associated with a type of personalized WordPress publication.

My question: Does it make more sense to make 1 API call that retrieves all of the custom post data (message title, feature image URL, 2-3 post meta fields per post) with a total from 80 to 100 posts, then use this data to load lazily when the user scrolls the post on the front-end

OR

Should I grab 10 posts via API and render them on the front-end and when the user scrolls down once he gets to a specific post (or pixel), the app does another API call to get the next 10 lazy loads once the user gets to a specific location while they scroll?

What I expect: I want the user experience to be as smooth as possible. So if there is to be a loading animation, I guess I would prefer to have one in the first loads vs 7-8 during the whole scrolling process.

I use the following technologies:

Cordova, JQuery Mobile, WordPress 5.2.4 (as a back-end data source)

javascript – nodejs 401 retry request mechanism

I am working on a project in which I have a backend in nodejs and from there I have to call external APIs, these APIs require an authentication token which is valid for 15 minutes. So if the response status of external APIs is 401, I have to generate a new token and then call the request.

In my backend, I am using a demand-promise package which does not provide any concept of interceptor as axios, so I have been trying to create my own mechanism, the code below is in typed characters

class RequestHandler {

    private token: any = {

        promiseCreator: function () {
            return new Promise((resolve, reject) => {
                this.rejects.push(reject);
                this.resolves.push(resolve);
            });
        },
        rejects: (),
        resolves: (),
        v: null,
        get value() {
            return this.v;
        },
        set value(val) {
            this.v = val;
            if (val) {
                this.resolves.forEach((resolve: any) => resolve());
            } else {
                this.rejects.forEach((reject: any) => reject());
            }
            this.resolves = ();
            this.rejects = ();
        }

    };

    constructor() {
        this.authorize();
    }

    // Test Request
    public async test(reqBody) {

        const reqOptions = {
            dataType: "json",
            headers: {
                Authorization: `Bearer ${this.token.value}`
            },
            json: reqBody,
            method: "POST",
            url: "http://localhost:8080/test-async",
        };

        const { data } = await request(reqOptions);

        // on success return data
        if (data.status === "200") {
            return data;
        }

        // if authentication fails generate new token and then request again
        if (data.status === "401") {
            return await this.unAuthorizeRequestHandler(this.test.bind(this, reqBody));
        }

        // if status other than 200 and 401 then throw error
        throw new Error(data.message);

    }

    // To Get Authentication Token
    async authorize() {

        const reqOptions = {
            dataType: "json",
            json: {},
            method: "POST",
            url: "http://localhost:8080/auth",
        };

        const { token } = await request(reqOptions);
        this.token.value = token;

    }

    // handles retry logic
    async unAuthorizeRequestHandler(requestFunction: any) {

        if (this.token.value) {
            this.token.value = null;

            try {
                await this.authorize();
            } catch (err) {
                this.token.value = null;
                throw new Error(err.toString());
            }

        } else {
            await this.token.promiseCreator();
        }
        return await requestFunction();
    }

}

In the above code, anAuthorizeRequestHandler handles the retry mechanism, it first checks to see if the value of the token is not zero. done by promiseGenerator, it returns the pending promise which will be resolved or rejected when authorizing the defined function token.value)

Please review my codes

c # – A class to provide an open database connection for the duration of a web request

For some database requests, I like to use raw ADO.NET.

As part of a web request, I created a class that provides an open IDbConnection object.

I use a dependency injection library ("DI") to do this, delimiting the instantiated object of this class to a web request. Thus, the disposal of the object is managed by the DI container.

The abstraction for this class is simple and looks like this:

public interface IDbConnectionManager : IDisposable
{
    IDbCommand BuildCommand(DbParameter() parameters, string query);
    IDbConnection GetOpenConnection();
}

And the concrete implementation, written for Sql Server, looks like this:

public class DbConnectionManager : IDbConnectionManager
{
    public SqlConnection DbConnection;
    public string ConnectionString { get; set; }

    public DbConnectionManager(string connectionString)
    {
        ConnectionString = connectionString;
    }

    public IDbConnection GetOpenConnection()
    {
        return GetOpenSqlConnection();
    }

    private SqlConnection GetOpenSqlConnection()
    {
        if (ReferenceEquals(DbConnection, null))
        {
            DbConnection = new SqlConnection(ConnectionString);
        }

        if (DbConnection.State != ConnectionState.Open)
        {
            DbConnection.Open();
        }

        return DbConnection;
    }

    public IDbCommand BuildCommand(DbParameter() parameters, string query)
    {
        if (parameters == null) throw new ArgumentNullException(nameof(parameters));
        if (string.IsNullOrWhiteSpace(query)) throw new ArgumentException(nameof(query));

        var command = new SqlCommand { Connection = GetOpenSqlConnection() };
        command.Parameters.AddRange(parameters);
        command.CommandText = query;

        return command;
    }

    public void Dispose()
    {
        DbConnection?.Dispose();
    }
}

You can see the BuildCommand use the method GetOpenSqlConnection for its connection.

The main reason why I chose this approach is that DbConnections are expensive. But I don't know if this is about creating or opening a connection.

I am aware that the connection pool is available (if activated), but I thought of simple web requests (think of the API), with maybe only 2 requests to the database, that it would probably be a good approach.

And as you can see, there is not much in the code.

I just wanted a little feedback on this code / approach.
And if you can see potential problems with that, let me know.

As a final comment, I am aware that a developer can call manually Dispose or use it in a using block (thus calling Dispose).
It would be up to me as the main developer to make sure that this does not happen and that the developers understand that the DI container has the object.

Specific data of a Laravel 5.8 request

I have a table where I save all the common data in several tables,

Basic data table (id, group, name).

In one form, I have multiple data groups, gender, category, ages, etc. so i make the request

$datosBase = DatosBasicos::where('grupo', 'genero')
->orwhere('grupo','edades')
->pluck('id', 'grupo', 'nombre');

The question is, once the data is sent in view, how can I see that only ages or gender appear in the corresponding field?

or it is better to separate the request by leaving:

$genero = DatosBasicos::where('grupo', 'genero')->pluck('id', 'nombre');
$edades = DatosBasicos::where('grupo', 'edades')->pluck('id', 'nombre');

nginx – SYNC_NOT_REQUIRED in request URL leads to 404

We noticed that the access logs from our Nginx website have quite a few 404 very strange URL requests that end with SYNC_NOT_REQUIRED

Example:
75.139.245.82 – – (12 / Dec / 2019: 22: 36: 29 +0000) "GET / first-dance-wedding-songs / SYNC_NOT_REQUIRED HTTP / 2.0" 404 12786 "/ first-dance-wedding-songs /" " Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 64.0.3282.140 Safari / 537.36 Edge / 18.17763 "

Some facts:
– pages load well, there is no redirection after page loading
– We have no code on the pages that would make such a request
– it's not clear what makes these requests (see them from Chrome, Safari and other browsers)
– there is nothing about it on Google, BUT, I already see Google indexing many pages that end with SYNC_NOT_REQUIRED. Just Google "SYNC_NOT_REQUIRED" in quotes. There is a page from Top Gear and other websites.

Questions:
– Does anyone know more details?
– should we just redirect by deleting SYNC_NOT_REQUIRED?

Thank you!

How to request cookie data from a full Bitcoin node?

So, I'm trying to build a Bitcoin block explorer using my own Python library. I'm just doing it as an exercise to better understand how Bitcoin works under the hood.

At the moment, when I send a blocking message to request information on a given block, I do not receive any cookie data for the transactions.

I have read that in order to receive cookie data, I should activate this service when I send my version message. I think I do it, but I still do not get any data from witnesses.

My service field in my version message looks like this:

Service bit field: [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Receive services bit field: [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Bit field of the sender services: [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

However, the version message I receive contains the following service fields:

Service bit field: [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Receiving Services: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Sender Services: [0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

What can I do to actually receive cookie data?

javascript – The definition of the header of the express request object is not preserved on all routes

I am trying to define sessionId in my req express object for use on other roads. When I configure it via middleware, it works. If I try the same thing via a route, it does not work.

I am trying to make the route approach work because I am trying to define a & # 39; sessionId & # 39; in my req , this sessionId is based on userName. Therefore, I would like the road approach to work.

Instead of req object, I tried to use res.locals but I am facing the same problem. What do I forget here?

When I say that it does not work, I meant that if I try to access req.headers.sessionid in another way it is undefined.

index.js

const express = require('express')
const app = express()
const setSessionId = require('./setSessionId');

app.use(function(req, res, next){ // this works...
    const { username } = req.body;
    req.headers.sessionid = crypto.createHash("sha256").update('Temp Name').digest("hex"); // to be replaced by corpId;
    next();
})
app.use('/login',setSessionId);

setSessionId.js

const express = require('express');
const router = express.Router();
const crypto = require('crypto');

router.post('/success', (req, res) => { // this doesnt work...
    const { username } = req.body;
    req.headers.sessionid= crypto.createHash("sha256").update(username).digest("hex"); // to be replaced by corpId;
    res.send(req.headers.sessionid);
});

module.exports = router;

http post – Public web tool to display the body of the request

Is there a public web endpoint that displays the data in the request body in a human-readable manner?

I have to present dynamic data which is sent via POST to non-technical people. I would like to show them the data in a format similar to what I get in the browser network inspector. I imagine sending my requests to a publicly accessible endpoint that would display the body of the request.

ibm midrange – ACS – Is it possible to automatically switch from "Use Kerberos authentication; do not ask" to Request username and password

If my ACS 5250 client's connection is configured to use the "Use Kerberos Authentication Not to Invite" method to connect to IBM I, is there a way to tell it to change to invite IBM I? User to enter the user name and password when Kerberos authentication did not work?

For example, if I have a user who is not configured in EIM, which will cause the Kerberos authentication failure, is there a way to configure ACS so that It automatically prompts the user to enter his user name and password, instead of displaying an encrypted Kerberos error?

reference request – Different definitions of solutions for ODE with irregular coefficient

What is the difference between the notions of

of an ODE $ dot Phi (t, x) = b (t, Phi (t, x)) $, with initial condition $ Phi (0, x) = x $, or $ b $ is a non-smooth vector field (that is, no Lipschitz)?

In general, are they related in one way or another? Under which hypotheses (non-trivial) are they equivalent? What is the strongest notion of solutions between these?