docker – Nginx server configuration for hosting an Angular app proxying requests for the API calls

How one is able to proxy the requests (or the API calls) of an Angular app hosted on Nginx towards backend running on a docker container (the Angular app is also dokcerized)?

Currently, I have an nginx.conf file and copying it to /etc/nginx/conf.d/default.conf, but cannot get the results from the backend. This is nginx.conf file:

server {
   listen 80;
   server_name localhost;

   root /usr/share/nginx/html;
   index index.html index.htm;

   location / {
      try_files $uri $uri/ /index.html = 404;

    location /api/ {



python – Should I use Flask w/ Javascript OR a Javascript UI that calls a Flask / Connexion API?

I recently wrote a data management tool in Python & SQLAlchemy. Now, I need to put a web UI on it. While I want to start small, there is some need for interactivity, like drag and drop in tables, that I can’t do in ‘plain’ HTML / CSS. It seems to me that there are two basic paths I can take from here and I’m not sure how to choose the right one. As I see it, both paths involve Flask and they are:

Develop my UI with

  • Flask, embedding Javascript where needed to provide the interactivity
    I need, or
  • Develop the UI in Javascript, having it call an API I develop using Flask with Connexion and Open API

Today, someone suggested to me that it would be easier to develop the UI in Flask and that, as I’m doing that, adding an API for others to get to my app would be relatively simple, giving me both a UI AND a platform for writing a pure Javascript UI application.

I know Python and databases. I don’t really know HTML / CSS / Javascript and will likely have someone else write that part for me, wherever it sits.

Does anyone have any suggestions as to what would be the best way to get something done quickly while retaining long term flexibility? Thanks for your help!

Why, if a function accepts arguments, it fails on ajax calls?

I am trying to write a WP function to work with both ajax and direct calls, something like this:


function some_function($var){
    $var = !empty($var) ? $var : $_POST('var');
    echo $var;
    //or even

    $var = null;
    echo 'something';

    if(!empty($_POST('action'))) wp_die();


let ajaxurl = '███';
let data = {'action': 'somefunction','var':'foo')};
$.post(ajaxurl, data, function(response) {console.log(response);});

WP use

add_action( 'wp_ajax_somefunction', 'some_function',10,1);
add_action( 'wp_ajax_nopriv_somefunction', 'some_function',10,1);

Another WP use


However, any time I place $var as an accepted function argument, some_function($var), my ajax calls start returning a 500 error. So, something like this

function some_function(){
    $var = !empty($var) ? $var : $_POST('var');
    echo $var;

works for ajax.

I tried looking up wp ajax & arguments, but the search results are always about the variables we pass through ajax, not the callback function arguments. The only thing I learned is that we have to add a number of accepted arguments into add_action()

What am I doing wrong?

Thank you.

…P.S. I found a funny workaround:

function some_function_ajax(){
    $var = $_POST('var');
function some_function($var){
    echo $var;
} // =)

but still, what is the right way?

speaker – Can’t hear voice calls in Android 10 one Ui2

I’. m not able to hear the caller voice in my Samsung Galaxy A8 star, since two days.
The person in the other end is able is able to hear me, but where I m not able to hear the voice of the speaker, Unless i plug in the earphones or enable speaker mode.
I tried contacting samsung service providers, but no response.

Please help.

c – write() with to many system calls

I have a writeOnFile() method with too many fwrite().
I think it is not a good implementation because too many system calls may produce a high overhead.

What can I do?


void writeOnFile()
    char cr(1) = {'n'};    //Usefull characters
    char sp(1) = {' '};

    char header1() = "Instant        ";             //Headers
    fwrite(header1, 1, strlen(header1), out);
    char header2() = "Playing (1 yes, 0 no)    ";
    fwrite(header2, 1, strlen(header2), out);
    char header3() = "Segment ID    ";
    fwrite(header3, 1, strlen(header3), out);
    char header4() = "Encode leveln";
    fwrite(header4, 1, strlen(header4), out);

    char strNumber(50);                             //Data writing
    for (int i = 0; i < global_index; i++)
        snprintf(strNumber, 50, "%f", instants(i));
        fwrite(strNumber, 1, strlen(strNumber), out);
        //Adds spaces
        for (int i = 0; i < strlen(header1) - strlen(strNumber); i++)
            fwrite(sp, 1, 1, out);

        snprintf(strNumber, 50, "%d", playing(i));
        fwrite(strNumber, 1, strlen(strNumber), out);
        for (int i = 0; i < strlen(header2) - strlen(strNumber); i++)
            fwrite(sp, 1, 1, out);

        snprintf(strNumber, 50, "%li", segment_index(i));
        fwrite(strNumber, 1, strlen(strNumber), out);
        fwrite(sp, 1, 1, out);
        for (int i = 0; i < strlen(header3) - strlen(strNumber) - 1; i++)
            fwrite(sp, 1, 1, out);

        snprintf(strNumber, 50, "%d", encode_level_buff(i));
        fwrite(strNumber, 1, strlen(strNumber), out);

        //Inserts a n at the end of the row but not at the end of file
        if (i != global_index - 1)            
            fwrite(cr, 1, 1, out);

Output example

enter image description here

crawl errors – Google Search Console reports blocked resources from DoubleClick while rendering my pages, where do these calls come from?

Doubleclick is subsidiary of Google, which develops and provides Internet ad serving services. Using Adsense with dynamic allocation and targetting will automaticlly receive more relevant adds from the Doubleclick network.

The reason that Google Search Console is nagging is because one or several resources are blocked, these can be internal resources or external such as Doubleclick, if you take a look at the robots.txt on their server (, you can see that they do not want their resources indexed, therefore, you see this message in your control panel.


Nothing to worry about if you are using advertising on your site.

audio – WF-1000XM3 Bad Sound during Calls on MacOS

So, WF1000-XM3 works pretty fine on my Windows 10 (after A LOT of drives installation) and on Android. On MacOS it does well if NOT on a call, using AAC as the default Codec.

BUT, when I enter on a call (meet, zoom, etc…) it falls back to SCO as the codec and then the sound is awful. I tried all the download developers tools things and Enabled AAC and aptX, but still WF1000-XM3 does default to SCO making it really bad for any meeting, to the point where I just set meetings with the Laptop Mic and output sound on Wf1000 (then it uses AAC).

Sony support only mentioned that this should be on the Apple side and refer to further assist.

Has anyone seen this before?

multithreading – Use cURL and threads to make API calls


We use a tool where we have Jython as one of the scripting languages available for making custom scripts. The requirement is that we need to make multiple API calls (in parallel) and aggregate those results in a single JSON using a script.

Previous attempts

My go-to instinct was to use requests but it didn’t work out. Please refer to the following StackOverflow question.

Jython: Getting SSLError when doing requests get

In my local environment, the simple Java way of doing it worked but when trying to do the same thing in the tool, it gave me an error.

Working implementation

So, the only other option that we could think of was using cURL. Following is a similar implementation that we have.

Note: I used the jsonplaceholder APIs for doing this test.

import json
import subprocess
from threading import Thread
import pprint

def execute_get_api(url, key, results):
    p1 = subprocess.Popen((
        'curl', '--location', '--request', 'GET', url
    ), stdout=subprocess.PIPE, shell=False)
    out, err = p1.communicate()
    results(key) = json.loads(out)

def get_post(post_id):
    post_url = '' % post_id
    comments_url = '' % post_id

    # Temporary dictionary to store responses from the API calls
    results = {
        "post": "",
        "comments": ""

    # Making the API calls
    threads = ()
    get_posts = Thread(target=execute_get_api,
                       args=(post_url, 'post', results))
    get_comments = Thread(target=execute_get_api,
                          args=(comments_url, 'comments', results))



    for th in threads:

    return results

def driver():
    pp = pprint.PrettyPrinter(indent=4)

if __name__ == '__main__':


{   'comments': (   {   u'body': u'laudantium enim quasi est quidem magnam voluptate ipsam eosntempora quo necessitatibusndolor quam autem quasinreiciendis et nam sapiente accusantium',
                        u'email': u'',
                        u'id': 1,
                        u'name': u'id labore ex et quam laborum',
                        u'postId': 1},
                    {   u'body': u'est natus enim nihil est dolore omnis voluptatem numquamnet omnis occaecati quod ullam atnvoluptatem error expedita pariaturnnihil sint nostrum voluptatem reiciendis et',
                        u'email': u'',
                        u'id': 2,
                        u'name': u'quo vero reiciendis velit similique earum',
                        u'postId': 1},
                    {   u'body': u'quia molestiae reprehenderit quasi aspernaturnaut expedita occaecati aliquam eveniet laudantiumnomnis quibusdam delectus saepe quia accusamus maiores nam estncum et ducimus et vero voluptates excepturi deleniti ratione',
                        u'email': u'',
                        u'id': 3,
                        u'name': u'odio adipisci rerum aut animi',
                        u'postId': 1},
                    {   u'body': u'non et atquenoccaecati deserunt quas accusantium unde odit nobis qui voluptatemnquia voluptas consequuntur itaque dolornet qui rerum deleniti ut occaecati',
                        u'email': u'',
                        u'id': 4,
                        u'name': u'alias odio sit',
                        u'postId': 1},
                    {   u'body': u'harum non quasi et rationentempore iure ex voluptates in rationenharum architecto fugit inventore cupiditatenvoluptates magni quo et',
                        u'email': u'',
                        u'id': 5,
                        u'name': u'vero eaque aliquid doloribus et culpa',
                        u'postId': 1}),
    'post': {   u'body': u'quia et suscipitnsuscipit recusandae consequuntur expedita et cumnreprehenderit molestiae ut ut quas totamnnostrum rerum est autem sunt rem eveniet architecto',
                u'id': 1,
                u'title': u'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
                u'userId': 1}}

I’m not sure if there is any other way of doing this. Also, do let me know if this approach can be improved.

Any help will be appreciated 🙂

api – Building custom solution for phone calls and text messaging

I want to build the app similar to these two:

Basically the app provide you with second phone number but it should also support these features:
issue phone number, contact Sync, cloud storage of Call Transcripts and Texts, Custom VoiceMail setup, etc.
Ther there is Number Porting, Contact Sync, Group Messaging, Separate Caller ID, Voicemail to Text, SMS + MMS Messaging, Custom Voicemail.

Now I am aware of few PaaS providers that could support these features:

Tech stack I will use to build the app is:
Ionic framework + Firebase as backend
As it is cross-platform framework, app should run on both Android and iOS.

Question: Does anyone has experience on building these types of apps and is there better PaaS then those 2 ?

c# – Is it good idea to use expensive LINQ calls under heavy load?

I am working with cassandra using datastax c# driver. I need to pull data out from three different tables. Below is my code which does the job.

    private const string itemMapStmt = "FROM product_data WHERE client_id = ? PER PARTITION LIMIT 1";
    private const string itemSelectStatement = "FROM item WHERE item_id = ? PER PARTITION LIMIT 1";
    private const string itemProStmt = "FROM process_holder WHERE item_id = ? AND process_id = ? PER PARTITION LIMIT 1";
    private var semaphore = new SemaphoreSlim(100);

    private readonly IResponseMapper rpm;
    private readonly Cluster cluster;
    private readonly ISession session;
    private readonly IMapper mapper;

     * Below method gets data from all 3 different tables.
    public async Task<IList<Item>> GetAsync(IList<int> clientIds, int processId, int proc, Kyte kt)
        var clientMaps = await ProcessCassQueries(clientIds, (ct, batch) => mapper.SingleOrDefaultAsync<ItemMapPoco>(itemMapStmt, batch), "GetPIMValue");

        if (clientMaps == null || clientMaps.Count <= 0)
            return null;

        var itemIds = clientMaps.SelectMany(x => x.ItemIds).Where(y => y != null).ToList();

        // 1st table
        var itemsTask = ProcessCassQueries(itemIds, (ct, batch) => mapper.SingleOrDefaultAsync<ItemPoco>(itemSelectStmt, batch), "GetAsync");

        // 2nd table
        var itemProTask = ProcessCassQueries(itemIds, (ct, batch) => mapper.SingleOrDefaultAsync<ItemProPoco>(itemProStmt, batch, processId), "GetIPValue");

        var items = await itemsTask;
        if (items.Count <= 0)
            return null;

        var itmDictionary = items.ToDictionary(dto => dto.ItemId, dto => rpm.MapToItem(dto, proc));
        var itmProDict = itemIds.ToDictionary<int, int, ItemProPoco>(id => id, id => null);
        var holder = new List<int>();

        var itemPrices = await itemProTask;
        itemPrices.ForEach(i => { if (i != null) itmProDict(i.ItemId) = i; });
        foreach (var ip in itmProDict) if (ip.Value == null) holder.Add(ip.Key);

        if (holder.Count > 0)
            // 3rd table
            var ipHolder = await ProcessCassQueries(itemIds, (ct, batch) => mapper.SingleOrDefaultAsync<ItemProPoco>(itemProStmt, batch, kt.Pid), "GetIPValue");
            ipHolder.ToList().ForEach(ipf => { if (ipf != null) itmProDict(ipf.ItemId) = ipf; });

        return itmDictionary.Select(kvp =>
            itmProDict.TryGetValue(kvp.Key, out var ip);

            if (kvp.Value != null)
                rpm.convert(ip, kvp.Value);
                return kvp.Value;

            return null;
        }).Where(s => s != null).ToList();

     * Below method does multiple async calls on each table for their corresponding id's by limiting it down using Semaphore.
     * (does below method looks right in terms of performance?)
    private async Task<List<T>> ProcessCassQueries<T>(IList<int> ids, Func<CancellationToken, int, Task<T>> mapperFunc, string msg) where T : class
        var tasks = ids.Select(async id => 
            await semaphore.WaitAsync();
                ProcessCassQuery(ct => mapperFunc(ct, id), msg);

      return (await Task.WhenAll(tasks)).Where(e => e != null).ToList();

    // this might not be good idea to do it. how can I improve below method?
    private Task<T> ProcessCassQuery<T>(Func<CancellationToken, Task<T>> requestExecuter, string msg) where T : class
        return requestExecuter(CancellationToken.None);

In my ProcessCassQueries method, I get data out from cassandra for each id but I am limiting it down using Semaphore so that I don’t put pressure on Scylla db under heavy load. I wanted to see is there anything we can do here to improve things out in terms of performance as this method will be used under very heavy load and I see lot of expensive LINQ calls like ToDictionary, ToList, ForEach that could be problematic under heavy load.

Anything we can improve here?