1. use-case

  • I repeatedly pull changes from repos and need to quickly check what has happened to config files
  • My colleagues troubleshoot data pipelines and, learning from them, I need to see what they have done to the files in question

2. pull & log -p

  • this is not git diff
  • run git pull → fetch & merge potential merges
  • run git log -p → see what has been changed

3. file history: who & commit message

git log –pretty=format:”%C(auto)%h%d%Creset %C(cyan)(%ci)%Creset %C(green)%cn <%ce>%Creset %s” –name-status –date=short –all –full-history — FILENAME

Image for post
Image for post

4. sources


Last updated: Nov 15, 2020

usecase

The concern is documenting getting consul queries in grafana

1. variables

1.1. create consul datasource

  • create a Consul variable as a datasource type → select Consul
  • difference is that here, you can use also KEYS (not tree leaves) as values
Image for post
Image for post

1.2. create consul query

  • create a ConsulQuery variable as a query → select $Consul as a datasource
  • but how could I create the queries made out of variables — well, most probably
  • you have to be using those, the only variable I can think of is, however, only customer, can you create another one
Image for post
Image for post

2. queries

  • You can just query consul
  • here I would like to know now many nodes each client has in their ES…

1. registrars VS hosts

  • 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 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 site
  • this semantical layer of the internet, technically, computers are connected with ip addresses
  • registration means going through DNS REGISTRAR, which is a company that directly deals with the REGISTRY OPERATORS FOR THE TOP LEVEL DOMAIN
