Skip to content

Instantly share code, notes, and snippets.

View wangyoutian's full-sized avatar
😠
Keep Coding

wyt@nilnul wangyoutian

😠
Keep Coding
View GitHub Profile
@karenpayneoregon
karenpayneoregon / DateTimeHelpers.cs
Created August 25, 2025 13:50
Date Time Helpers
public static class DateTimeHelpers
{
/// <summary>
/// Generates a list of dates representing the next week's dates starting from the upcoming Sunday.
/// </summary>
/// <returns>A list of <see cref="DateOnly"/> objects representing the dates of the next week.</returns>
public static List<DateOnly> NextWeeksDates()
{
var start = DateTime.Now;
var nextSunday = DateOnly.FromDateTime(start).Next(DayOfWeek.Sunday);
@karenpayneoregon
karenpayneoregon / Sample.sql
Last active March 29, 2025 08:24
Example to get column details from a SQL-Server database table
DECLARE @TableName AS NVARCHAR(MAX) = 'Birthdays'
SELECT
X.COLUMN_NAME AS ColumnName,
X.ORDINAL_POSITION AS Position,
X.TABLE_CATALOG AS Catalog,
X.TABLE_SCHEMA AS TableSchema,
X.COLUMN_DEFAULT AS ColumnDefault,
X.DATA_TYPE AS DataType,
CASE
WHEN KCU.COLUMN_NAME IS NOT NULL THEN CAST(1 AS BIT)
string firstLastName = "KarenPayne";
var separated = firstLastName.SplitByCase();
@karenpayneoregon
karenpayneoregon / Example.cs
Created April 4, 2024 13:45
Get DotNet version at runtime
public static Version FrameworkRuntimeVersion()
{
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var path = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
var index = Array.IndexOf(path, "Microsoft.NETCore.App");
return new Version((index > 0 && index < path.Length - 2 ? path[index + 1] : null)!);
}
interface IInterface
{
void DoSomething();
}
class Implementation : IInterface
{
public void DoSomething()
{
// This method can't return a Task,
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Frameworks;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Packaging.Signing;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Resolver;
using NuGet.Versioning;
@kazad
kazad / fourier.html
Created June 25, 2014 19:00
BetterExplained Fourier Example
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<script src="//ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
<!--
TODO: