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
#include <xf86drm.h> | |
#include <xf86drmMode.h> | |
#include <gbm.h> | |
#include <EGL/egl.h> | |
#include <GLES3/gl31.h> | |
#include <stdlib.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <stdio.h> |
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 Task<string> Bash(string cmd, int[] acceptableCodes = null) | |
{ | |
var source = new TaskCompletionSource<string>(); | |
var escapedArgs = cmd.Replace("\"", "\\\""); | |
var process = new Process | |
{ | |
StartInfo = new ProcessStartInfo | |
{ | |
FileName = "bash", | |
Arguments = $"-c \"{escapedArgs}\"", |
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 Concentric | |
{ | |
/// <summary> Enumerates the rings of a circle starting from 1 radius up to the given radius. </summary> | |
public static IEnumerable<Point> EnumerateConcentric(int centerX, int centerY, int radius) | |
{ | |
yield return new Point(centerX, centerY); | |
for (var r = 1; r <= radius; ++r) | |
foreach (var point in EnumerateRadius(centerX, centerY, r)) | |
yield return point; | |
} |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <memory> | |
#include <cstring> | |
#include <vector> | |
#include <string.h> | |
#include <assert.h> | |
#include <getopt.h> /* getopt_long() */ | |
#include <fcntl.h> /* low-level i/o */ |
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
int getSmooth6() { | |
// ASSUMPTION: history has at least 6 entries | |
auto a = (getOffset(0) + getOffset(-1)) / 2; | |
auto b = (getOffset(0) + getOffset(-2)) / 2; | |
auto c = (getOffset(0) + getOffset(-3)) / 2; | |
auto d = (getOffset(-1) + getOffset(-2)) / 2; | |
auto e = (getOffset(-1) + getOffset(-3)) / 2; | |
auto f = (getOffset(-2) + getOffset(-3)) / 2; | |
return (((((a + b * 2) / 3 + c * 2) / 3 + d * 2) / 3 + e * 2) / 3 + f * 2) / 3; | |
} |
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 LimitedWorkers | |
{ | |
public static async IAsyncEnumerable<TO> EnumerateAsync<TI, TO>(this IEnumerable<TI> items, Func<TI, TO> taskFunc, int maxConcurrency, Action<TI, Exception>? handleError) | |
{ | |
var semaphore = new SemaphoreSlim(maxConcurrency); | |
var tasks = new List<Task<TO>>(); | |
var taskItems = new Dictionary<Task<TO>, TI>(); | |
foreach (var item in items) | |
{ |