Skip to content

Instantly share code, notes, and snippets.

View toptensoftware's full-sized avatar

Brad Robinson toptensoftware

View GitHub Profile
// Runs tasks in parallel with a max concurrency.
// - `tasks` param should be an iterable collection of promises
// - `concurrency` is the maximum number of tasks to run at once
// - returns an array of results in same order as returned from
// the tasks. Each result is an object with either `value` key
// if the promise returned a value, or `error` if the task threw
// an error.
async function runParallel(tasks, concurrency)
{
using SkiaSharp;
using System;
using System.Data.Common;
using System.Runtime.InteropServices.ComTypes;
using Topten.GuiKit.DataTransfer;
using Topten.RichTextKit;
using Topten.RichTextKit.Editor;
namespace Topten.GuiKit
{
@toptensoftware
toptensoftware / TempoLeds.ino
Created April 14, 2021 23:43
Arduino script to display tempo beat using Cantabile Tempo LEDs binding
#include <Adafruit_NeoPixel.h>
#include <MIDI.h>
#define PIN_COLOR_LEDS 6
#define CC_TEMPO_LEDS 127
#define BEAT_MASK 0x0F
#define BEATS_SHIFT 4
#define BEATS_OFFSET 2
#define BEATS_MASK 0x0F
@toptensoftware
toptensoftware / TempoFlasher.ino
Created April 14, 2021 23:41
Arduino script to flash LED using Cantabile Tempo LEDs binding
in#include <Adafruit_NeoPixel.h>
#include <MIDI.h>
#define PIN_COLOR_LEDS 6
#define CC_TEMPO_LEDS 127
#define BEAT_MASK 0x0F
#define COLOR_DOWNBEAT 0x001000
#define COLOR_OTHERBEATS 0x080000
#define MILLIS_FLASH 100
@toptensoftware
toptensoftware / getFileLinesSync.js
Last active March 27, 2021 07:20
Synchronously read a file line by line with NodeJS
let fs = require('fs');
let string_decoder = require('string_decoder');
// Synchronously read the content of a text file one line at a time
// Note, caller must complete the iteration for file to be closed
// ie: don't break out early from the loop calling this function
function* getFileLinesSync(filename, encoding)
{
let fd = fs.openSync(filename);
let buf = Buffer.allocUnsafe(32768);
// This is the root Class1.cs file
public partial class Class1
{
public string Platform
{
get => impl_GetPlatform();
}
}
// This goes in PlatformWin/Class1.cs
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.EndsWith('Win'))">
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.EndsWith('Osx'))">
<DefineConstants>$(DefineConstants);OSX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);NET4</DefineConstants>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace DpiTest
{
class Program
void Load()
{
// Standard messages
Add(0x0000, new unused()); // WM_NULL
Add(0x0001, new WM_NC_OR_CREATE(false)); // WM_CREATE
Add(0x0002, new WM_DESTROY()); // WM_DESTROY
Add(0x0003, new copy()); // WM_MOVE
Add(0x0005, new copy()); // WM_SIZE
Add(0x0006, new WM_ACTIVATE()); // WM_ACTIVATE
// etc...