SOLID Software Design Principles
SOLID
[S]ingle-responsibility principle:
Every class should only have one responsibility.
[O]pen-closed principle:
Software entitities (e.g. classes, functions, components), should be open for
extension, but closed for modification. Write code in a manner that you are able
to add new functionality, without changing the existing code, this prevents …
Read More
Git Stash
If you just quickly want to create a temporary stash:
git stash
# .. do your thing
git stash pop
This create and applies a stash, if you want to manage multiple stashes however,
the following process is recommended:
[A] Create stash
git stash push -m "stashname"
Or simply use git stash …
Read More
Git Submodules
Add a submodule
You can add either a HTTPS or SSH URL (SSH is most convenient)
E.g. for github an HTTS URL looks like: https://github.com/...
and SSH URL looks like: git@github.com:...
. The URL can be
picked from the github UI (Code button dropdown box).
Read More
Git LFS
First you need a .gitattibutes files in your repository. This is where the
LFS file patterns are stored.
:::sh
touch .gitattributes
Now lets start tracking *.gz files as LFS.
This tells git-lfs to track all files matching the .bin pattern. The quotes
around the *.bin are …
Read More
SW Development Estimation
The ABCD Rules of thumb for SW dev. estimation
[A] Clarify scope & requirements
This includes making sure everyone really understand the requirements
Clarifying requirements can be difficult, and often those who kwow the exact requirements, don't always
understand how to convey them to the development team (itereate untill this is …
Read More
Docker cheatsheet
# run docker container with mounted host directory
# (use a full absolute path for <host_dir>
docker run -v <host_dir>:<container_dir> -it <image_id|image_name> /bin/bash
# connect to a running docker container
docker ps
# >> container_id image container_name
# >> ... ... ...
docker exec -it <container_id|container_name> /bin …
Read More
Bash cheatsheet
# To witch shell type, e.g. zsh
chsh -s /bin/zsh
chsh -s /bin/bash
# To hide bash deprecation warning on mac add the following to .bash_profile
export BASH_SILENCE_DEPRECATION_WARNING=1
# filter output and just print the n'th line of it
bash someScript.sh | sed -n …
Read More
Go cheatsheet
Most example code taken from A Tour of Go, which is an excellent introduction to Go.
If you're new to Go, do that tour. Seriously.
Go in a Nutshell
- Imperative language
- Statically typed
- Syntax tokens similar to C (but less parentheses and no semicolons) and the structure to Oberon-2
- Compiles …
Read More
Manage multiple JDK versions
To find the available JDK packages available for your system you can use
apt search
, to install for example java-8 and java-11 JDK:
sudo apt install -y openjdk-8-jdk openjdk-11-jdk
NOTE: Since Debian 11, minimum available openjdk vesion included in the debian
repositories, is version 11. The older JDK version can …
Read More
Breadth First Search (BFS) in Python
import queue
class BreadthFirstSearch:
def __init__(self, graph):
"""
graph: Graph represntation in the form of an adjecency list.
E.g: `B <- A -> C`, graph = { 'A' : ['B','C'], }
"""
self._graph = graph
def head(self):
# NOTE: In Python 3.7.0 the insertion-order preservation nature of
# dict objects has been declared to …
Read More