Hi, I’m Peter 👋

I like learning new things. When I learn something new, I try to summarize key points in Articles & apply it by building projects.

Stock Analysis

Intelligent Investor is a classic investment book written by Benjamin Graham, often considered the father of value investing. Originally published in 1949, the book offers timeless principles for sound investing. It is one of my most favorite finance books and to summarize key points deserves a single post in itself. Python (or programming in general) is very popular in the financial industry. I really like to work on my programming skills on a real-world projects, hence I have built a small script that analyzes stocks based on Benjamin Graham’s criteria (but I also added some other small criterias) for finding undervalued stocks. ...

December 10, 2024 · 2 min · 275 words

Simple SQL tips

Nothing ground breaking, but hey, simplicity and basics are the most important. Reader Rules Don’t run select * queries without filters You might not know how big the table you are querying is. Therefore, in order not to negatively impact the performance of the whole system, limit the amount of the query. Instead of 1 select * from myTable; use 1 select * from myTable limit 10; Writer Rules Use transactions Even simple & tested queries might have unintentional side-effects. ...

April 20, 2024 · 2 min · 231 words

How to do a null check

Checking for null is important in programming to avoid potential runtime errors, prevent crashes, and ensure the reliability and robustness of your code. In C#, we can check for null in few different ways, depending on the context. So far I have been using following methods: Using the equality operator 1 2 3 4 5 6 7 object obj = null; if (obj == null) { // if null, do something } Using the is keyword 1 2 3 4 5 6 7 object obj = null; if (obj is null) { // if null, do something } Using the ReferenceEquals() method 1 2 3 4 5 6 7 object obj = null; if (ReferenceEquals(obj, null)) { // if null, do something } Using the != opeartor 1 2 3 4 5 6 7 object obj = null; if (obj != null) { // object is not null } Using the null-conditional operator ?. 1 2 3 var text = null; int? length = text?.Length; // length will be null, if text is null Using the null-coalescing operator ?? 1 2 3 var text = null; var result = text ?? "default non-null value"; // if text is null, use the default value

March 11, 2024 · 1 min · 203 words

Update PIP Packages

I am trying to implement inifinite scroll functionality to some of my blog pages and at the same time decided to do some maintanance work for my blog, which includes upgrading the packages I am using. I have found a lot of ways, but really simple one is to use an external library called pip-review. First install the lilbrary: pip install pip-review{.single} To upgrade packages manually run: pip-review --local --interactive{.single} To upgrade all packages automatically run: ...

March 10, 2024 · 1 min · 79 words

Access Modifiers

I have recently started learning C# language, which, compared to python, is a lot more verbose and structured. C# syntax is influenced by C and C++ languages. Part of CS50 Introduction to Computer Science course used C language, so having seen the syntax before helps a lot. However, working mostly with Python, there is a lot of difference. As I like to do, I will try to summarize key points as it helps me to learn and understand the language more. ...

February 25, 2024 · 3 min · 486 words

Bash shortener

I prefer not to have a lot of text in my bash as it can get unreadable quickly. For that reason I have learned a small trick to shorten the bash line. I prefer the format (environment) (dirname)$. To use it once, simply copy the following line into the bash: PS1='\W\$ '. However it was annoying to do it each time I started a new bash, so I inserted it to the ~/.bashrc in order to make it persistent (however, only for VSCode program). ...

December 21, 2023 · 1 min · 108 words

Special Methods

I want to learn Python deeply. Because I like to combine learning materials and I also like to learn from books, I have bought a book considered “a bible of Python” - Fluent Python. It contains almost 1000 pages and has really good reviews. I will use it not only as a reference when I need to look something up, but I will slowly go through it topic-by-topic in order to learn as much about the language as possible. ...

November 28, 2023 · 2 min · 415 words

Inspecting temporary pop-up

I needed a selector for a temporary pop-up, but it was impossible to get it in time as it would disappear quickly. Found a small trick using browser devtools. Open console Run the following javascript: setTimeout(() => { debugger; }, 5000){.single} Click the element that calls the pop-up Browser will enter debugger mode in 5 seconds (you can adjust), freeze the page and you can inspect the pop-up.

November 25, 2023 · 1 min · 68 words

No Need To Know Everything

Learning anything deeply requires a lot of time and it is an on-going process. Programming is no different. Challenging part is that, it seems like, there is always more and more to learn. For example, learning Python - you can go through basics in 1 hour, but when you start exploring it more and actually start using the language, you always find something new. A new feature, library, module, tool, n different ways of doing a task. ...

November 5, 2023 · 2 min · 219 words

PyTest - Parametrizing Test Functions

One of key features of PyTest is the ability to create parametrized tests, meaning running test cases with various input values without having to write separate test cases. Main goal of my most recent Django project is to develop better understanding of testing principles and tools. I have already built few Django applications, however never really focused on testing my own code - I was just happy the app “worked”. Knowing what and how to test is a skill in itself. It is quite a challenge. One can write hundreds of test cases which are not really covering the essential functionalities, or they repeat. Just as most of the things, it comes with a practice. However, I understand the long-term value of writing and having effective tests. ...

October 6, 2023 · 2 min · 417 words