There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull
example requires it.
Consider adopting the new property pattern, wherever you use IsNullOrEmpty
.
string? hello = "hello world";
/* | |
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 |
There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull
example requires it.
Consider adopting the new property pattern, wherever you use IsNullOrEmpty
.
string? hello = "hello world";
; 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:: |
; 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 |
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 |
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'}}]}" | |
]} |
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; |