Image for post
Image for post
  • the global list of domain names is managed by IANA (International Assigned Numbers…

usecase

The concern is documenting the ways to find who is behind a particular change with git — not file history, but (as I call it) the line history.

1. git log -S

  • one way of going about that
  • you need a string or a piece of code
  • you search the entire repo
git log -S "_STRING_" --pretty=format:"%C(auto)%h%d%Creset %C(cyan)(%ci)%Creset %C(green)%cn <%ce>%Creset" --name-status --date=short

1.1. example

git log -S "nomad" --pretty=format:"%C(auto)%h%d%Creset %C(cyan)(%ci)%Creset %C(green)%cn <%ce>%Creset" --name-status --date=short
Image for post
Image for post

2. git blame

  • get the exact location within the file (exact line, or range, or the whole file if short)
  • search within a single file
  • you need a line number + filename
  • run git blame with L parameter to see who has modified that line exactly
Image for post
Image for post
git blame -e -L _LINE_N_START_, _LINE_N_END_ _FILENAME_

2.1. example

git blame -e -L 9,9 C:\Users\Admin\Documents\workspace\work.log\kb\powershell\pub-wlog.ps1
Image for post
Image for post

3. sources


usecase

The concern is documenting currently the fastest way to look for the commit and its content based on the search of commit message — using gitk

1. brainstorm

content of the commit message is what interests me here, mainly when there is a naming convention to commiting (some logic, well convention I would say) and I need to find the latest change done — this is all done within IaC when changing the config of EMR cluster or SQL job runner,…

2. steps

  • navigate to the repository
  • enter gitk
  • put the search string into the proper field and browse
Image for post
Image for post

3. footnotes

  • gitk is written in (for me newly discovered) Tcl/Tk

4. gitk-vs-git gui

  • not much xp, but seems that
  • gitk is analytical
  • git gui is more transactional; it focuses on refining individual commits, single file annotation and does not show project history (Atlasian)

5. sources


usecase

The concern is documenting the practice of AWS Redshift maintenance windows and the fact is it killing my load-jobs

Image for post
Image for post

When trying to perform a data-loading jon I am getting the following error and need to… resume manually !

Data loading error [Amazon](500150) Error setting/closing connection: Connection refused.

1. on maintenance

If a scheduled maintenance occurs while a query is running, the query is terminated and rolled back and you need to restart it. Schedule long-running operations, such as large data loads or VACUUM operation, to avoid maintenance windows. You can also minimize the risk, and make restarts easier when they are needed, by performing data loads in smaller increments and managing the size of your VACUUM operations. …


usecase

The concern is documenting the keyword self as used in python — when working within the OOP (Python w/ classes)

1. intro: on instance method

  • Instance methods are methods that can be called on objects, i.e. unique instances of the class
  • INSTANCE means that with this method it is possible to ACCESS UNIQUE DATA of the instantiated object of that class

If you have two objects each created from a car class, then they each may have different properties. They may have different colors, engine sizes, seats, and so on.

https://www.makeuseof.com/tag/python-instance-static-class-methods/

  • belong to the family of methods together with
  • class methods (a method for the whole…

usecase

  • The concern is documenting capturing the token from hashicorp vault and passing it to the Windows Environment Variables
  • that I need to re-issue every 12 hours in order to work with the stack.
  • The aim is to get both consul and nomad CLI to work properly and to use the same keys for the WEBUI
▶ vault read consul/creds/support
Key Value
--- -----
lease_id consul/creds/support/1111111111
lease_duration 12h
lease_renewable true
accessor 1111-1111-1111-1111-1111
local false
token 1111-1111-1111-1111-1111 <--- NEED TO ASSIGN THIS TO THE ENV VAR FOR CLI TO WORK
  • nomad output:
▶ vault read nomad/creds/nomad-viewer
Key Value
--- -----
lease_id nomad/creds/nomad-viewer/1111-1111-1111-1111-1111
lease_duration 12h
lease_renewable true
accessor_id 1111-1111-1111-1111-1111
secret_id…

abstract

The concern is documenting an accidental discovery of the DETACHED HEAD state

Image for post
Image for post

1. enter detached HEAD

  • note that HEAD is the term from data structure terminology for graph-types like lists or DAGs
  • it denotes the beginning point where the traverse can begin (TAIL being the end)
  • in git: HEAD === active branch — only 1 branch can be active, pointing to the latest commit
  • in powershell, from the main folder of the git project get the name of the active branch
gc ./.git/HEAD
ref: refs/heads/master
  • if you however checkout a particular commit with the its <sha> you'll enter a state of DETACHED HEAT

The detached HEAD state is useful for revisiting old states, and sometimes for short-term work that you are not sure you will keep. Other than that you probably want to avoid it. —…


usecase

the puzzle is, how to rename a bunch of file with a certain criteria. In my case, i have the following structure (snippet) and I need to remove all the digits from the name

├───FOO
│ loremIpsum02_NEECA_Northern_Europe.xlsx
│ loremIpsum03_NEECA_Czech_Republic.xlsx
│ loremIpsum04_NEECA_Hungary.xlsx
│ loremIpsum05_NEECA_Poland.xlsx
│ loremIpsum06_NEECA_Romania.xlsx
│ loremIpsum07_NEECA_Bulgaria_Greece.xlsx
│ loremIpsum08_NEECA_Georgia.xlsx
│ loremIpsum09_NEECA_Kazakhstan.xlsx
│ loremIpsum10_NEECA_Russia.xlsx
│ loremIpsum29_NEECA_All.xlsx

├───BAR
│ loremIpsum17_AEM_Turkey.xlsx
│ loremIpsum18_AEM_Egypt.xlsx
│ loremIpsum19_AEM_Morocco_Mauretania.xlsx
│ loremIpsum20_AEM_Africa 1.xlsx
│ loremIpsum21_AEM_Africa 2.xlsx
│ loremIpsum22_AEM_Africa 3.xlsx
│ loremIpsum31_AEM_All.xlsx

1. mass renaming get-childitem (dir)

get-childitem -recurse | Rename-Item -NewName {$_.Name -replace '\d{2}', ''}
  • pipe get-childitem (list content) with the recurse parameter (include the content of all subfolders) with the rename-item

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