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 / 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 / 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 / convert-wildcards-to-regex.cs
Last active January 28, 2024 21:32
Convert wildcards to Regular Expressions.
private static string convertWildcardToRegex(string pattern)
{
// http://stackoverflow.com/a/6907849/107625
// http://www.codeproject.com/Articles/11556/Converting-Wildcards-to-Regexes
return "^" + Regex.Escape(pattern).
Replace("\\*", ".*").
Replace("\\?", ".") + "$";
}
@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 / ColorConverting.cs
Last active October 9, 2024 14:25
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 / 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 / ZetaFolderXCopy.cs
Last active January 28, 2024 21:32
XCOPY-like functionality to copy files and folders in C#, ideal for batch scripts
//css_nuget -force:3600 -ng:"-Source https://nuget.org/api/v2/" ZetaLongPaths
using ZetaLongPaths;
namespace Zeta
{
/*
===========================
Zeta XCOPY.