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
var number = 1; | |
new List<string> | |
{ | |
$"|{number}|", // |1| | |
$"|{number, -10}|", // |1 | | |
$"|{number, 10}|" // | 1| | |
}.ForEach(Console.WriteLine); |
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 class ComputerNetwork | |
{ | |
public static void Run() | |
{ | |
//var output = Network(new int[] { 0, 3, 4, 2, 6, 3 }, new int[] { 3, 1, 3, 3, 3, 5 }); | |
var output = Network(new int[] { 0, 4, 2, 2, 4 }, new int[] { 1, 3, 1, 3, 5 }); | |
//var output = Network(new int[] { 0, 4, 4, 2, 7, 6, 3 }, new int[] { 3, 5, 1, 3, 4, 3, 4 }); | |
Console.WriteLine($"output is : {output}"); | |
} |
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.Diagnostics; | |
var stopWatch = new Stopwatch(); | |
stopWatch.Start(); | |
//Tasks.Run(); | |
var ts = stopWatch.Elapsed; | |
// Format and display the TimeSpan value. |
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.Diagnostics; | |
List<int> numbers = new() { 1,2,3,4,3,5}; | |
if (ContainsDuplicates(numbers)) | |
{ | |
Console.WriteLine("Contains Duplicate? Yes"); | |
} | |
else | |
{ |
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
DECLARE @QueryString NVARCHAR(MAX) ; | |
SELECT @QueryString = COALESCE(@QueryString + ' UNION ALL ','') | |
+ 'SELECT ' | |
+ '''' + QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) | |
+ '.' + QUOTENAME(sOBJ.name) + '''' + ' AS [TableName] | |
, COUNT(*) AS [RowCount] FROM ' | |
+ QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) | |
+ '.' + QUOTENAME(sOBJ.name) + ' WITH (NOLOCK) ' | |
FROM sys.objects AS sOBJ |
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
blueprint: | |
name: Aqara Magic Cube | |
description: Control anything using Aqara Magic Cube. | |
domain: automation | |
input: | |
remote: | |
name: Magic Cube | |
description: Select the Aqara Magic Cube device | |
selector: | |
device: |
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 class ExceptionFilterUtility | |
{ | |
public static bool True(Action action) | |
{ | |
action(); | |
return true; | |
} | |
public static bool False(Action action) | |
{ |
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
[Test] | |
public void Test() | |
{ | |
var str = "{\"start\":123,\"rows\":213,\"query\":{\"$eq\":[\"template\",\"Catalogue Allocation\"]},\"parentQuery\":{\"4\":{\"$eq\":[\"recordid\",\"65570\"]}}}"; | |
//var m = Regex.Matches(str,"\"(?<key>[^\"]+)\"\\s*:\\s*(?:\"([^\"]+)\"|(?<value>\\d+)),?", RegexOptions.IgnoreCase); | |
//var startGroup = m.FirstOrDefault(x => x.Success && x.Value.Contains("\"start\"")); | |
//var rowsGroup = m.FirstOrDefault(x => x.Success && x.Value.Contains("\"rows\"")); | |
//if (startGroup != null && rowsGroup != null) |
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 class ActivatorExt | |
{ | |
private static ObjectActivator<T> GetActivator<T>(ConstructorInfo ctor) | |
{ | |
var paramsInfo = ctor.GetParameters(); | |
var param = Expression.Parameter(typeof(object[]), "args"); | |
var argsExp = new Expression[paramsInfo.Length]; |
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 class ActivatorExt | |
{ | |
private static ObjectActivator<T> GetActivator<T>(ConstructorInfo ctor) | |
{ | |
var paramsInfo = ctor.GetParameters(); |
NewerOlder