Skip to content

Instantly share code, notes, and snippets.

View dylanbeattie's full-sized avatar

Dylan Beattie dylanbeattie

View GitHub Profile
DECLARE @places TABLE (name nvarchar(max));
insert into @places(name) values('Aarhus');
insert into @places(name) values('Berlin');
insert into @places(name) values('Zurich');
insert into @places(name) values('Aachen');
select name from @places order by name COLLATE Latin1_General_CI_AI
select name from @places order by name COLLATE Danish_Norwegian_CI_AI
select name from @places order by name COLLATE Finnish_Swedish_CI_AI
@dylanbeattie
dylanbeattie / ObjectExtensions.cs
Created January 14, 2021 01:41
ObjectExtensions.ToDynamic
public static class ObjectExtensions {
public static dynamic ToDynamic(this object value) {
IDictionary<string, object> expando = new ExpandoObject();
var properties = TypeDescriptor.GetProperties(value.GetType());
foreach (PropertyDescriptor property in properties) {
expando.Add(property.Name, property.GetValue(value));
}
return (ExpandoObject)expando;
}
}
@dylanbeattie
dylanbeattie / whisper.rock
Created March 2, 2021 21:52
Rockstar: Whisper the Future
Forever takes a lifetime.
The sunset is silence (it seems)
Until a lifetime is nothing,
Roll a lifetime into your dreams,
Cast your dreams into the night,
Let the sunset be with the night.
Give back the sunset
Give back the night
@dylanbeattie
dylanbeattie / ObjectToDynamic.cs
Last active November 6, 2021 11:20
An extension method on Object in C#, that converts statically-typed objects to dynamic objects with the same structure.
public static class ObjectExtensions {
public static dynamic ToDynamic(this object value) {
IDictionary<string, object> expando = new ExpandoObject();
var properties = TypeDescriptor.GetProperties(value.GetType());
foreach (PropertyDescriptor property in properties) {
expando.Add(property.Name, property.GetValue(value));
}
return (ExpandoObject)expando;
}
}
using System;
using System.Text;
namespace DotNetSummitBy {
class Program {
static NormalizationForm[] forms = new[] {
NormalizationForm.FormC, NormalizationForm.FormD,
NormalizationForm.FormKC, NormalizationForm.FormKD
@dylanbeattie
dylanbeattie / while_e_coyote.cs
Created July 1, 2022 13:20
while() {} vs do {} while() loops using Roadrunner and Wile E. Coyote
abstract class Animal {
public int distanceFromEdge = 1;
protected bool edge => distanceFromEdge <= 0;
protected void run() {
distanceFromEdge--;
}
public abstract void go();
}