Skip to content

Instantly share code, notes, and snippets.

View ZacharyPatten's full-sized avatar
👊
It's Morphin' Time

ZacharyPatten

👊
It's Morphin' Time
  • Kansas, United States
  • 06:08 (UTC -05:00)
View GitHub Profile
@SavageCore
SavageCore / 1-readme.md
Last active June 25, 2024 18:31 — forked from cdleveille/Install⁄Update Xone
Install or update xone driver for Steam Deck (desktop shortcut and bash script)

Enjoying this script? Consider buying me a beer/coffee!

ko-fi

First time setting up your Deck? You may enjoy my setup guide. It'll get you started on Emulation.

Improvements

Main changes at initial release versus cdleveille's original script:

  • Added zenity for a basic "GUI"
@ZacharyPatten
ZacharyPatten / readme.md
Last active February 3, 2023 15:58
GitHub Repository Checklist (C#)

GitHub Repository Checklist (C#)

Have a repository on GitHub? Planning on making a repository on GitHub? This checklist is intended to introduce you to various features that may help you make the most of your GitHub repository with specific recommendations for C# repositories.

Checklist

These are only suggestions.
They may not be appropriate for all repositories.
They are in no particular order.
Click each item to expand for more information.

@ZacharyPatten
ZacharyPatten / RandomWithExclusions.md
Created January 31, 2021 05:54
Random Generation (with efficient exclusions)

Note: code examples are in C#, but the theory should be applicable to most programing languages

"How do I generate random numbers except for certain values?" - This is a relatively common question that I aim to answer with this post. I wrote some extension methods for the topic that look like this:

Random random = new();

int[] randomNumbers = random.Next(
    count: 5,
 minValue: 0,
@ZacharyPatten
ZacharyPatten / ValueAttribute.md
Last active September 21, 2020 01:35
Valuue-Based Attributes in C#

Value-Based Attributes in C#

This code is a snippet from the https://github.com/ZacharyPatten/Towel project. Please check out the project if you want to see more code like it. :)

Attributes in C# are great. They let you add metadata onto members of your code that can be dynamically looked up at runtime. However, they are also a bit of a pain to deal with. You generally have to make your own class that inherits System.Attribute and add a decent bit of boiler plate code to look up your attribute with reflection. Here is an example of making your own attribute:

@ZacharyPatten
ZacharyPatten / VisualStudioSettings.md
Last active August 25, 2023 17:03
Just a reference of Visual Studio settings I use...

These are some notes about settings I like to use when I code in Visual Studio. They are completely optional.

  • Automatic brace completion = false
  • Dark Theme Tools -> Options -> Environment -> General
  • Disable Semicolon Bullshit Tools -> Options -> Text Editor -> C# -> IntelliSense
    • Automatically complete statement on semicolon = false
  • Control Click Tools -> Options -> Text Editor -> General
    • Enable mouse click to perform Go to Definition = false
  • Shift Key Overrides Tools -> Options -> Environment -> Keyboard
@AdmiralSnyder
AdmiralSnyder / TypeConstraining.cs
Last active August 4, 2020 14:22
a way to have a dictionary to a subset of types, for mapping classes to tags, for example
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp1
{
class TypeBase<TInterface>
{
public virtual Type TheInnerType { get; }
}
@ZacharyPatten
ZacharyPatten / Omnitree.md
Last active September 29, 2022 11:25
[July 8, 2014] Blog Post discussing a generic N-D SPT data structure

Omnitree

Date: July 8, 2014

Introduction

In this article, I would like to introduce and explain a data structure I have written in C#. This structure has the ability to store items sorted along "N" dimensions. It is similar in concept to a k-d tree (see Wikipedia), but it is NOT implemented as a binary tree. It branches relative to the number of dimensions its items are being sorted upon.

I developed the structure entirely on my own accord, and since I could not find another implementation like it, I am taking the liberty in giving it a name. I have called the structure an "Omni-Tree".

Background

@ZacharyPatten
ZacharyPatten / Accessing C#|VB|F# XML Code Documentation via Reflection.md
Last active May 15, 2024 03:36
[April 24, 2019] A blog post about accessing XML documentation via reflection in dotnet code

Accessing C#|VB|F# XML Code Documentation via Reflection

Date: April 24, 2019

In this post I will demonstrate how you can easily load C#|VB|F# XML code documentation and access it via reflection (using extension methods).

Note: The method described in this post only works if you are able to get the “.xml” file generated by Visual Studio when the code is built.

Author Edit (2020.7.27): The latest source code for this topics is included in the https://github.com/ZacharyPatten/Towel repository.

Why would you want to do this?

@ZacharyPatten
ZacharyPatten / C# Generic Math.md
Last active January 12, 2021 14:14
[May 12, 2015] A blog post discussing generic mathematics in C#

C# Generic Math

Date: May 12, 2015

Introduction

I wanted to share a new pattern I developed for perform generic mathematics in C# using runtime compilation.

Over the years I've been coding I have seen several versions of generic math in C#, but none of them have been particularly good. In this section I would like to step through some examples I have seen, and explain why they do not make good patterns for generic math.

I developed this pattern to use as part of my Seven Framework project. Please check out the project here if you are interested: https://github.com/ZacharyPatten/SevenFramework

@ZacharyPatten
ZacharyPatten / MultiStringReplace.md
Last active August 25, 2020 21:41
An extension method for multiple string replacements in a single call.

Multiple String Replacement Extension Method

This code is an example of an extension method that performs multiple string replacements in one method.

This code is included in the Towel Project. Please check it out if you want to see more code like it. :)

using System;
using System.Linq;
using Towel;