mardi 1 janvier 2019

Unable to download a file from the link, used CURL

I am trying to download stockmarket data from NSE website, till 2018 i was able to get the file downloaded using CURL in command Line, But now its not working anymore.

Please help me a way to download it from command line.

Working : Using Chrome and clicking on the link Not Working : CURL method, copying the link to chrome in another tab is also not working

curl -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" https://www.nseindia.com/content/historical/EQUITIES/2019/JAN/cm01JAN2019bhav.csv.zip
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;www&#46;nseindia&#46;com&#47;content&#47;historical&#47;EQUITIES&#47;2019&#47;JAN&#47;cm01JAN2019bhav&#46;csv&#46;zip" on this server.<P>
Reference&#32;&#35;18&#46;93fa56b8&#46;1546394430&#46;40ca86c6
</BODY>
</HTML>

A zip file has to be downloaded without being corrupted.




Multiple user's accounts in mySQL with PHP

Can you help me, please, to solve this. There is a table (user's access log) in mysql: "user_id" "Ip" "access_date".
Is it possible to display all User's double accounts (multiaccounts, users with different ID, but used same IP), without huge load on mysql & server resources?

Like:
"10" "155.166.11.2" "2018-01-22 13:08:36"
"122" "127.0.0.1" "2018-01-22 13:19:00"
"13" "144.11.11.4" "2018-01-31 17:16:56"
"10" "127.0.0.1" "2018-01-31 17:26:35"
"99" "155.166.11.2" "2018-01-31 17:26:55"
"13" "12.11.22.4" "2018-01-31 17:43:56"
"18" "145.106.11.2" "2018-01-31 18:50:18"
"11" "144.11.11.4" "2018-01-31 18:54:18"
"10" "155.166.11.2" "2018-01-31 19:08:26"

Result:
"10, 99, 122" - same user
"11, 13" - same user.




Master Mind Game on a website, is there a copyright issue?

I made a master mind game in the browser, just for fun. On its wiki page https://en.wikipedia.org/wiki/Mastermind_(board_game) it says, that some company Invicta Plastics is holding the rights to the game. Am I allowed to put it on a web page, obviously not for sale, but just for me and my friends to play it online?




Weighted load balancing Nginx

Its my first time working with Nginx, and i started doing some balancing.

I have the next shema:

  • Nodejs app1 running (IP:5050).
  • Nodejs app2 running (IP:6060).

And i have this load balancing config:

upstream backend {
   #least_conn;
   #ip_hash;
   server 172.29.24.1:5050 weight=3;
   server 172.29.24.1:6060 weight=5;
}

I need to get this:

Make 1 of every 3 times load the first application and 2 of every 3 for the second application




Update single field on Firestore database (cloud) with simple https request

I'm currently using Swift (macOS) & that doesn't matter.

I can get my database data with this simple get request from Firestore

https://firestore.googleapis.com/v1beta1/projects/MY_PROJECT_NAME/databases/(default)/documents/" + "User_email" + "?pageSize=100&pageToken=" + "NextPage_Id"

Now I want to update one single filed on the database & I don't know how.

The Firebase api guide is too complicated for me & I don't understand it.

I found this get request url:

https://firestore.googleapis.com/v1beta1/projects/{projectId}/databases/{databaseId}/documents/{document_path}?updateMask.fieldPaths=status&updateMask.fieldPaths=title

But when I try it, it gives me this error:

 {
"details" : [
  {
    "fieldViolations" : [
      {
        "description" : "Invalid JSON payload received. Unknown name \"updateMask.fieldPaths\": Cannot bind query parameter. Field 'updateMask' could not be found in request message."
      }
    ],
    "@type" : "type.googleapis.com\/google.rpc.BadRequest"
  }
],
"code" : 400,
"message" : "Invalid JSON payload received. Unknown name \"updateMask.fieldPaths\": Cannot bind query parameter. Field 'updateMask' could not be found in request message.",


  "status" : "INVALID_ARGUMENT"
  }
}

I Use above url like this:

https://firestore.googleapis.com/v1beta1/projects/MY_PROJECT_NAME/databases/(default)/documents/" + User_email + "/MY_COLLECTION_ID/?updateMask.fieldPaths=name&updateMask.fieldPaths=aaaa

Where did I do wrong?




Need suggestions in help making a conditional parameter initialize a class with DI, C#, and Web API 2.0

I am using Unity dependency injection and Web API 2.0.

I have a controller which i am injecting my unit of work:

public ProductController(IUnitOfWork unitOfWork)
{
    _unitOfWork = unitOfWork;
}

I then have a method in that controller:

public HttpResponseMessage UpdateProducts(string website)
{ 
   ProductAPI productAPI;
   Enum.TryParse(website, out Website website);

   productAPI = new ProductAPI(_unitOfWork, website);
   productAPI.UpdateProducts();
}

The method takes in a parameter website which is a enum. It has 3 different values (website1, website2, website3).

This is the ProductAPI constructor that takes in UOW and the website enum:

public ProductAPI(IUnitOfWork unitOfWork, Website website)
{
    _unitOfWork = unitOfWork;
    _website = website;
    _httpClient = CommonAPI.GetHttpClient(website);
}

The CommonAPI class is a static class that returns the httpclient based on the website.

public static HttpClient GetHttpClient(Website website)
{
    HttpClient httpClient = new HttpClient();

    if (website == Website.1)
    {
        //return httpclient for website 1
    }
    else if (website == Website.2)
    {
        //return httpclient for website 2
    }
    else if (website == Website.3)
    {
        //return httpclient for website 3
    }

    return httpClient;
}

The ProductAPI class also has calls within its methods that use the UOW but also use the website enum to filter based on the website value:

List<ProductViewModel> products = _unitOfWork.ProductRepository.GetProducts(_website.ToString());

Is there a better and cleaner way to set this code up based on that website enum?




free domain websites for hosting

I have a web site and I want to publish it, I tried to do it by downloading IIS and create a physical path but it is not working. So what is the best way for free domains to host my website?