This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static T CycleEnum<T>(T type, int direction) where T : Enum | |
| { | |
| var values = (T[])Enum.GetValues(typeof(T)); | |
| var index = Array.IndexOf(values, type); | |
| var newIndex = Math.Clamp(index + direction, 0, values.Length - 1); | |
| return values[newIndex]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.ComponentModel; | |
| using System.Windows.Interop; | |
| using System.Windows.Input; | |
| using System.Runtime.InteropServices; | |
| using System.IO; | |
| using Windows.Win32.Foundation; | |
| using Windows.Win32.UI.WindowsAndMessaging; | |
| using Windows.Win32; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define MIN(A, B) ((A) < (B) ? (A) : (B)) | |
| #define MAX(A, B) ((A) > (B) ? (A) : (B)) | |
| #define CLAMP(N, LO, HI) (MIN(MAX((LO), (N)), (HI))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static byte LOBYTE(ushort a) => | |
| (byte)(a & 0xFF); | |
| public static byte HIBYTE(ushort a) => | |
| (byte)((a >> 8) & 0xFF); | |
| public static ushort HIWORD(uint a) => | |
| (ushort)((a >> 16) & 0xFFFF); | |
| public static ushort LOWORD(uint a) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def calc_check_digit(digits): | |
| digits = [int(i) for i in str(digits)][:-1] | |
| odd_pos_list = digits[0::2] # 1st, 3rd, 5th, etc | |
| even_pos_list = digits[1::2] # 2nd, 4th, 6th, etc | |
| n = (sum(odd_pos_list) * 3) + sum(even_pos_list) | |
| rmndr = n % 10 | |
| return (10 - rmndr) if rmndr > 0 else 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Add-Type -AssemblyName System.Windows.Forms | |
| $Win32_ShowWindow = @' | |
| [DllImport("user32.dll")] | |
| public static extern bool ShowWindow(int handle, int nCmdShow); | |
| '@ | |
| $User32 = Add-Type -MemberDefinition $Win32_ShowWindow ` | |
| -Name 'User32' -Namespace 'Win32' -PassThru |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal const uint FILE_ATTRIBUTE_NORMAL = 0x80; | |
| [Flags] | |
| internal enum SHGetFileInfoFlags | |
| { | |
| SHGFI_LARGEICON = 0x0, | |
| SHGFI_SMALLICON = 0x1, | |
| SHGFI_OPENICON = 0x2, | |
| SHGFI_SHELLICONSIZE = 0x4, | |
| SHGFI_PIDL = 0x8, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal enum WindowCompositionAttribute | |
| { | |
| WCA_UNDEFINED = 0, | |
| WCA_NCRENDERING_ENABLED = 1, | |
| WCA_NCRENDERING_POLICY = 2, | |
| WCA_TRANSITIONS_FORCEDISABLED = 3, | |
| WCA_ALLOW_NCPAINT = 4, | |
| WCA_CAPTION_BUTTON_BOUNDS = 5, | |
| WCA_NONCLIENT_RTL_LAYOUT = 6, | |
| WCA_FORCE_ICONIC_REPRESENTATION = 7, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| rem Run this script as administrator | |
| rem You may need to restart your computer to take effect | |
| set hKey=HKLM | |
| for /f "tokens=2 delims==." %%a in ('wmic os get version /value') do ( | |
| if %%a neq 10 set hKey=HKCU | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Translates an HTML-format color value to a GDI+ | |
| /// <see cref="System.Drawing.Color"/> structure. | |
| /// </summary> | |
| /// | |
| /// <param name="htmlVal"> | |
| /// A 3 or 6 digit hexadecimal value to translate. Do not include the | |
| /// leading "#" sign. | |
| /// </param> | |
| /// |
NewerOlder