Skip to content

Instantly share code, notes, and snippets.

View UweKeim's full-sized avatar
😊
www.uwe.co

Uwe Keim UweKeim

😊
www.uwe.co
View GitHub Profile
@UweKeim
UweKeim / Check whether Outlook is installed via C#
Created May 30, 2013 15:07
Checks whether Microsoft Outlook is installed on a Windows system.
private bool IsOutlookInstalled()
{
Type requestType = Type.GetTypeFromProgID("Outlook.Application", false);
if (requestType == null)
{
RegistryKey key = null;
try
{
key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Office", false);
if (key != null)
@UweKeim
UweKeim / Texturizer.cs
Created September 25, 2017 13:35
Small, incomplete "port" of WordPress "wptexturize" function to .NET/C#
namespace ZetaProducer.RuntimeBusinessLogic.Rendering.Helper
{
using AngleSharp.Dom;
using AngleSharp.Parser.Html;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
public static class Texturizer
{
@UweKeim
UweKeim / DayOfCentury.cs
Last active November 14, 2017 06:53
Calculate DayOfCentury for C# DateTime, similar to DayOfYear
/// <description>
/// Calculates the total number of days passed sind first of January 2000
/// until a given Date.
/// </description>
public static long DayOfCentury(DateTime dt)
{
var span = dt.Date - new DateTime(2000, 1, 1);
return (long)span.TotalDays;
}
@UweKeim
UweKeim / wsdl.cs
Created January 15, 2019 11:10
wsdl.cs für cs-script
//css_import credentials;
using System;
using System.Net;
using System.Reflection;
using System.Diagnostics;
using System.Windows.Forms;
using System.Text;
using System.IO;
using CSScriptLibrary;
using csscript;
@UweKeim
UweKeim / program.cs
Last active August 7, 2019 07:04
Convert Oracle "RR" date formats to SQL Server "YYYY" formats
namespace OracleRRConverter
{
// Takes an Oracle-generated SQL script file and converts something like
// to_date('02.10.18','DD.MM.RR') to something like CONVERT(DATETIME,'02.10.2018',126).
// https://dba.stackexchange.com/q/244722/42
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@UweKeim
UweKeim / program.cs
Last active August 7, 2019 10:11
A simple .NET version of SQLCMD for executing an SQL Script against Microsoft SQL Server
namespace uksqlcmd
{
using System;
using System.Data.SqlClient;
using System.IO;
using System.Text;
internal static class Program
{
private static int Main(string[] args)
@UweKeim
UweKeim / QuickLogger.cs
Last active September 5, 2019 16:09
The shortest possible file logging class.
namespace Helper
{
using System;
using System.IO;
using System.Reflection;
/// <summary>
/// The shortest possible logger.
/// </summary>
public static class QuickLogger
@UweKeim
UweKeim / ColorConverting.cs
Last active January 28, 2024 21:27
HSL color, HSB color and RGB color types, as well as conversion methods between them in C# and .NET
namespace ZetaColorEditor.Colors
{
using System;
using System.Drawing;
/// <summary>
/// Provides color conversion functionality.
/// </summary>
/// <remarks>
/// http://en.wikipedia.org/wiki/HSV_color_space
@UweKeim
UweKeim / FileSize.cs
Created October 27, 2020 07:45
Automatically formatting an integer for human-readable file size
namespace Extensions
{
using System;
using System.Globalization;
using System.Threading;
public static class FileSizeExtensions
{
public static string FormatFileSize(
this long fileSize,
@UweKeim
UweKeim / BlazorTimer.cs
Last active January 28, 2024 21:30
Timer in Blazor 3.1
namespace ZetaHelpdesk.MainBlazor.Code.Components
{
using System;
using System.Timers;
// https://wellsb.com/csharp/aspnet/blazor-timer-navigate-programmatically/
public sealed class BlazorTimer
{
private Timer _timer;