Skip to content

Instantly share code, notes, and snippets.

View dweedul's full-sized avatar

Dewayne Bagley dweedul

  • Lognormal Solutions, Inc
View GitHub Profile
@dweedul
dweedul / PronounSystem.cs
Created January 18, 2024 06:22 — forked from celechii/PronounSystem.cs
Pronoun System to be used for keeping track of character's pronouns and determining when and how to use them :)
/*
MIT License
Copyright (c) 2021 Noé Charron
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@dweedul
dweedul / modernizing-csharp9.md
Created November 9, 2020 23:18 — forked from richlander/modernizing-csharp9.md
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";
@dweedul
dweedul / CapsUnlocked.ahk
Created September 6, 2018 03:52 — forked from kshenoy/CapsUnlocked.ahk
Use CapsLock as Control/Escape in Windows
; This is a complete solution to map the CapsLock key to Control and Escape without losing the ability to toggle CapsLock
; We use two tools here - any remapping software to map CapsLock to LControl and AutoHotkey to execute the following script
; This has been tested with MapKeyboard (by Inchwest)
; This will allow you to
; * Use CapsLock as Escape if it's the only key that is pressed and released within 300ms (this can be changed below)
; * Use CapsLock as LControl when used in conjunction with some other key or if it's held longer than 300ms
; * Toggle CapsLock by pressing LControl/CapsLock + RControl
~*LControl::
@dweedul
dweedul / capslock_remap_alt.ahk
Created September 6, 2018 03:52 — forked from Danik/capslock_remap_alt.ahk
Autohotkey Capslock Remapping Script. Makes Capslock function as a modifier key to get cursor keys etc. on the left side of the keyboard, so you never have to move your hand to the right.
; Autohotkey Capslock Remapping Script
; Danik
; More info at http://danikgames.com/blog/?p=714
; danikgames.com
;
; Functionality:
; - Deactivates capslock for normal (accidental) use.
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
; - Access the following functions when pressing Capslock:
; Cursor keys - J, K, L, I
@dweedul
dweedul / latency.txt
Created May 3, 2018 14:52 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@dweedul
dweedul / CreateGUID.vb
Created March 15, 2017 02:23 — forked from danwagnerco/CreateGUID.vb
This function returns a GUID (globally unique identifier) primarily for use in VBA scripts
Option Explicit
Public Function CreateGUID(Optional IncludeHyphens As Boolean = True, _
Optional IncludeBraces As Boolean = False) _
As String
Dim obj As Object
Dim strGUID As String
'Late-bind obj as a TypeLib -- a rare time when late-binding
'is actually a must!
give @p written_book 1 0 {title:"Weather Magic",author:"dweedul",pages:[
"{text:'Weather\n\n',extra:[
{text:'Summon the sun\n',color:dark_aqua,clickEvent:{action:run_command,value:'/time set day'}},
{text:'Summon the moon\n',color:dark_aqua,clickEvent:{action:run_command,value:'/time set night'}},
{text:'Clear the sky\n',color:dark_aqua,clickEvent:{action:run_command,value:'/weather clear 1000000'}},
{text:'Summon Rain\n',color:dark_aqua,clickEvent:{action:run_command,value:'/weather rain 1000000'}},
{text:'Summon Thunder Clouds',color:dark_aqua,clickEvent:{action:run_command,value:'/weather rain 1000000'}},
{text:'Summon TACOS!',color:dark_aqua,clickEvent:{action:run_command,value:'/say raining tacos'}}]}"
]}
@dweedul
dweedul / demo-output-GetPropertyName.linqpad.cs
Last active August 29, 2015 14:18 — forked from zaus/demo-output-GetPropertyName.linqpad.cs
From StackOverflow discussion http://stackoverflow.com/questions/671968/retrieving-property-name-from-lambda-expression/17220748#17220748 -- demonstrating the behavior of various solutions via LinqPad to answer questions in the comments. Usage: LinqPad as "C# Program".
void Main()
{
// from comment discussion http://stackoverflow.com/questions/671968/retrieving-property-name-from-lambda-expression/17220748#17220748
Expression<Func<O, int>> exprId = o => o.Id;
Expression<Func<O, string>> exprName = o => o.Name;
Expression<Func<O, int[]>> exprItems = o => o.Items;
Expression<Func<O, int>> exprItemsLength = o => o.Items.Length;
Expression<Func<O, Subclass>> exprChild = o => o.Child;
Expression<Func<O, string>> exprChildName = o => o.Child.Name;
@dweedul
dweedul / gist:1512862
Created December 23, 2011 02:35
Dumping ground for dev until my thing is done