Skip to content

Instantly share code, notes, and snippets.

View DanielWJudge's full-sized avatar

Daniel Judge DanielWJudge

View GitHub Profile
syntax: glob
#-- Files
*.bak.*
*.bak
thumbs.db
*.msi
*.sdf
*.opensdf
#-- Directories
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
@DanielWJudge
DanielWJudge / TimePeriodFinal.cs
Created August 25, 2014 15:44
Time Period Final
if (isTypeA)
{
periodsToCheck.AddAll(typeAPeriods);
if (isTypeB)
{
//find overlaps between type a and type b
periodsToCheck.AddAll(typeBPeriods);
overlapPeriods = periodCombiner.IntersectPeriods(periodsToCheck);
//reassign periods to check to the overlapping periods if we have to look at type C
@DanielWJudge
DanielWJudge / TimePeriodOverlap.cs
Created August 25, 2014 15:43
Time Period Overlap
//final overlapping periods
ITimePeriodCollection overlapPeriods = new TimePeriodCollection();
//used to help find overlaps
TimePeriodIntersector<TimeRange> periodCombiner = new TimePeriodIntersector<TimeRange>();
//periods to check to see if they overlap
TimePeriodCollection periodsToCheck = new TimePeriodCollection();
@DanielWJudge
DanielWJudge / TimePeriodRange.cs
Created August 25, 2014 15:42
TimePeriodRange
if (isTypeA)
foreach (var dateTime in typeADates)
typeAPeriods.Add(new TimeRange(dateTime.Start, dateTime.End));
if (isTypeB)
foreach (var dateTime in typeBDates)
typeBPeriods.Add(new TimeRange(dateTime.Start, dateTime.End));
if (isTypeC)
foreach (var dateTime in typeCDates)
typeCPeriods.Add(new TimeRange(dateTime.Start, dateTime.End));
@DanielWJudge
DanielWJudge / TimePeriodCollection.cs
Created August 25, 2014 15:42
TimePeriodCollection
TimePeriodCollection typeAPeriods = new TimePeriodCollection();
TimePeriodCollection typeBPeriods = new TimePeriodCollection();
TimePeriodCollection typeCPeriods = new TimePeriodCollection();
@DanielWJudge
DanielWJudge / LargestTriangleThreeBuckets.cs
Last active March 16, 2024 15:23
Largest-Triangle-Three Bucket Downsampling Graphs in C#
public static IEnumerable<Tuple<double, double>> LargestTriangleThreeBuckets(List<Tuple<double, double>> data, int threshold)
{
int dataLength = data.Count;
if (threshold >= dataLength || threshold == 0)
return data; // Nothing to do
List<Tuple<double, double>> sampled = new List<Tuple<double, double>>(threshold);
// Bucket size. Leave room for start and end data points
double every = (double)(dataLength - 2) / (threshold - 2);