Blog

Gratis certificaat gebruiken voor https

Uncategorized
Als je voor een bedrijf een website maakt koopt je bedrijf een certificaat in bij een certificate authority. Maar als je voor je hobbyproject hetzelfde wil dan wil je je kosten minimaliseren. Dus als het even kan gebruik je dan een certificaat van bijvoorbeeld Let's Encrypt. Alleen.. Die verloopt na een x aantal dagen (90 voor Let's Encrypt, zie https://letsencrypt.org/docs/faq/#what-is-the-lifetime-for-let-s-encrypt-certificates-for-how-long-are-they-valid) De oplossing is om de WIN-ACME Client te gebruiken, en daarvoor een scheduled task aan te maken in de Windows Task Scheduler om te zorgen dat het certificaat op tijd wordt vernieuwd. Ga daarvoor naar win-acme.com en sla de download op op een makkelijk te vinden locatie. Ga daarheen met de command prompt en typ: wacs Doorloop de volgende stappen (zoals ik ze al heb gedaan): Dat is alles. Mijn…
Lees meer

Rebuild index performance: int vs bigint

Uncategorized
Some time ago I was working with a company that had a lot of data in multiple tables, using bigint as the primary key. At the time, it looked like a good idea to rebuild these indexes each day. Nowadays, I am not so partial to rebuilding indexes anymore: you can gain a lot just by updating statistics instead of doing a full rebuild. However, what I found was that when we were doing a rebuild of our tables using a bigint primary (clustered) key it would take a long time. Now, the people who came before me decided that using bigint was a good idea because there was going to be a lot of data in these tables, however, max int is 2,147,483,647. Two billion one hundred and forty…
Lees meer

EF Core: IEnumerable to separated list of string

C#, SQL Server
The problem In my database I have a column where I store comma separated strings representing a combination of options/features I need to use on the website. It would be nice to be able to access the comma separated items as an IEnumerable so I can use it to - for instance - populate a dropdown list. Some thoughts Of course, I could use entity framework core to get the string value from the database, and then split that string into a list, and use that in my page model. However then I don't know how many times I would need to do that in the future, when I might be building more and more functionality based on this same column. Also, I cannot think of a situation where my…
Lees meer

Using Dependency Injection and IOptions in Azure Functions

Azure, Backend Development, C#, Development
So, I created this Azure Function and because I have a lot of parameters that I would like to be able to use in dependency injection I did not want to go with the familiar way like this: var firstName = Environment.GetEnvironmentVariable("FirstName"); Instead I want to use the Options pattern as I would do when creating a "normal" appsettings file. However, Azure Function configurations only feature key-value pairs for configuration and do not support JSON configuration files. Luckily there is a way around this using a little peculiar syntax. Writing the code First, we create our options class: public class ParentOptions { public string FirstName { get; set; } public string LastName { get; set; } public ChildOptions ChildOptions { get; set; } } public class ChildOptions { public string…
Lees meer

Benchmarking .NET Performance

Uncategorized
Nerds do it better When we, nerds, are looking for the best solution to a programming problem we sometimes get distracted. We are asked to find a way to get from A to B and while we are finding our way we find out that there are often (always) multiple solutions to a problem. A lesser person would say: "Hey, if it brings me from A to B then it's alright!". Right? Well not us nerds. At least not always. For instance right now I am working on a pet project of mine where I want to receive data from a GPS unit that is sending positional and other data from my car to a receiver service I am currently programming. This service should receive the raw bytes from my…
Lees meer

Learning Web Development (5)

Niet gecategoriseerd
So now I dove a bit into the Gekko docs and it seems fairly simple to create a strategy. This is the thing that outputs the trading advice to Gekko. The tutorials I used are: https://www.youtube.com/watch?v=6-74ZhrG0BE&t=1456s and https://gekko.wizb.it/docs/strategies/creating_a_strategy.html My strategy looks like this (just outputting some trivial things like in the youtube demo): The JavaScript function from the strategy.. The output Gekko can make use of strategies using all kinds of algorithms, but I don't want that. I want to decide each day if I want to buy or sell on a specific input. For this I wrote a Web Api endpoint in C#. For my first test, like I showed you in the previous post, this just takes in an integer parameter and outputs a dummy object. I've changed…
Lees meer

Learning Web Development (4)

Niet gecategoriseerd
It has been a while since I was here but I decided to continue the series after being busy for a long time. Part of the solution entails calling a web api from javascript, so I decided to learn how that should be done. Because the TradingAdvice endpoint needs to be there in the future to return the trading advice I decided to get some practice with this. I took a look at what the gekko ticker stores from an incoming candle, and I found there's a Unix timestamp in there. That's an integer. So, even though I probably will not use that integer as a parameter for the api it is very convenient for testing. Saved candles from the bitcoin exchange I am using Let's create an endpoint with…
Lees meer

Learning Web Development (3)

Niet gecategoriseerd
Creating Entities Before I do anything else, I need to create the entity that gets saved to the database. I called this entity "Condition", but I think the word "Rule" is more appropriate since I need to store not only a condition but also the value that is used by the condition, and maybe some other data as well. Separate Functionality into Projects I like to organize different parts of software I write into different projects in Visual Studio: this way each project is responsible for its own set of tasks and I can reference these projects from new projects. For instance, I can create a website, a console application or a Windows Service and allow these to use the same existing set of core classes, datalayer, et cetera. Using…
Lees meer

Reinstall your development laptop, fast

Niet gecategoriseerd
Today was one of those days again. You know, one of these days when Visual Studio keeps freezing up on you and you decide to finally do something about it. After a few hours disabling extensions to no effect, and comparing with my other laptop where VS is working without issue I decided to do a fresh reinstall of my laptop. Windows, all programs, everything. Cleaning Windows Everything I need is on my secondary disk so I did a windows refresh: just type "reset" in Start and follow the breadcrumbs: Reset this PC Alternatively, you can download the Windows iso manually from your msdn benefits page. Next, we wait.. Waiting... Scripted installation After reinstalling my laptop a few times it became time to do it differently. I now use a…
Lees meer

Learning Web Development (2)

Niet gecategoriseerd
Requirements Of course, when starting a new project it could be a good idea to put some requirements down to assure your efforts are going to be more or less in the direction of where you would like to end up after your journey. Books have been written about this, as well as ISO standards. I will keep things very basic so you, the reader will not get bored and go looking for funny cat videos on youtube. Functional Requirements Most of the functional requirements have already been named in the previous post. I think these are fairly complete and will just copy them here: A websiteFor entering valuesAnd maybe later creating some reporting dashboardsA databaseFor storing the entered valuesAnd maybe later some resultsAnd maybe later doing something with authentication…
Lees meer