07 Mar 2025 #misc
Hollywood often glorifies Navy SEALs portraying them as indestructible and focused men.
Jocko Willink, the guy from American Sniper, and the guys from Lone Survivor are all portrayed of them self-disciplined tough men.
But that’s not always the case. And this isn’t a story of a self-disciplined man.
His name is Taylor Cavanaugh, an ex-SEAL.
After joining the Military, Taylor’s life was a disaster. Bad decision after bad decision kicked him out of the military and led him to escape to France to join the Foreign Legion.
He tells his full story here:
And here are my 3 favorite quotes from his story.
“If you feel like it’s the happiest you’ve ever been, be very careful”
Taylor’s breaking point was after graduating from his military training.
It was partying and living “la vida loca” that got Taylor into trouble. It was the feeling of making it.
My breaking point wasn’t when I was making minimum wage at my first job.
No! It was years later when I was making the most money I had made as a software engineer. It was when I had won a “reputation” and felt comfortable at work. That’s when I got into trouble. I burned out.
And if we aren’t careful enough in those happy moments, everything that goes up has to go down.
“You cannot get healthy in the same place that makes you sick”
Often we can’t afford moving to a new place.
That’s what Taylor did to change his life. He moved to France to join the Foreign Legion. A military unit that accepts foreigners and give them a new name and life, no questions asked.
But we can change our environment without leaving home by:
- cleaning our room,
- working out,
- making our bed,
- eating healthy food,
- ditching social media, and
- going to bed earlier.
It took me months to start getting out of that burnout episode. But, it all started with a 5-kg dumbbell and a YouTube video to work out before showing up to work and with the type of content I was consuming online.
Move to another place or create the right conditions around you to flourish.
“Anything you do starts with self development”
Nobody is coming to save you.
It was a little voice in my head when I hit rock bottom that helped me to get up. “If you don’t get up by yourself, nobody is going to do it for you.”
I had to believe it was possible. I started to read inspiring books and YouTube videos. I had to watch stories from other who overcame similar situations in their lives. All that to believe I could do it too.
Change has to start in your mind first.
Parting thought
After overcoming his messy life, now Taylor is a life coach.
Me? Well, I took almost a year off to continue taking care of my health. I adopted a simple habit: ditching my to-do list and doing something for my body, mind, and spirit every day. Every single day, without excuses.
And that last quote summarizes Taylor’s journey through recovery—and my journey too. It all starts in your mind with your beliefs. Because beliefs turn into actions, actions into habits, and habits into change.
06 Mar 2025 #csharp #asp.net
If you’re not careful, your Program.cs file can become a mess.
It can turn into a long class full of methods and conditionals for every dependency to configure. We focus on the rest of our code, but often forget about the Program.cs file.
We could try extension methods to keep our configurations clean and organized.
But, these days, while working with a client, I learned an alternative to extension methods for keeping our Program.cs file tidy. A coworker showed me this approach. He learned it from a past job.
Here’s how to do it:
1. Let’s create an ASP.NET Core project adding Hangfire
Let’s create a dummy ASP.NET Core app. And to make it a bit more “complicated,” let’s add a lite Hangfire with one recurring job.
Here’s our unorganized Program.cs file,
using Hangfire;
using Hangfire.Console;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddHangfire(configuration =>
{
configuration.UseInMemoryStorage();
configuration.UseConsole();
});
builder.Services.AddHangfireServer(options =>
{
options.SchedulePollingInterval = TimeSpan.FromSeconds(5);
options.WorkerCount = 1;
});
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute
{
Attempts = 1
});
var app = builder.Build();
app.MapControllers();
app.UseHangfireDashboard();
app.MapHangfireDashboard();
RecurringJob.AddOrUpdate<ProducerRecurringJob>(
ProducerRecurringJob.JobId,
x => x.DoSomethingAsync(),
"0/1 * * * *");
RecurringJob.TriggerJob(ProducerRecurringJob.JobId);
app.Run();
Nothing fancy. A bunch of AddSomething()
and UseSomething()
methods.
It’s already kind of a mess, right? Looks familiar?
2. Let’s register each dependency using a separate class
To make our app work, we must register controllers and Hangfire. Let’s do it in a new class called MyCoolAppUsingHangfire
,
using Hangfire;
using Hangfire.Console;
namespace OrganizingProgramDotCs;
public class MyCoolAppUsingHangfire : BaseWebApp
// ^^^^^
{
protected override void RegisterConfiguration(IWebHostEnvironment env, IConfiguration configuration)
// ^^^^^^
{
Register(new ControllersConfig()); // <--
Register(new HangfireConfig()); // <--
}
}
// One class to register controllers
class ControllersConfig : IConfigureServices, IConfigureApp
{
public void ConfigureApp(WebApplication app)
{
app.MapControllers();
}
public void ConfigureServices(IConfiguration configuration, IServiceCollection services)
{
services.AddControllers();
}
}
// Another class to register Hangfire
class HangfireConfig : IConfigureServices, IConfigureApp
{
public void ConfigureApp(WebApplication app)
{
app.UseHangfireDashboard();
app.MapHangfireDashboard();
RecurringJob.AddOrUpdate<ProducerRecurringJob>(
ProducerRecurringJob.JobId,
x => x.DoSomethingAsync(),
"0/1 * * * *");
RecurringJob.TriggerJob(ProducerRecurringJob.JobId);
}
public void ConfigureServices(IConfiguration configuration, IServiceCollection services)
{
services.AddHangfire(configuration =>
{
configuration.UseInMemoryStorage();
configuration.UseConsole();
});
services.AddHangfireServer(options =>
{
options.SchedulePollingInterval = TimeSpan.FromSeconds(5);
options.WorkerCount = 1;
});
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute
{
Attempts = 1
});
}
}
MyCoolAppUsingHangfire
has only one method: RegisterConfiguration()
.
Inside it, we register two classes: ControllersConfig
and HangfireConfig
. One “config” class per “artifact” to register.
Each config class implements IConfigureServices
and IConfigureApp
.
Inside each config class, we put what was scattered all over the Program.cs file.
3. Let’s look at BaseWebApp
Inside BaseWebApp
, the real magic happens,
namespace OrganizingProgramDotCs;
public abstract class BaseWebApp
{
private readonly List<IConfigure> _configurations = [];
protected abstract void RegisterConfiguration(IWebHostEnvironment env, IConfiguration configuration);
// ^^^^^
protected void Register(IConfigure configure)
{
_configurations.Add(configure);
}
public async Task RunAppAsync(params string[] args)
// ^^^^^
{
var builder = WebApplication.CreateBuilder(args);
RegisterConfiguration(builder.Environment, builder.Configuration);
foreach (var configuration in _configurations.OfType<IConfigureServices>())
{
configuration.ConfigureServices(builder.Configuration, builder.Services);
}
var app = builder.Build();
foreach (var configuration in _configurations.OfType<IConfigureApp>())
{
configuration.ConfigureApp(app);
}
await app.RunAsync();
}
}
public interface IConfigure;
public interface IConfigureApp : IConfigure
{
void ConfigureApp(WebApplication webApplication);
}
public interface IConfigureServices : IConfigure
{
void ConfigureServices(IConfiguration configuration, IServiceCollection services);
}
RunAppAsync()
looks almost like the content of a normal Program.cs.
But, it reads the services and configurations to register from a list, _configurations
. We populate that list inside MyCoolAppUsingHangfire
using the method Register()
.
After that change, our Program.cs file has only a few lines of code
And lo and behold,
using OrganizingProgramDotCs;
var myCoolApp = new MyCoolAppUsingHangfire();
await myCoolApp.RunAppAsync(args);
With this approach, we move every configuration artifact to separate classes, keeping the Program.cs clean and compact. Ours now has only three lines of code.
We could also use this approach to handle the Startup class when migrating old ASP.NET Core projects.
Et voilà!
05 Mar 2025 #writing
The biggest mistake all new writers make is trying to sound like a “writer.”
That’s because we’re more used to reading fiction. And we try to do the same. But we end up writing long sentences and using complicated words.
Instead of pretending to be a writer, write for a single person in mind. That’s what I do.
But these days, I’ve found another technique to bring out your inner and real voice out when writing.
It comes from Henrik Karlsson from Escaping Flatland. He wrote in Advice for a friend who wants to start a blog:
#4. People tend to sound more like themselves in chat messages than in blog posts. So perhaps write in the chat, rapidly, to a friend.
When we’re texting friends or family, we don’t use jargon, fluff, or long sentences. We use the tone we use in a face-to-face conversation. A text box inside WhatsApp brings your inner voice out.
The next time you sit down to write, open a chat with yourself and let your true voice flow.
04 Mar 2025 #career
Over 10 years ago, I was fired from my first job.
I worked as an entry-level software engineer. I learned a lot from that job. I had to learn about coding and to make my way through the corporate world while growing my career.
Coding was the easy part. I had books, courses, and tutorials for that. But to survive the corporate world? Not so much. I had to figure it out on my own, with lots of trial and error, and yes, getting fired.
Here are 10 career lessons I wish someone had told me over 10 years ago:
1. Be ready to leave your job at any time
A 9-5 is never safe.
You could lose your job at any time for reasons you don’t control. Yesterday? A pandemic, global crisis, recession, and high interest rates. Today? DOGE and AI. Tomorrow? Who knows.
Be ready to leave:
- Grow your professional network
- Keep your “tell me about yourself muscles” in shape
- Have an emergency fund to cover a few months of expenses
When you’re let go, you’ll have options, not just panic.
2. An online presence is your best CV and portfolio
CVs are so last century.
I wasn’t hired directly for my first job. I was hired under a staffing company. My salary passed from another couple of hands before getting into my bank account. Of course, they took a good chunk of it.
One day, I had to visit the office of the staffing company for some paperwork. Next to the main door, there was a sign: “Put your CV here.” It was a trash bin.
Well, the same type of receptacle offices used as trash bins. I guess it saved them the struggle of piling up and throwing away all the CVs from desperate people looking for a minimum wage job. They were already on a trash bin. That day, I knew the system was broken.
Ditch your CV and appear professionally anywhere online.
3. Pay raises won’t change an unfulfilling job
Vacations and pay raises won’t help you when you don’t want to get out of bed.
If Monday mornings are torture, or even worse, if Sunday evenings are also torture, you don’t need vacations. You need a way out of your job.
Trust me, I got burned out. And not wanting to get out of bed was the first sign I failed to notice. I learned it the hard way.
Find something that excites you to get up every morning.
4. Hoping and praying is a bad career strategy
Make a career plan and always have an exit route for every job.
OK, a career plan sounds like a lot of commitment, especially when we’re just starting. Let’s say, set an intention for your career. Do you want money, connections, recognition, travel opportunities, etc.?
Otherwise, society will give you its plan: work hard, get 3% yearly raises, please your bosses, keep your head down, then wait to retire.
5. Soft skills are more important than hard skills
Being good at coding, writing, or designing will give you a job, but being good at communication will give you promotions.
Your success depends on how good you are at communicating, managing, and coordinating people. I’m paraphrasing a lesson I learned from How to Win Friends and Influence People.
Work on your soft skills.
6. Detach your sense of meaning from your work
Being a “Senior Software Engineer” was my only identity.
My career was probably the most important part of my life. It was what gave me money and a sense of meaning.
Until I was laid off.
Suddenly, after one Zoom meeting, the title and the things I did with it were gone. It shook my world. That was the only thing I thought I enjoyed.
I had to learn I’m not a title. I’m more than a job. “Senior Software Engineer” was just a label I decided to accept. I was more than that.
You’re more than a job title.
7. Don’t be the only one doing something at work
It feels so good when you’re the only one who knows or does something.
But that’s a trap. Being the “only one” makes you a hero. And a hero can’t get sick, go on vacation, or be promoted. A hero is always stuck.
Don’t turn yourself into a hero. Teach, automate, or document what you only know or do.
Don’t be a hero. Be a team player.
8. Find mentors but don’t ask anyone to be your mentor
I put “Senior” in my title after one or two years of working next to the right people at one of my first jobs.
They taught me in just one year way more than what I learned in the next 5 years after I left that job.
A good mentor or role model can help you advance in your career faster.
But don’t ask anyone to be your mentor. Don’t drop the M-word. “Would you be my mentor?” That’s a strong ask. It implies commitment from one side more than the other. Often for free.
Find ways to learn from your role models without the M-word. Find not-mentors.
9. Two years is the tipping point for growth at a company
I’ve stayed too long at stagnant jobs and I regretted it.
I lost years, thousands of dollars an let some of my skills get rusty.
At one place, I stayed too long waiting for my chance. I tried to convince upper management I deserved a promotion. All the seats were taken. Every one of my ideas for roles was rejected. “Somebody is kind of already doing that.”
If after two or three years of doing good work, you don’t get a raise or a promotion, don’t wait any longer. You’re at the wrong place. Move on.
You’re leaving money on the table by staying too long at the same place.
10. You will be remembered by your attitude, not by your work
The long hours, the impeccable report, the great presentation. Nobody will remember them.
They will remember your answers in meetings, your willingness to help others, your treatment of clients.
Being easy to work with will pay off in your career. That’s the easiest way to stand out at work and to leave a lasting impression.
Remember, as Robert Martin said in the Clean Coder, “your career is your responsibility, not your employer’s.”
03 Mar 2025 #career
He said, “You have put boundaries around your time.”
I was on a 1-on-1 with my boss’s boss and not-mentor at a past job. He was right. I had boundaries around my working hours. I always clocked out on time, and sometimes even earlier.
On more than one occasion, my team leader texted me or called me at 4:50 PM sharing details of a task or a bug. “Sorry, but I can’t finish that today. It’s 10 minutes to my end of day and that will take me at least a couple of hours,” I always said.
Eventually he stopped calling me 10 minutes before my end of day.
The hardest part of working from home
I’ve worked remotely for over 5 years. The hardest part? Setting boundaries between working and non-working hours.
When you’re at an office, some boundaries are clear. It’s lunch time. Or it’s 5:00 PM and you see a line of people clocking out. The day is over. No more meetings. No more calls.
But from home, the line between work and non-work is blurry.
From home, we’re a couple of steps away from “work” and we’re wearing pajamas or no pants like any other time of the day.
And, if we don’t pay attention, we’re replying to emails and taking calls after hours. Or even working on weekends. Or thinking about work all day long.
How to put boundaries between work and non-work
To start setting back those boundaries between work and non-work:
- Have separate work and personal spaces: Your work laptop is only for work stuff.
- Turn off all notifications after working hours: No Slack or Teams or email beeps or buzzes after 5:00 PM.
- Do something that signals the end of your working hours: Walk your dog, change clothes, or go to a different room.
- Uninstall work-related messaging apps from your phone: No Slack or Teams or work email on the phone.
If you’re working from a different time zone than your coworkers, you don’t have to reply after hours, not even to say it’s already past your working hours. Reply the next work day.
And if you’re the one texting, start your messages with a disclaimer, something like “When you’re back online tomorrow: blah, blah, blah” or schedule your messages. And, please don’t send “hello, how are you” messages. That’s how you get ignored at work.
Remember, working from home doesn’t mean being available 24/7.