Archives

Archives / 2017 / May
  • How to get response from Walmart

    Hello everybody,

    today I want to share with the world another piece of code, producing of which took me significant amount of efforts, getting response from Walmart.

    Yesterday I've posted code that signs provided by Walmart credentials.

    And today I decided to post code that retrieves orders information from Walmart.

    private void MakeRequests()

    {

    HttpWebResponse response;

    if (Request_marketplace_walmartapis_com(out response))

    {

    response.Close();

    }

    }

    private bool Request_marketplace_walmartapis_com(out HttpWebResponse response)

    {

    response = null;

    try

    {

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https:// … more

  • Walmart signer

    Hello everybody,

    today I want to preserve at my blog piece of code that almost eaten my brain. Walmart signer. 

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using System.Globalization;

    using Org.BouncyCastle.Crypto.Parameters;

    using Org.BouncyCastle.Security;

    namespace Walmart

    {

    public class WallmartSigner

    {

    /// <summary>

    /// Begining of time according to Java world.

    /// </summary>

    private static readonly DateTime JanuaryFirst1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

    /// <summary>

    /// … more

  • How to measure size of Vector

    Hello everybody,

    today  I want to share with everybody information about function that is known as norm. Here it is:

    ||x|| p = ( Σ(|x|i)p) p -1

    For p ∈ R, p ≥ 1

    Also it is named as Lp norm. On intuition level it measures distance from some beginning point to locatio of x.

    L2 norm is often named Euclidian norm. Also due to heavy usage L2  is presented just as ||x|| with skipped 2. It means that if you see ||x|| it was intended to show you ||x||2.

    Sometime you can find L∞ norm. It is nothing more then maximum value of vector. 

    ||x||∞= maxi|xi|.

    more

  • How to execute bash docker image of Cent OS

    Hello,

    recently I had a need to execute CentOS image with bash. Following command proved helpful for me:

    docker run -i -t --rm centos /bin/bash

    Then at executed image you can do whatever you want. For example I had  a need to validate DNS server activity. 

    For this purpose I had to find what provides dig.

    Following command told me what:

    yum whatprovides dig

    And next command installed:

    yum install bind-utils more

  • How to redirect from port 80 on port 9000 with nginx

    Hello everybody,

    today I want to share with you how to make redirects with help of nginx. 

    I have executed docker image of portainer in my linux environment on port 9000. 

    And I need to make nginx to redirect incoming trafic from port 80 on port 9000. In order to achieve it I've made the following modifications in nginx.conf:

                   

    server {                listen 80 default_server;                listen [::]:80 default_server;                server_name _;                root /usr/share/nginx/html;

                   # Load configuration files for the default server block.                include /etc/nginx/default.d/*.conf;

                   location / {                              … more

  • Bind9 in CentOS

    Hello everybody,

    recently I've got a task to configure Bind9 on CentOS.

    While doing this I have found some hardly documented features of CentOS.

    File locations and defaults

    By default bind9 is has name named. It means that you can start it with command systemctl. For example you can get status of bind with this command:

    systemctl status named

    Information about zones are stored in zone files. By default named stroes zone files at /var/named/.

    Infromation about bind itself is stored at /etc/named* location.

    Following command tells us something more about those files:

     ls -ld /var/named

    drwxr-x--- 5 root named 127 May 17 17:25 /var/named

    It says that access to those files has two … more

  • Content of ping command according to Wireshark

    Hello everybody,

    today I want to share few words about usage of Wireshark and what it discovers about ping.

    As usually everyboydy who want to check does he have internet connection tries to enter command prompt and ping some web site. If ping is successful then person believes he has internet connection. If ping is not successful, it means that internet connection is somehow invalid. 

    But have you ever wondered what ping sends?

    Wireshark will help to get an answer!

    First step will be to open Wireshark, and type there in line for filters ICMP ( which stands for internet control messaging protocol )

    Second step will be to generate some kind of ping trafic. You can open command prompt … more

  • How to execute some process in Dockerfile

    Hello everybody,

    today I want to share another piece of code, that proved to be helpful for me in creating docker containers.

    Here it is:

    Start-Process c:\sdksetup.exe -ArgumentList '/Quiet /NoRestart' -Wait; \

    First time when I seen it I was sceptical. Why I should use Start-Process instead of just running application? The answer is simple: because quite often installers just execute some processes and give control to powershell in asyncronous way. And if other parts of your docker image are dependable from your sdksetup.exe, then you'll not get needed container.

    For example you can install Dot net 4.6.2 package in the following way:

    RUN Invoke-WebRequest 'https://download.microsoft. … more

  • One more example of selectors

    Hello everybody,

    today I want to present one more example of selectors, but the one, that has multiple fields in it. 

    Consider following code:

    using System;

    using System.Collections;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using PX.Data;

    using PX.Objects.CS;

    using PX.Objects.CT;

    using PX.Objects.DR;

    namespace MyBlog

    {

    public class DeliverySelectorAttribute : PXCustomSelectorAttribute

    {

    public DeliverySelectorAttribute(Type selectorField, params System.Type[] fieldList)

    : base(selectorField, fieldList)

    {

    }

    public override void FieldVerifying(PXCache … more

  • How to copy Folder in Dockerfile

    Hello everybody,

    recently I had following issue:

    copy folder dotnet-dev-win-x64.1.0.1 into c:\Program Files\Dotnet in container. After different dancing and triings I've found following command that worked:

    COPY ["dotnet-dev-win-x64.1.0.1", "c:/Program Files/dotnet"] more

  • How pageSource in Acumatica works

    Hello everybody,

    recently I was asked by one friends of mine, how pageSource in Acumatica works, i.e. how to code/decode pagesource contents. 

    After different methods of trial and error I've created following C# code in order to code/decode pageSource:

    Snippet

    private static string Compress(string src)

            {

                if (src.IsNullOrEmpty())

                {

                    return null;

                }

                byte[] bytes = Encoding.UTF8.GetBytes(src);

                using (MemoryStream stream = new MemoryStream())

                {

                    using (DeflateStream stream2 = new DeflateStream(stream, CompressionMode.Compress))

                    {

                        stream2. … more

  • Working with Nuget in Visual Studio 2015

    Hello everybody,

    today I want to describe some useful from my prospective commands for working with Nuget.

    First of all, I want to say that you can work with Nuget as usually with usage of wizard, but if wizard fails for some unknown reason, console can give you interesting facts, that otherwise will be hidden from your eyes. 

    First step is how to find Nuget manager console?

    You can use top right edit for opening nuget manager console, as shown at screenshot:

    After console window is opened, you can try following combinations.

    Get-Package -ListAvailable EntityFramework - search in all sources for library named Entity framework

    In newer version of nuget ( 3.0 + ) you can use Find- … more