Skip to content

Instantly share code, notes, and snippets.

View Zacbt519's full-sized avatar

Zach Beatty-Taylor Zacbt519

View GitHub Profile
@Zacbt519
Zacbt519 / falsehoods-programming-time-list.md
Created July 29, 2024 15:27 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
foreach (Control s in myMain.pnlPages.Controls.OfType<{{ControlName}}>())
{
if (s.Name == "{{ControlName}}")
{
myMain.pnlPages.Controls.Remove(s);
myMain.{{ControlName}} = null;
}
}
cd .. to C Drive
cd windows\microsoft.net
dir /w
cd Framework
cd v4.0.30319
In Command prompt, this is what the final command to encrypt should look like. The path is for the specific project. Do not include the web.config in the url
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -pef "connectionStrings" "C:\Users\ZacBe\Desktop\SecurityDemo\SecurityDemo" -prov "DataProtectionConfigurationProvider"
@Zacbt519
Zacbt519 / Extensions.cs
Last active September 7, 2021 12:38
Returns the description for a specific Enum.
public static class Extensions
{
public static string GetDescription(this Enum value)
{
Type type = value.GetType();
string name = Enum.GetName(type, value);
if (name != null)
{
FieldInfo field = type.GetField(name);
if (field != null)
@Zacbt519
Zacbt519 / Extensions.cs
Last active September 7, 2021 12:36
Thread safe method to randomly shuffle a List<T>
public static void Shuffle<T>(this IList<T> list){
int n = list.Count;
while (n > 1)
{
n--;
int k = ThreadSafeRandom.ThisThreadsRandom.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
@Zacbt519
Zacbt519 / ServerPing.cs
Created August 30, 2020 02:00 — forked from csh/ServerPing.cs
Server ping written in C#, complete with coloured console output.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Newtonsoft.Json;
#if DEBUG
using System.Diagnostics;