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; | |
using System.Collections.Generic; | |
namespace Clipper { | |
public class Program { | |
private static List<IntPoint> MakeRectangle(int left, int top, int right, int bottom) { | |
var contour = new List<IntPoint>(); | |
contour.Add(new IntPoint(left, top)); | |
contour.Add(new IntPoint(right, top)); | |
contour.Add(new IntPoint(right, bottom)); |
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 IntVector2[] ConvexHull3(IntVector2 a, IntVector2 b, IntVector2 c) { | |
var abc = Clockness(a, b, c); | |
if (abc == Clk.Neither) { | |
var (s, t) = FindCollinearBounds(a, b, c); | |
return s == t ? new[] { s } : new[] { s, t }; | |
} | |
if (abc == Clk.Clockwise) { | |
return new[] { c, b, 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
using System; | |
using System.Drawing; | |
using OpenMOBA; | |
using OpenMOBA.DevTool.Debugging; | |
using OpenMOBA.Geometry; | |
namespace QuadSegmentIntersection { | |
public class Program { | |
// assumes p is ccw ordered | |
public static bool SegmentInConvexPolygon(IntLineSegment2 s, IntVector2[] p) { |
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 class SectorSnapshotGeometryContext { | |
private const int kCrossoverAdditionalPathingDilation = 2; | |
private readonly SectorSnapshot _sectorSnapshot; | |
private readonly double _holeDilationRadius; | |
private readonly int _crossoverErosionRadius; | |
private readonly int _crossoverErosionDiameterSquared; | |
private readonly int _crossoverDilationFactor; |
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
IEnumerable<int> nums = Enumerable.Range(0, 10); | |
var sum = nums.Aggregate( | |
seed: 0, | |
func: (accumulator, val) => { | |
Console.WriteLine($"Acc: {accumulator}, Val: {val} => {accumulator+val}"); | |
return accumulator + val; | |
} | |
); | |
Console.WriteLine("Sum: " + sum); |
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 bool TestForInnerException<TInnerException>(Exception exception) { | |
if (exception.GetType() == typeof(TInnerException)) { | |
return true; | |
} | |
var aggregateException = exception as AggregateException; | |
if (aggregateException != null) { | |
foreach (var innerException in aggregateException.InnerExceptions) { | |
if (TestForInnerException<TInnerException>(innerException)) { | |
return true; |
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; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace TaskParallelForEachDeadlock { | |
class Program { | |
static void Main(string[] args) { | |
int workerThreads, iocpThreads; | |
ThreadPool.SetMaxThreads(4, 4); |
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
/sys/bus/i2c/devices | |
i2c0: 0x44E0_B000 | |
i2c1: 0x4802_A000 | |
i2c2: 0x4819_C000 | |
echo BB-I2C1 > /sys/devices/bone_capemgr.9/slots | |
root@beaglebone:/sys/bus/i2c/devices# ls -l | |
total 0 | |
lrwxrwxrwx 1 root root 0 Jan 1 00:00 0-0024 -> ../../../devices/ocp.3/44e0b000.i2c/i2c-0/0-0024 |
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
await new Select { | |
Case(Time.After(500), async () => { | |
if (ticksToVictory == 1) { | |
logger.Info("Party time!"); | |
await Task.FromResult(false); | |
} else { | |
await ElectionCandidatePhaseAsync(ticksToVictory - 1, followerIds); | |
} | |
}), | |
Case(electChannel, async message => { |
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
foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces()) { | |
if (!networkInterface.SupportsMulticast || | |
networkInterface.OperationalStatus != OperationalStatus.Up || | |
networkInterface.IsReceiveOnly) continue; | |
var ipv4Properties = networkInterface.GetIPProperties()?.GetIPv4Properties(); | |
if (ipv4Properties != null) | |
sockets.Add(CreateSocket(ipv4Properties.Index)); | |
} | |