Skip to content

Instantly share code, notes, and snippets.

View jsdbroughton's full-sized avatar
🐒
coiled spring

Jonathon Broughton jsdbroughton

🐒
coiled spring
View GitHub Profile
@jsdbroughton
jsdbroughton / GuidConversion.cs
Last active November 22, 2022 15:17
IFC<>NET GUIDs
using System;
using System.Diagnostics;
namespace CASE.Navis2BCF
{
/// <summary>
/// Conversion methods between an IFC
/// encoded GUID string and a .NET GUID.
/// This is a translation of the C code
@jsdbroughton
jsdbroughton / module.ts
Created June 21, 2021 16:21 — forked from soerenmartius/module.ts
vuex 4 cognito module
import {
ActionContext,
ActionTree,
GetterTree,
MutationTree,
Module,
Store as VuexStore,
CommitOptions,
DispatchOptions,
} from 'vuex'
@jsdbroughton
jsdbroughton / 0.intro.md
Last active February 16, 2020 23:27
Not as recursive as I'd hoped. Or how Javascript's essence saved me from recurring dreams.
// tree is what is returned post shenanigans.
let tree:TreeItem[] = [];
// keyMap keeps track of the indexes where parentKeys are found in the keyed but flat array.
const keyMap:Map<string, number> = new Map();
treeItemsWithBranches.forEach( ( node ):void => {
// nodes with no parents are at root level.
// this is not a binary tree, there can be several root level nodes.
const parentItems:TreeItem[] = [];
parentKeys.forEach( ( v:string ):void=>{
let parts = v.split( `-` );
while ( uniqueIds.has( lastId ) ) {
lastId += 1;
}
uniqueIds.add( lastId );
let name = parts.pop() || ``;
parentItems.push( {
id: lastId,
const keyedItems = treeItems.map( ( item ): TreeItem => {
const fieldValues = fieldNames.map( ( field ): string => item.data && item.data[field] );
let parentKey = fieldValues.slice( 0, -1 ).reduce( ( id, field ):string=>{
if ( id && field ) {
id += `-` + field;
}
if ( !id && field ) {
id = field;
}
parentKeys.add( id );
const fieldNames = fieldTokens.map( ( field ): string => field.name );
const parentKeys: Set<string> = new Set();
const fieldNames = fieldTokens.map( ( field ): string => field.name );
const parentKeys: Set<string> = new Set();
const uniqueIds: Set<number> = new Set();
let lastId = 1;
// All treeviewItems
treeItems.forEach( ( item ): void => {
if ( item && item.data ) {
uniqueIds.add( item.data.uniqueId );
lastId += 1;
}
});
const uniqueIds: Set<number> = new Set();
let lastId = 1;
// All treeviewItems
treeItems.forEach( ( item ): void => {
if ( item && item.data ) {
uniqueIds.add( item.data.uniqueId );
lastId += 1;
}
});