Skip to content

Instantly share code, notes, and snippets.

View tracker1's full-sized avatar

Michael J. Ryan tracker1

View GitHub Profile
@tracker1
tracker1 / settings.json
Created May 6, 2020 17:17
vs code settings for synchronet /sbbs/.vscode/settings.json
{
"editor.rulers": [
76,
80
],
"editor.tabSize": 2,
"editor.renderControlCharacters": true,
"files.encoding": "cp437",
"files.associations": {
"*.ssjs": "javascript"
@tracker1
tracker1 / load-component-import.js
Created May 6, 2020 15:06
Code Splitting via lazy import with React
/*
/feature/load-component-import.js
This is used by any async loading areas of the application
import load from '../load-component-import.js';
const FooComponentAsync = load(() => import('./FooComponent'))';
*/
import React, { Suspense } from 'react';
@tracker1
tracker1 / precheck.js
Created March 28, 2020 18:06
Modern browser SPA precheck.js
// precheck
try {
eval('(function() { async _ => _; })();');
if (typeof fetch !== 'function') throw new Error('No fetch api');
} catch (e) {
// render unsupported message in half a second - after error trap
window.setTimeout(function() {
// fallback render for development
var body = document.getElementsByTagName('body')[0];
body.className = 'message';
@tracker1
tracker1 / settings.json
Created March 21, 2020 10:01
/sbbs/.vscode/settigns.json - Synchronet config for editing with VS Code.
{
"editor.rulers": [
76,
80
],
"editor.tabSize": 2,
"editor.renderControlCharacters": true,
"files.encoding": "cp437",
"files.associations": {
"*.ssjs": "javascript"
@tracker1
tracker1 / future.js
Last active December 30, 2021 08:12
Node Promise + EventEmitter
module.exports = () => {
// break resolve and reject out of a promise
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
// return as a future
return {
@tracker1
tracker1 / index.js
Created December 17, 2019 18:57
Application Initialization
/*
The application uses os-service module to register itself in to an
environment based on command line parameters.
*/
const SERVICE_NAME = "my-service-name"; // TODO: changeme
// https://www.npmjs.com/package/os-service - using fork for 12.13 for now
const service = require("os-service");
const startServer = require("./feature/web-server");
@tracker1
tracker1 / ProjectName.csproj
Created December 3, 2019 15:52
DotNet Core 3, XUnit, Integrated Tests With Coverage
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Add to be able to test default assembly -->
<GenerateProgramFile>false</GenerateProgramFile>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RootNamespace>ProjectName</RootNamespace>
<!-- Needed to exclude *.Test.cs from Release Build -->
@tracker1
tracker1 / npm-publish-release.yml
Last active October 15, 2020 00:36
NPM Publish Github Action
# scripts in package.json include the following...
# "prepare": "npm run build",
# "publish-major": "npm version major && git push origin master && git push --tags",
# "publish-minor": "npm version minor && git push origin master && git push --tags",
# "publish-patch": "npm version patch && git push origin master && git push --tags"
name: Publish to NPM
on:
push:
tags:
@tracker1
tracker1 / CustomJsonData.md
Created August 1, 2019 00:14
Custom encoded data into JSON

For encoding custom/complex data in JSON for generic detection, I suggest the following methodology.

// USE ASCII Characters for kind of what they are meant for.
const DLE = String.fromCharCode(16); // Data Link Escape
const SOH = String.fromCharCode(1); // start of heading
const STX = String.fromCharCode(2); // start ot text
const ETX = String.fromCharCode(3); // end of text
const EOT = String.fromCharCode(4); // end of transmission
@tracker1
tracker1 / Snackbar.component.jsx
Created July 31, 2019 21:37
Snackbar via notistack
import React from 'react';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import { SnackbarProvider, withSnackbar } from 'notistack';
import CheckIcon from 'mdi-material-ui/Check';
import ErrorIcon from '@material-ui/icons/Error';
import ThumbUpIcon from '@material-ui/icons/ThumbUp';
import WarningIcon from '@material-ui/icons/Warning';