Skip to content

Instantly share code, notes, and snippets.

View bbrt3's full-sized avatar
🤑

Hubert Kłonowski bbrt3

🤑
View GitHub Profile
@bbrt3
bbrt3 / Fundamentals---ORM.cs
Last active October 7, 2022 10:49
Entity Framework Core
/*
ORM (Object-Relational Mapping) allows us to have a framework
for storing objects within relational databases and translating between
DATABASE-CODE communication.
What is ORM?
1. Object relational mapping is a technique for storing,
retrieving, updating and deleting (CRUD) from
an object-oriented program in a relational database.
2. Utilization of "data layer" to manage translation between the OO and relational
@bbrt3
bbrt3 / actionInjection.cs
Last active July 31, 2021 17:30
Dependency Injection
public interface IClass
{
void TestMethod();
}
public class Class : IClass
{
void TestMethod()
{
Console.WriteLine("LOL");
@bbrt3
bbrt3 / asyncOperations.cs
Last active July 31, 2021 17:33
Asynchronous Programming in C#
private async void Search_Click(object sender, RoutedEventArgs e)
{
...
// By using Task.Run we can execute code that is not asynchronous-friendly
// on different thread so it wont block our main UI for example.
await Task.Run(() =>
{
var lines = File.ReadAllLines(@"path");
SELECT a.Id, COUNT(b.Title) AS BookCount FROM BooksDB.dbo.Books AS b JOIN BooksDB.dbo.Authors AS a ON b.AuthorId = a.Id GROUP BY a.Id
UPDATE BooksDB.dbo.Fun SET Value = (SELECT COUNT(b.Title) AS BookCount FROM BooksDB.dbo.Books AS b JOIN BooksDB.dbo.Authors AS a ON b.AuthorId = a.Id GROUP BY a.Id)
ID AUTORA LICZBA_KSIĄŻEK (ZLICZONA W QUERY) AS LQ LICZBA_KSIĄŻEK (ZAPISANA W TABELI) AS LT
-------------------------------------------------
JOIN STATS ON LT.ID = LQ.ID
---------------------------------------------
@bbrt3
bbrt3 / REBASE.txt
Last active August 6, 2021 14:04
git
Let's assume that you have branch named "routing” and you are working on it. 
At first, make sure your git fetch  and git pull master (or like previously in our team table-view-of-events) 
Then you need to create new branch based on master (or like previously in our team table-view-of-events) 
     You can name it like for example routing-rebase1 
     It will be on your local machine, no need to push it to ADO
 
Then, you need  git checkout routing-rebase1 
 
/*
List of Angular elements:
a) component
b) directive
c) module
d) pipe
e) service
- interceptors
- resolvers
f) guard
@bbrt3
bbrt3 / Design Patterns---tech.txt
Last active August 10, 2021 19:06
Architecture
Strangler
Bridge
Factory
Abstract Factory
Mediator
Adapter
Decorator
Null object
Builder
Prototype
@bbrt3
bbrt3 / shortcuts.md
Last active July 31, 2021 17:58
VSCode
  1. General Shortcuts Ctrl+Shift+P/F1

Show Command Palette

Ctrl+P

Quick Open

Ctrl+Shift+N

// FASTER THAN INTERFACES, BECAUSE EVERYTHING IS IN ONE PLACE!
public abstract class AbstractWorker
{
// CONST, FIELDS, PROPERTIES ALLOWED!
const int salaryMultiplier = 1;
protected int Salary { get; set; }
private IWorker _worker;
public constructor(IWorker worker, int baseSalary)