Software developer and indie game developer from Sweden. Been turning coffee into code since 2010.

As a musician I often want to play along to different songs on Spotify but since the song is always starting right away I always miss the first few seconds of the song. An auto play after X seconds feature has been requested a lot on the forums. …

What’s lazy loading?

Lazy loading means loading your object when needed.

Normally when we are fetching data from our database we want to make as few calls as possible. In the world of EntityFramework a request may look like this.

// Fetch one book and include the author
var bookWithAuthor = bookEntities
.Include(n => n.Author)

Retrieving a single object

var book = bookEntities.FirstOrDefault(n => n.ID == 1); 
// Returns null if not found
var book = bookEntities.First(n => n.ID == 1);
// Throws if not found
FROM [Books]
WHERE [ID] = 1
var book = bookEntities.SingleOrDefault(n => n.ID …

1. Don’t keep your money on exchange services or online wallets

Having your money online on means that your money exists on a wallet belonging to someone else. The company may be trustful but they have the private keys and can anytime steal your money. It’s not too uncommon that exchange services get hacked too.

Solution: Always keep your currencies in…

Once again we are really going to emphasize test driven development and maintainable applications here so we are going to go for a “Onion Architecture” where the Core/Hearth of our solution will base around Entities and not data access. This architecture leads emphasizes separation of concerns throughout the system, separation…

We will start by defining a generic method where T could be any class.

public void GenerateReport<T>(List<T> rows) where T : class

Now parse the properties of T, simply define what properties you want to include in the where linq clause. …

wkhtmltopdf is really great and free! The library is written in C.

If you are on C# then you need a wrapper in order to use the library.
I recommend Codaxy’s C# wrapper for this.


Install-Package Codaxy.WkHtmlToPdf

Then you can generate pdfs from html by this simple code:

byte[] pdfBytes = null;PdfConvert.ConvertHtmlToPdf(new PdfDocument
Html = html,
}, new PdfOutput
OutputCallback = (PdfDocument d2d, byte[] bytes) =>
pdfBytes = bytes;

Don’t forget to follow me on Twitter.





Kristoffer Karlsson

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store