Named Pipes. C# Python. .NET Core

I recently ran into issues  using the NamedPipeServerStream API  with .NET Core.

  • In Windows,  NamedPipeServerStream creates a pipe with a defined name in a specific location on the Windows filesystem (\\.pipe\\)
    • In a Python client application,  we were able to open this pipe for communication  using  the   code  snippet  :  open(r’\\.\pipe\\’ + pipe_name, ‘r+b’, 0)

 

  • However, on Linux,  the behavior for the NamedPipeServerStream API is different.
    • Looking at the source code for .NET Core,  I saw that NamedPipeServer/ClientStream in .NET Core are built on top of Unix domain sockets.
    • So, if we want to communicate with a Python client, we have to use Python’s socket module

Code:

 

References:

Advertisements

C# OutOfProcess Python

Using SSH Keys on Cloud Platforms

Azure:

  • openssl.exe req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem
    • We will mostly use the .key file
    • The .pem file is only needed for Classic deployments. Typically we wont use this.

—-

  • Look up use of req : https://linux.die.net/man/1/req
    • The req command primarily creates and processes certificate requests . Thats why the output of req is a cerificate (myCert.pem)
    • But we are interested in the private key (myPrivateKey.key). Hence we are using the -keyout flag

References:

 

AWS:

  • In AWS,  the private key is saved in a .pem file . you just use the .pem file to connect to the instances.
    • Ideally the .pem extension is for certificates, not for keys.
    • This was one of my confusions – because AWS saves the key in the .pem file 

 

Tip:

  • Use ssh-agent to store private keys. Makes life much simpler!

 

Terminal Choices and Tips

It seems there is a deluge of terminal options on the windows platform.

  • Cygwin
  • Mintty
    • Whats the relationship between cygwin and mintty ? 
    • The cygwin shortcut on my machine looks as follows:
      • C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico –
  • GitBash
  • MYSYS
  • CMD
  • PS

Tips:

 

References:

 

Multi-dimensional (axial) data handling in Python

Recently I was playing around with multi-dimensional data structures in Python.

Some interesting observations:

  1. Multi-dimensional lists and multi-dimensional arrays are fundamentally handled differently.
  2. Slicing of multi-dimensional arrays (numpy) need to be carefully considered in regards to shallow copy etc

 

Some references below for further examination:

References:

  1. http://ilan.schnell-web.net/prog/slicing/
  2. https://docs.python.org/2/library/copy.html
  3. http://stackoverflow.com/questions/509211/explain-pythons-slice-notation
  4. http://cs231n.github.io/python-numpy-tutorial/
  5. http://www.physics.nyu.edu/pine/pymanual/html/chap3/chap3_arrays.html
  6. http://www.astro.ufl.edu/~warner/prog/python.html

 

Pending Posts

 

References:

  1. http://www.codeproject.com/Tips/805923/Asynchronous-programming-in-Web-API-ASP-NET-MVC
  2. http://stackoverflow.com/questions/8463809/customize-the-authorization-http-header