Skip to content

Instantly share code, notes, and snippets.

/**
Mark up code document at the given `codeUrl` into the div `domelement`
using the optional option overrides and optional callback.
Callback signature is (err, out) - where `out` is the structure defined
in [markupcode.js](../src/markupcode'js).
The getCodeUrl function allows testing on localhost (ie: leaves the
url untouched). If the server is not localhost will change url to
go to GitHub for the raw source to mark up.
@PotOfCoffee2Go
PotOfCoffee2Go / quickyExpressMarkdownMiddleware.md
Last active October 9, 2018 08:04
Quick express server middleware to convert .md files to .html page
// app.js or where-ever 'app' and 'express' vars are assigned
const
    fs = require('fs-extra'),
    path = require('path'),
    marked = require('marked');

// Web site is in ./www from this js file
const commonSiteDir = __dirname +'/www';
@PotOfCoffee2Go
PotOfCoffee2Go / node-red-contrib-alasql-install.md
Last active June 23, 2017 03:41
Local install of PotOfCoffee2Go changes to node-red-contrib-alasql

Draft 6/21/2017

Review procedures of updates to PotOfCoffee2Go fork of node-red-contrib-alasql

Before accepting Pull Requests to PotOfCoffee2Go fork of node-red-contrib-alasql a review of the updates will be performed.

The review will be done by installing changes locally, kick-the-tires, and upon acceptance will be submitted to https://github.com/AlaSQL/node-red-contrib-alasql for merging into the next production release.

Currently, nodes developed under node-red do not have a system of test verification - such as mocha, jasmine, etc. The best that can be done at this time, is to build a node-red test suite of flows that test the modifications. No updates will be accepted by PotOfCoffee2Go without a set of accompanying node-red flows which test the changes.

The reviewers will integrate the flows into what will become a standard set of test flows to be approved by the maintainers of the official production release of node-red-contrib-alasql AlaSQL,

@PotOfCoffee2Go
PotOfCoffee2Go / git-daemon-anon.md
Last active September 4, 2020 09:39
Setup git daemon allowing anonymous clone and push behind a firewall

Git server behind a firewall

It is handy to be able to quickly create a git repo server with anonymous clone and push access rights.
Note: Anyone!! with access to the server will be able to clone and push to the repo
Is super handy for personal use, in-house networks, or networks behind a firewall where security is less of an issue.

Server side

Create common repo directory

Create the server git directory
Create a test repo
Bring up the git server daemon

@PotOfCoffee2Go
PotOfCoffee2Go / GistBtns.js
Last active November 29, 2018 09:27
Some examples for ObservableHq DMT Gist Tool
GistBtns = {
// Used to lookup language based on file extension and render highlighting
const prism = new PrismLookup;
function tinyOcto() {return `${Spinner.octocat}`.replace('"48" height="48"','"24" height="24"')}
const gistid = '8014cc196d580699feab787abc9398a0'; // My Gist for these examples
let buttons = [];
buttons[0] = html`<button class="bttn pill" style="margin-left: 2em;">Markdown gist</button>`;
buttons[0].onclick = async () => {
@PotOfCoffee2Go
PotOfCoffee2Go / observable-to-nodejs.js
Last active October 7, 2018 15:02
Load classes stored in ObservableHq into nodejs
/*
Create empty directory
From command line
* note to self: nvm use 10
npm init -y
npm i fs-extra --save
npm i node-fetch --save
npm i download-cli --save
@PotOfCoffee2Go
PotOfCoffee2Go / store.js
Last active March 26, 2020 15:54
Persist values between web pages in localstorage
/*
Persist values between web pages in localstorage
Handles data objects to any depth
usage:
let store = new Store;
let value = store.db.path.to.field.value;
store.update = {section: {field: value}};
*/
class Store {
constructor() { this.init(); }
@PotOfCoffee2Go
PotOfCoffee2Go / colorconsole.js
Created May 12, 2020 09:51
Linux bash color console in nodejs
/*
Allows coloring linux console text with nodejs.
Color codes are loaded into a table of 8 rows
with each row containing 64 columns.
Examples:
Save this file as 'colorconsole.js'
then run 'node ./colorconsole.js'
Usage:
@PotOfCoffee2Go
PotOfCoffee2Go / _automaton.md
Last active June 15, 2020 20:55
Javascript Cellular Automaton Engine

_conway_life

  • Press 'raw' button of the _index.html file below

  • Copy the file (ctrl-a)(ctrl-c)

  • Paste into fav editor (ctrl-v) and save (ctrl-s).

    • (Name can be anything but should have a '.html' extension)
  • Open in browser - no server needed.

    • (The other files in this gist will be automatically fetched)
@PotOfCoffee2Go
PotOfCoffee2Go / cellular automata RLE parser.md
Last active March 15, 2024 08:52
Javascript cellular automata RLE parser

RLE parser usage

See the RLE section for definition of RLE format.

This class expects the (extended) RLE input to be correctly formatted. It is a two state parser, thus multi-state RLE will not parse properly.

The output this.pattern is a string with spaces(dead)/zero(alive) with lines separated by '\n'.