Skip to content

Instantly share code, notes, and snippets.

View tracker1's full-sized avatar

Michael J. Ryan tracker1

View GitHub Profile
@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';
@tracker1
tracker1 / MyComponent.jsx
Last active July 8, 2019 12:48
Simple pattern for loading async data with react, redux and redux-thunk middleware
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as Actions from './action';
const mapStateToProps = ({ loaded, loading, error, data }) = ({ loaded, loading, error, data });
const mapDispatchToProps = dispatch => ({ action: bindActionCreators(Actions, dispatch) });
export class MyComponent extends Component {
load = _ => this.props.action.load(this.props.id);
@tracker1
tracker1 / create-docker-sql.js
Created June 20, 2019 22:29
SQL in Docker via Node
import { Docker } from "docker-cli-js";
import path from "path";
import shell from "shelljs";
import mkdirp from "mkdirp";
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const isWin = process.platform === "win32";
const docker = new Docker();
const exec = str => {
@tracker1
tracker1 / README.md
Last active May 11, 2019 14:37
Web.config file for synchronet on IIS

You'll need windows server, or windows pro for this, so that you have IIS. I'm running Windows 10 Pro.

Move your BBS's Web settings to bind on port 8000 (or any internal port you choose).

Install Application Request Routing (ARR)

Add your BBS's web/root directory to a new website in IIS, you must specify a host name, you can add additional host names under bindings.

My web.config file below, this file should also go into your web/root. You'll need to replace localhost:8000 with the appropriate port you are using. You sould also replace the www\.roughneckbbs\.com and www.roughneckbbs.com references with your host name.

import os from 'os';
import path from 'path';
const COMPANY = 'companydir';
const APP = 'appdir';
export const getDefaultDataPath = (env = process.env, useOS = os.platform()) => {
switch (useOS) {
case 'win32':
return path.join(env.PROGRAMDATA || 'C:/ProgramData', `${COMPANY}/${APP}/`);
@tracker1
tracker1 / request.js
Created April 5, 2019 16:34
fetch api wrapper - request
import changeObjectCase from 'change-object-case';
import base from '../../base';
import HttpStatus from 'http-status-codes';
const serverCase = input =>
changeObjectCase.pascalKeys(input, { recursive: true, arrayRecursive: true });
export const headRequest = async route => {
const token = sessionStorage.getItem('token');
const headers = {
@tracker1
tracker1 / password-breached.js
Last active April 2, 2019 21:34
Check haveibeenpwned with JS
import crypto from 'crypto';
import fetch from 'node-fetch';
const PREFIX_LENGTH = 5;
export function hash(passphrase) {
const shaSum = crypto.createHash('sha1');
shaSum.update(String(passphrase).normalize('NFKC'));
return shaSum.digest('hex');
}
@tracker1
tracker1 / logger.js
Last active March 27, 2019 18:59
Console Logger for node.js
import console from 'console';
import process from 'process';
import util from 'util';
import fclone from 'fclone';
import rollingFile from 'rolling-file';
import mkdirp from 'mkdirp';
import { packageBase } from './pkg';
export const LEVELS = Object.seal({
FATAL: 1000,
@tracker1
tracker1 / Docker on Windows Server 2019 Directions.md
Last active March 8, 2019 00:48
Docker on Windows Server 2019 for linux and windows containers

POWERSHELL: (Admin)

Install-WindowsFeature Hyper-V
Install-WindowsFeature Containers

mkdir "$Env:ProgramFiles\Docker"

cd "$Env:ProgramFiles\Docker"