Skip to content

Instantly share code, notes, and snippets.

View argentini's full-sized avatar

Michael Argentini argentini

View GitHub Profile
@argentini
argentini / dotnet-css-minifier.cs
Last active February 27, 2024 00:02
Pure dotnet (.NET) C# CSS Minifier - Minify CSS using compiled Regex
#region Compiled CSS Regex; Should be Singletons
public Regex SelectCssComments { get; } = new (@"\/\*.*?\*\/", RegexOptions.Compiled); // Select comment blocks
public Regex SelectCssLineBreaks { get; } = new (@"[\n\r]+\s*", RegexOptions.Compiled); // Select line breaks and subsequent space
// Ensure content property values use quotation marks
public Regex SelectCssContentValueWithApostrophes { get; } = new (@"content:\s*'([^']*)';", RegexOptions.Compiled); // Select content properties using apostrophes
public Regex SelectCssContentValueWithSpacePrefix { get; } = new ("""content:\s{1,}"([^\"]*)";""", RegexOptions.Compiled); Select content properties with space between the name and value
public Regex SelectCssEmptyContentValueWithSpacePrefix { get; } = new ("""content:\s*"";""", RegexOptions.Compiled); // Select empty content properties
@pbthorste
pbthorste / Dockerfile_mssql
Last active October 24, 2024 12:22
Docker image with msssql 2022 with full text search enabled
# Docker image with msssql 2022 with full text search enabled
# based on work in: https://github.com/Microsoft/mssql-docker
# Base OS layer: Latest Ubuntu LTS
FROM --platform=linux/amd64 ubuntu:focal
# Install prerequistes since it is needed to get repo config for SQL server
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -yq curl apt-transport-https gnupg && \
@mendhak
mendhak / gist:3369293
Created August 16, 2012 11:00
Extension method to get value from a field in a SQLDataReader
public static class DataRecordExtensions
{
public static T GetValue<T>(this IDataRecord reader, string columnName)
{
object columnValue = reader[columnName];
T returnValue = default(T);
if (!(columnValue is DBNull))
{
returnValue = (T)Convert.ChangeType(columnValue, typeof(T));
}