Skip to content

Instantly share code, notes, and snippets.

@tracker1
tracker1 / ProjectName.csproj
Created Dec 3, 2019
DotNet Core 3, XUnit, Integrated Tests With Coverage
View ProjectName.csproj
<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 Oct 15, 2020
NPM Publish Github Action
View npm-publish-release.yml
# 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 Aug 1, 2019
Custom encoded data into JSON
View CustomJsonData.md

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
View Snackbar.component.jsx
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 / create-docker-sql.js
Created Jun 20, 2019
SQL in Docker via Node
View create-docker-sql.js
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 => {
View init-environment.js
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 Apr 5, 2019
fetch api wrapper - request
View request.js
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 Apr 2, 2019
Check haveibeenpwned with JS
View password-breached.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 / Docker on Windows Server 2019 Directions.md
Last active Mar 8, 2019
Docker on Windows Server 2019 for linux and windows containers
View Docker on Windows Server 2019 Directions.md

POWERSHELL: (Admin)

Install-WindowsFeature Hyper-V
Install-WindowsFeature Containers

mkdir "$Env:ProgramFiles\Docker"

cd "$Env:ProgramFiles\Docker"
@tracker1
tracker1 / MyComponent.jsx
Last active Jul 8, 2019
Simple pattern for loading async data with react, redux and redux-thunk middleware
View MyComponent.jsx
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);