usecase

  • The concern is documenting the need to quickly check the
  • certificate chain
  • certificate expiry date
  • using a single command from PowerShell with OpenSSL
Image for post
Image for post

1. steps

function test-certificate($domain) {
$domain += ":443"
openssl s_client -connect $domain | sls "certificate chain" -Context 5
openssl
openssl s_client -connect github.com:443 | openssl x509 -noout -enddate

2. passing the “Q” key into the command

  • s_client opens the client that is awaiting for the input
  • I need to pass the q into the script for the s_client to end gracefully and immediatelly
  • which is achieved with write-output "q" | ...
  • echo is alias for write-output cmdlet
echo "q" | openssl s_client -connect github:443

3. solution

  • just adding the following to the…

1. usecase

The aim is to document the security/networking concept of certificate chain based on the superb Troubleshooting with Wireshark: Analyzing and Decrypting TLS Traffic in Wireshark (Using HTTPs)

2. Certificate Authority Server (CA)

  • certificate must be issued by a trusted party called Certificate Authority Server
  • certificate authority is public and acknowledged by vendors

3. Cert Chain

  • check any certificate within a browser (devtools 🠊 certificate 🠊 certificate path) and see the certificate chain consisting of
  • 1 root certificate
  • 1+ intermediate certificates
  • 1 server certificate
Image for post
Image for post
  • we can do some mathematics to verify that the certificate was actually issued by a CA that is said it was (this verification is…

The concern is documenting ensuring pytest works as expected in vscode

1. requirements

  • there is 1 codeFile and 1 testFile
  • testFile is called *_test.py
  • test is called test_foo()
  • the only allowed separator on file (module) name is underscore _
  • no dots
  • no dashes
  • do not have code and tests in same file (I used to do that for katas, etc.)
  • you can use ptw for real-time testing there if needed

2. usage

  • have a custom keyboard shortcut for opening the test sidebar
  • CTRL + ALT + SHIFT + T
  • possibly also for running a particular test method / debug particular test method

3. creating code

  • lazy to keep creating an extra test file for each code…


the question is, what is the definition and opposition of unit tests, where is it coming from and what is the structure

From my own experience over many companies and teams over the years, most people who try to unit test their code either give up at some point or don’t actually perform unit tests. They waste a lot of time writing problematic tests and then give up when they have to waste a lot of time maintaining them or worse, not TRUSTING their results.

1 The basics of unit testing — The Art of Unit Testing, Third Edition MEAP…


usecase

The concern is documenting the need to remove whitespace with regex

Image for post
Image for post
how to remove all this whitespace in my python curriculum?

1. solution

  • some people dislike regex for its conciseness and lack of expressive power but once I got used to it, I see problems and solutions in unusual places!

… and how to get this information without leaving VSCode, ideally (i.e. with a powershell script and some free-tier of an dedicated web service)

1. registrars VS hosts vs registry operators

  • DOMAIN REGISTRAR is the subject where domain names are finally purchased
  • DNS HOST is the service/server authoritative for hosting your DNS records
  • there are hosting providers that offer domain registration
  • there are registrars that offer DNS hosting, but the two should not be confused
  • selecting a domain name is the first step you make when building a web…

usecase

The doc’s aim is to write a procedure for finding a method for finding a square root according to Heron of Alexandria.

1. algorithmic definition for finding the square root

Image for post
Image for post

2. CODE

  • composed of 7 functions
  • _tryThis is a recursive
  • begins at the bottom with calling the initial guess 1 with return _truncate(_tryThis(1))
def sqrt(x):
def _average(x, y):
return (x+y)/2
def _square(x):
return x*x
def _abs(x):
if x < 0:
return -x
elif x == 0:
return 0
else:
return x
def _improve(guess):
return _average(guess, (x/guess))
def _goodEnough(guess):
return _abs(_square(guess) - x) < 0.001
def _tryThis(guess):
if _goodEnough(guess):
return guess
else:
return _tryThis(_improve(guess))
def _truncate(n, decimals=3):
multiplier = 10 ** decimals
return int(n * multiplier) /

usecase

The concern is documenting cookies, essential to understanding for the modern BI.

1. origins

  • cookies were created in Netscape by Lou Montulli
  • the term goes back to Unix and C (same authors, same origins) meaning a piece of data passed between programs not essential for their functionality

2. http & state

  • http is designed as stateless protocol
  • there are transactions, known as request-response transactions
  • stateless means that each transaction is independent from any previous or future transaction
  • nothing in the protocol requires the server to retain state
  • every message is self-descriptive and requires all the information that is required to process that message
  • see Introducing self-describing JSONs for an inspired take on the data…

The concern is documenting my recent enjoyment of switching for personal use when I just run

shp com.acme-prod1 c

… from anywhere and this pulls the recent updates from the acme repo + immediately opens a config file I want to check

1. backstory

  • I was listening to programmers saying “don’t do switching”
  • But I realized this is advice starts to pay off at the certain level of complexity
  • In my personal use of PowerShell, I use lots of procedures where I pass a letter of the alphabet that is suggestive of the name of the feature I want to use and it does…

usecase

  • the question is that of an elegant interaction, i.e. not having to write long commands in a single line
  • the answer is don’t use backticks unless splitting arguments, try splatting and rely on natural line continuators like a pipeline operator or scriptblock operator (and many others)

1. backtick

  • a cmdlet ` Get-ChildItem -Path $env:windir -Filter *.dll -Recurse` can be made a little more readable by breaking up long lines with PowerShell’s escape character:
  • backtick is the escape character in powershell
PS C:\> Get-ChildItem `
-Path $env:windir `
-Filter *.dll `
-Recurse

In general, the community feels you should avoid using those backticks as “line continuation characters” when possible. …

About

Pavol Kutaj

today I learnt… | as a support eng of the wonderful Snowplow Analytics, expect everything around modern (postmodern?) business intelligence

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store