Skip to content

Instantly share code, notes, and snippets.

View gpproton's full-sized avatar

Grayscale Pacifista gpproton

View GitHub Profile

Read Part 1: MediatR vs MassTransit Mediator - Differences

The MassTransit Mediator implementation is more powerful than MediatR implementation, but also more complicate to use. Unit Testing a MassTransit Consumer is not a nice experience.

In this article I will propose some techniques to simplify the MassTransit Consumer and to make them look as straight forward as a MediatR handler.

Case study

We will study a very common use case (the most common use case which I can think of):

Why mediator?

In a ASP.NET Web application. You don't need mediator

  • If you prefers to make controlers depends directly to the Application Codes instead of indirectly via the Mediator.
  • If you prefers to make a normal ASP.NET Web Application instead of a Mediator Application

Frankly it is not a Bad choice, no need to use a Mediator framework or make a Mediator Application just because everyone did.. Though, There are benefits in making a Mediator Application:

  • Event sourcing (Messages broadcast), CQS pattern..
  • Decouple the Controler (presentation) from Application codes, so that you could swap the presentation technology. For eg, if you make a "MassTransit" application, then you can swap the presentation layer to Mediator or RabbitMQ, or Grpc.. => you are not to be sticked with or limited by ASP.NET presentation => but rather sticked with and limited by your mediator framework!
@gpproton
gpproton / Segment.xaml
Last active May 22, 2024 10:57
A basic dotnet MAUI sample segment control example using BindableLayout
<!-- Working code -->
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XClaim.Mobile.Views.Segment"
x:Name="this">
<Border Padding="3" StrokeThickness="0" BackgroundColor="{DynamicResource Tertiary}">
<Border.StrokeShape>
<RoundRectangle>
<RoundRectangle.CornerRadius>
@gpproton
gpproton / importing.module.ts
Created August 13, 2022 00:49 — forked from evolkmann/importing.module.ts
Create Nest.js modules with custom config
import { Module } from '@nestjs/common';
import { MyLibModule } from './my-lib.module';
@Module({
imports: [
MyLibModule.register({ name: 'Enzo' }),
]
})
export class ImportingModule {}
@gpproton
gpproton / android-backup-apk-and-datas.md
Created April 15, 2022 13:50 — forked from AnatomicJC/android-backup-apk-and-datas.md
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

Fetch application APK

@gpproton
gpproton / github_desktop_ubuntu.sh
Created January 15, 2022 03:52 — forked from berkorbay/github_desktop_ubuntu.md
To install Github Desktop for Ubuntu
## Follow this link for further updates to Github Desktop for Ubuntu https://github.com/shiftkey/desktop/releases/latest
# UPDATE (2021-10-18): Thanks to Amin Yahyaabadi's message, the updated code is as follows
sudo wget https://github.com/shiftkey/desktop/releases/download/release-2.9.3-linux3/GitHubDesktop-linux-2.9.3-linux3.deb
### Uncomment below line if you have not installed gdebi-core before
# sudo apt-get install gdebi-core
sudo gdebi GitHubDesktop-linux-2.9.3-linux3.deb
# UPDATE (2021-03-05): Thanks to PaoloRanzi81's comment, the updated code is as follows https://gist.github.com/PaoloRanzi81
sudo sed -i 's/3/2/' /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
sudo apt install dkms build-essential make
git clone https://github.com/lwfinger/rtw88 && cd rtw88 && make clean && sudo dkms add . && sudo dkms install rtlwifi-new/0.6
//verificar se o "Power Management:off" caso estiver "Power Management:on" deslique e ligue o note
iwconfig

It's true that swapoff -a is a silver bullet in most cases, however, certain k8s setups may really require swap. For instance, I've got a very small and cheap VM with just 1GB RAM, which I use for a personal GitLab Runner that rarely handles short CI/CD tasks. If I increase the size of the machine, I'll be paying more for a resource that's 99% idle. If I disable swap, npm install and other scripts inside the buid pods may hang because they require quite a lot of memory, although for short periods of time. Thus, a single-node kubeadm cluster with gitlab runner chart and swap is what suits me best.

Here is how I could get my mini-cluster up and running:

kubeadm reset 

## ↓ see explanation below
sed -i '9s/^/Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"\n/' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
@gpproton
gpproton / filter.d_nginx-auth.conf
Created October 27, 2020 11:32 — forked from dunguyenn/filter.d_nginx-auth.conf
Fail2ban Config with Nginx and SSH
#
# Auth filter /etc/fail2ban/filter.d/nginx-auth.conf:
#
# Blocks IPs that makes too much accesses to the server
#
[Definition]
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"
ignoreregex =
@gpproton
gpproton / macosx-install-php-oracle-oci8-pdo_oci.md
Created September 12, 2020 18:22 — forked from krisanalfa/macosx-install-php-oracle-oci8-pdo_oci.md
Install OCI8 and / or PDO_OCI on OSX via Brew

Installation

This procedure is tested on Mac OS X 10.10.5 with Developpers tools installed (xCode).

PHP 5.6 installed with Homebrew.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):