Skip to content

Instantly share code, notes, and snippets.

View glopesdev's full-sized avatar

glopesdev

View GitHub Profile
@glopesdev
glopesdev / TimeConverter.cs
Created June 21, 2023 22:24
A utility helper class for converting 64-bit ticks to doubles with minimal loss of precision
using System;
static class TimeConverter
{
const double SecondsPerTick = 1.0 / TimeSpan.TicksPerSecond;
public static double GetTimestamp(TimeSpan timeSpan)
{
return GetTimestamp(timeSpan.Ticks);
}
@glopesdev
glopesdev / BinarySerializer.cs
Created May 29, 2023 21:39
Simple binary writer serializer generator using expression trees
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq.Expressions;
using System.Reflection;
static class BinarySerializer
{
public static void Serialize<T>(BinaryWriter writer, T value)
{
@glopesdev
glopesdev / AppExecLinkHelper.cs
Created February 15, 2023 18:43
Resolve UWP package reparse point metadata
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
using System.IO;
/// Resolve UWP package reparse point metadata (IO_REPARSE_TAG_APPEXECLINK)
/// inspired by: https://stackoverflow.com/a/65583702/628228
internal static class AppExecLinkHelper
{
@glopesdev
glopesdev / harp.py
Created May 12, 2021 02:41
Short utility functions for loading HARP files
import numpy as np
import pandas as pd
payloadtypes = {
1 : np.dtype(np.uint8),
2 : np.dtype(np.uint16),
4 : np.dtype(np.uint32),
8 : np.dtype(np.uint64),
129 : np.dtype(np.int8),
130 : np.dtype(np.int16),
@glopesdev
glopesdev / QuadratureCounter.cs
Created January 27, 2020 12:47
Decodes the current state of a quadrature encoder from raw A/B channels
using Bonsai;
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
[Combinator]
[Description("Decodes the current state of a quadrature encoder from raw A/B channels.")]
[WorkflowElementCategory(ElementCategory.Transform)]
@glopesdev
glopesdev / Delaunay.cs
Last active March 5, 2021 11:12
Delaunay triangulation based on Paul Bourke's algorithm (http://paulbourke.net/papers/triangulate/)
using OpenTK;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
static class Delaunay
{
@glopesdev
glopesdev / DynamicSource.cs
Created October 4, 2017 09:11
Minimalist example of a dynamically typed source in Bonsai
using Bonsai.Expressions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bonsai.Dynamic
@glopesdev
glopesdev / FolderBrowserDialog.cs
Created December 16, 2016 15:46
Minimalist example for opening a modern UI folder browser dialog in Windows Forms.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CommonDialogs