jvandertil / blog Goto Github PK
View Code? Open in Web Editor NEWSource code for my blog
Home Page: https://www.jvandertil.nl
Source code for my blog
Home Page: https://www.jvandertil.nl
The most important bit of code would be the SqlServer fixture that is responsible for creating and deleting the database. It also provides a checkpoint so that the database can be reset to a known (a.k.a. empty) state.
public class SqlServerFixture : IAsyncLifetime
{
private readonly string _dbName;
private readonly string _connectionString;
private readonly Checkpoint _emptyDatabaseCheckpoint;
public SqlConnection Connection { get; private set; }
public SqlServerFixture()
{
_dbName = "db-" + Guid.NewGuid().ToString();
_connectionString = "Data Source=(localdb)\\MSSQLLocalDB; Integrated Security=True;";
_emptyDatabaseCheckpoint = new Checkpoint
{
// Reseed identity columns
WithReseed = true,
TablesToIgnore = new[]
{
// DbUp journal does not need cleaning
"SchemaVersions"
},
};
}
public async Task InitializeAsync()
{
Connection = new SqlConnection(_connectionString);
await Connection.OpenAsync();
await ExecuteDbCommandAsync($"CREATE DATABASE [{_dbName}]");
await ExecuteDbCommandAsync($"USE [{_dbName}]");
var builder = new SqlConnectionStringBuilder(_connectionString)
{
InitialCatalog = _dbName
};
var connectionString = builder.ToString();
var runner = new DbUp.SqlServerMigrationRunner(connectionString);
var result = runner.PerformUpgrade();
if (!result.Successful)
{
throw result.Error;
}
await _emptyDatabaseCheckpoint.Reset(Connection);
}
public async Task DisposeAsync()
{
await ExecuteDbCommandAsync($"EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'{_dbName}'");
await ExecuteDbCommandAsync("USE [master]");
await ExecuteDbCommandAsync($"ALTER DATABASE [{_dbName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE");
await ExecuteDbCommandAsync("USE [master]");
await ExecuteDbCommandAsync($"DROP DATABASE [{_dbName}]");
await Connection.DisposeAsync();
}
public Task ResetDatabaseAsync()
{
return _emptyDatabaseCheckpoint.Reset(Connection);
}
private async Task ExecuteDbCommandAsync(string commandText)
{
using var cmd = Connection.CreateCommand();
cmd.CommandText = commandText;
await cmd.ExecuteNonQueryAsync();
}
}
Rationale: Building .NET projects on Linux is faster in Azure Pipelines than building them on Windows agents.
Scripts are quite easy, so should be easy to implement this quick perf win.
On iOS 13.3.1 horizontal scrolling of code blocks does not work
Currently we store the 'darkmode' preference on the users computer, which is a functional 'cookie'.
This does not require user consent, but does require a cookie policy unfortunately.
Also CloudFlare adds the _cfduid cookie, which is a 'technical' cookie which does not require consent but also needs to be named in the cookie policy.
Link to CloudFlare cookie explanation: https://support.cloudflare.com/hc/en-us/articles/200170156-Understanding-the-Cloudflare-Cookies#12345682
Since this repository is as much a learning ground as it is an actual thing that's published. Let's try to move to GitHub actions from Azure Pipelines.
Since I put all the moving parts in scripts this should be easy... right?
As title, styling is not in place to make comments dark in dark mode.
Now that bootstrap has gone vanilla JS, it's time for us as well :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.