Skip to content

Coding Practice

How to Create a Dev Container for Ruby Apps

Last week we looked at the reason why we should use dev containers to write code. This week we create a dev container to develop a Ruby application on a machine that has no Ruby installed.

Why would you do that? Tools like rbenv are a great help to manage your Ruby environments. However, getting the right Ruby interpreter is only part of the setup. You need all your Gems and 3rd party tools in the right version, or nothing goes. My machine has no Ruby installed and by the end of this post I will run my Ruby Gem

C:\>ruby

'ruby' is not recognized as an internal or external command, operable program or batch file.

How to Access the Clipboard History in Windows 10

If you need to copy multiple values from one document to another, you can go and copy & past every value on its own. That works, but there is a better and faster way. Windows 10 comes with a well-hidden clipboard history that you already have on your machine. With this feature you to copy multiple values and then past them to the target document in the order you need to – no 3rd party software required.

How to Test the Emails Send by MailKit in .Net 5?

In a .Net Full Framework application we could use the property SpecifiedPickupDirectory in our mailSettings and the emails got stored to disk instead of sending them to the recipient. That allowed us to check them manually or in our test code.

For .Net 5 you should no longer use System.Net.Mail.SmtpClient and instead use MailKit. However, testing is a lot harder then MailKit does not offer such a convenient way to dump your emails to disk. Let us explore what we can do to check that our applications send the right emails.

Sending Emails in .Net 5 With MailKit

SmtpClient from System.Net.Mail was the way to send emails in .Net 4.x. This old class worked for our use cases well enough to not bother finding an alternative. However, as the time progresses, email protocols improved while SmtpClient stayed the same. If you look at the .Net 5 documentation for SmtpClient, you find this important note from Microsoft:

Important We don't recommend that you use the SmtpClient class for new development because SmtpClient doesn't support many modern protocols. Use MailKit or other libraries instead. For more information, see SmtpClient shouldn't be used on GitHub.

Little Git Tricks: Clean-up Your Working Directory

If your code works on the Continuous Integration (CI) server but not on your local machine, you may have a problem in the files not tracked by Git. And since Git does not track them, there is no easy way to get rid of them - at least in most Git clients. In such cases, we can go to the command line and use the full feature set of Git to fix the problem.