Skip to content

Instantly share code, notes, and snippets.

View pjmagee's full-sized avatar
🤨

Patrick Magee pjmagee

🤨
View GitHub Profile
@pjmagee
pjmagee / death_report.cs
Last active June 11, 2022 14:19
Detect dagger links and find related pages with empty death infobox
async Task Main()
{
var regex = new Regex(@"\[\[([^\]\]]+)\]\]\s?(†|†)", RegexOptions.Compiled);
var backup = new FileInfo(@"C:\Users\patri\Downloads\starwars_pages_current.xml");
var pagesWithDaggers = new List<Result>();
var outputs = new List<Output>();
var settings = new XmlReaderSettings()
{
@pjmagee
pjmagee / findLinksAndMissingLinks.cs
Last active June 9, 2022 19:01
starwars wiki infobox dates
const string WikiFragment = "/wiki/";
const string RelationshipsSection = "_Relationships_";
async Task Main()
{
Util.AutoScrollResults = true;
List<Loaded> allFiles = new DirectoryInfo(@"C:\Projects\github\pjmagee\starwars-data")
.EnumerateFiles("*.json", new EnumerationOptions { RecurseSubdirectories = true })
.AsParallel()
static char[] InvalidChars = Path.GetInvalidFileNameChars();
static JsonSerializerOptions Options = new JsonSerializerOptions { WriteIndented = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
static SemaphoreSlim slim = new SemaphoreSlim(1);
async Task Main()
{
await StarWarsFandomExtractor.ExtractPagesWithInfoboxes();
}
// 2 Pots (Hand pot and Sabacc pot)
// Players could designate a dealer or take turns as the dealer - No need, the Computer/Server will be the Dealer
// The object of sabacc was to have a final hand with a total as close to 23 or -23 as possible without going over.
// A hand with a total of 24 or higher was said to "bomb out" and lost the round - Visa versa -24??
// A perfect hand of 23 or −23 was called a Pure Sabacc, and it could only be beaten by a rare and unbeatable hand called an Idiot's Array, consisting of The Idiot, a 2 card of any suit, and a 3 card of any suit.
// DEALING:
// The dealer started by shuffling the deck before dealing one card to each player
// Repeat another rotation until each player had two cards facedown.
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "session",
"style": "diamond",
@pjmagee
pjmagee / gist:fe4313938355711dbb58fa27b3ca1482
Last active April 17, 2022 14:59
hero-tag-generator for 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 / gist:50c69ebcd54c4983b24d3755c109db5c
Created March 29, 2022 23:37
LostArk AFK PowerAutomate Desktop
Display.ShowMessageDialog.ShowMessageWithTimeout Message: $'''AFK Macro Starting in 10 seconds.''' Icon: Display.Icon.Information Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False Timeout: 3 ButtonPressed=> ButtonPressed
WAIT 10
LABEL START
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: $'''LOST ARK (64-bit, DX11)*''' Class: $'''EFLaunchUnrealUWindowsClient''' TextToSend: 8 DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT 300
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: $'''LOST ARK (64-bit, DX11)*''' Class: $'''EFLaunchUnrealUWindowsClient''' TextToSend: 9 DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT 300
GOTO START
@pjmagee
pjmagee / SWTOR GUI Settings Sync.cs
Last active October 13, 2021 21:32
SWTOR GUI Settings Sync
void Main()
{
SettingsManager.EnumerateSettings(SettingsManager.EnumerateCharacters()).Dump();
}
public class SettingsManager
{
private static readonly string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, System.Environment.SpecialFolderOption.None), "SWTOR", "swtor", "settings");
public static IEnumerable<Character> EnumerateCharacters()
@pjmagee
pjmagee / data-generator.cs
Last active August 2, 2021 19:09
Generates the JSON structure required for d3 from using exported JSON data provided by HeroesToolchest
/* Data generated for https://observablehq.com/@pjmagee/heroes-of-the-storm-hero-relationships */
public class Node
{
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("imports")]
public List<string> Imports { get; set; } = new ();
}