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
ffmpeg.exe -t 10 -f gdigrab -framerate 30 -offset_x 1750 -offset_y 990 -video_size 148x90 -show_region 1 -i desktop -c:v h264 -qp 0 output.mkv |
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
#nullable enable | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Automation; | |
namespace libUIHelper | |
{ |
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 string RemoveNonPrintable(this string input) | |
{ | |
var result = Regex.Replace(input, @"\p{C}+", string.Empty); | |
return result; | |
} |
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 IEnumerable<T> Recurse<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> childSelector, bool depthFirst = false) | |
{ | |
List<T> queue = new List<T>(source); ; | |
while (queue.Count > 0) | |
{ | |
var item = queue[0]; | |
queue.RemoveAt(0); | |
var children = childSelector(item); |
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 T? DeserializJson<T>(this string json) where T : class | |
{ | |
var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; | |
var result = JsonConvert.DeserializeObject<T>(json, settings); | |
return result; | |
} | |
public static string SerializeToJson(this object obj) | |
{ | |
var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; |
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 dObj = (dynamic)obj; | |
var filter = CreateFilterDelegate<object>(@"dObj.Name.StartsWith(""P"") && dObj.HeightCm >= 180"); | |
var matchesFilter = filter(new Globals(dObj)); | |
Console.WriteLine($"{dObj.Name}: {matchesFilter.Result}"); | |
var proj = CreateSelectDelegate<object>(@"new {dObj.Name.ToUpper(), HeightMm = dObj.HeightCm * 1000}"); | |
var transformed = proj(new Globals(proj)); | |
Console.WriteLine($"{transformed.Result}"); |
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 string GetProgramOutput(string exe, string args) | |
{ | |
Process process = new Process(); | |
process.StartInfo.FileName = exe; | |
process.StartInfo.Arguments = args; | |
process.StartInfo.UseShellExecute = false; | |
process.StartInfo.RedirectStandardOutput = true; | |
process.StartInfo.RedirectStandardError = true; | |
process.Start(); |
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
Function GetProgramOutput([string]$exe, [string]$arguments) | |
{ | |
$process = New-Object -TypeName System.Diagnostics.Process | |
$process.StartInfo.FileName = $exe | |
$process.StartInfo.Arguments = $arguments | |
$process.StartInfo.UseShellExecute = $false | |
$process.StartInfo.RedirectStandardOutput = $true | |
$process.StartInfo.RedirectStandardError = $true | |
$process.Start() |
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
I used (converted from Python): | |
public static (int X, int Y) Deg2Tile(double latDeg, double lonDeg, int zoom) | |
{ | |
var latRad = (latDeg * Math.PI) / 180; | |
var n = Math.Pow(2.0, zoom); | |
var xtile = (int)((lonDeg + 180.0) / 360.0 * n); | |
var ytile = (int)((1.0 - Math.Log(Math.Tan(latRad) + (1 / Math.Cos(latRad))) / Math.PI) / 2.0 * n); | |
return (xtile, ytile); | |
} |
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
//DON'T USE THESE. It spins the CPU when calling TryTake() | |
using System; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; |