Skip to content

Instantly share code, notes, and snippets.

View pjmagee's full-sized avatar
🤨

Patrick Magee pjmagee

🤨
View GitHub Profile
@pjmagee
pjmagee / hero-graph-data.cs
Last active July 31, 2021 15:49
heroes-nodes-edges-tags
using dwg = System.Drawing;
using Microsoft.Msagl.Drawing;
public class JsonNode
{
[JsonPropertyName("id")]
public string Id { get; set; }
[JsonPropertyName("label")]
public string Label { get; set; }
krypto_nat
faith
alice_marrs
amouranth
gloriamatvien
stream_sniperka
pinkfloweremoji
loreliamia
firedancer
lina_asmr
@pjmagee
pjmagee / streamers.json
Last active April 21, 2021 00:17
The Hopeless on Twitch
[
"krypto_nat",
"faith",
"alice_marrs",
"amouranth",
"gloriamatvien",
"stream_sniperka",
"pinkfloweremoji",
"loreliamia",
"firedancer",
@pjmagee
pjmagee / tag-generator.cs
Created March 21, 2021 16:15
tag-generator-for-vott-machine-learning
void Main()
{
using(var data = Heroes.Icons.DataDocument.HeroDataDocument.Parse(@"C:\Users\patri\Downloads\heroes-data-2.53.2.84249_all.tar\heroes-data-2.53.2.84249_all\2.53.2.84249\data\herodata_84249_localized.json"))
{
Random random = new Random();
var result = data.GetAttributeIds
.Select(attributeId => data.GetHeroByAttributeId(attributeId, false, false, false, true))
.SelectMany(hero => hero.HeroUnits.Select(hu => hu.Id).Concat(new[] { hero.Id }))
@pjmagee
pjmagee / find-hero.cs
Created February 16, 2021 21:16
Terrible image detection spike
async Task Main()
{
MagickImageFactory imageFactory = new MagickImageFactory();
var heroIcons = Directory.GetFiles(@"C:\Users\patri\OneDrive\Pictures\SaltySadism\hero-icons").Select(x => new { Hero = x.Split("storm_ui_minimapicon_")[1], Icon = imageFactory.Create(new FileInfo(x)) }).Where(x => x.Hero.Contains("kel")).ToList();
// heroIcons.ForEach((heroIcons) => heroIcons.Icon.Grayscale());
await Task.Run(() =>
{
public IEnumerable<Focus> GetFocusPlayers(TimeSpan now, Replay replay)
{
if (replay == null)
throw new ArgumentNullException(nameof(replay));
foreach (var unit in replay.Units.Where(unit => gameData.GetUnitGroup(unit.Name) == Unit.UnitGroup.MapObjective && gameData.VehicleUnits.Contains(unit.Name)))
{
var startTime = unit.Positions.Select(p => p.TimeSpan).Min();
var endTime = unit.Positions.Select(p => p.TimeSpan).Max();
@pjmagee
pjmagee / Reproduce.cs
Last active November 23, 2020 22:05
Reproduce System.ObjectDisposedException: 'Cannot access a disposed object. ObjectDisposed_ObjectName_Name'
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Windows.Graphics.Imaging;
public class SvgService
{
private readonly Dictionary<string, MarkupString> svgs = new Dictionary<string, MarkupString>();
private readonly MarkupString Empty = new MarkupString();
public MarkupString GetSvg(EcosystemKind kind) => kind switch
{
EcosystemKind.Docker => svgs["docker"],
EcosystemKind.Gradle => svgs["gradle"],
@pjmagee
pjmagee / Example.cs
Last active January 16, 2020 19:46
Command Line Parser Example Setup
using System;
using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Invocation;
using System.CommandLine.Rendering;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using HeroesReplay.Spectator;
using Microsoft.Extensions.Configuration;
@pjmagee
pjmagee / Entry.cs
Last active January 15, 2020 01:33
Example of me trying to use System.CommandLine
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Invocation;
using System.IO;
using System.Linq;