Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
say hi

brad oyler bradoyler

👋
say hi
View GitHub Profile
@bradoyler
bradoyler / README.md
Last active Mar 24, 2020
Application Insights helper for typescript function apps
View README.md

AppInsights helper

a typescript wrapper for Application Insights

Examples

Exception tracking

import { trackException } from './appinsights-helper'

trackException({ exception: error })
@bradoyler
bradoyler / README.md
Last active Mar 19, 2020
Simple Rest API client for node with support for JWT (bearer authentication) - requires Axios
View README.md

REST-client.js

Usage

const RestClient = require('./rest-client')
const client = RestClient({ baseURL: 'https://mydomain.com' })
client.setAuthHeader('my-auth-token') // optional

const { data } = await client.get('/articles')
@bradoyler
bradoyler / .aaa.md
Last active Mar 16, 2020
Flu Illness Cartogram
View .aaa.md

CDC ILI map

@bradoyler
bradoyler / README.md
Last active Mar 16, 2020
US Flights animation (Canvas2D)
View README.md

Animating 3000 Flights using Canvas2D

Source code for animation used in #AirplaneMode

Orange dots = landing
Blue dots = takeoff

Config settings

var landingColor = '#fe761e';
@bradoyler
bradoyler / node-standards-v6.md
Last active Feb 5, 2020
Nodejs (6.x) standards
View node-standards-v6.md

Node Standards (v6.x)

The 7 Commandments of Node:

  1. processes shall be small, and start instantly
  2. always communicate via message bus (Redis, RabbitMQ)
    • this is intended to avoid blocking IO like a slow HTTP request
  3. each process shall log to stdout
    • it's not the responsibility of the app to route logs
  4. a process shall not maintain state
    • avoid in-memory session ids, socket connections, etc
View allDateConversions.js
Object.getOwnPropertyNames(Date.prototype)
.filter(name => name.startsWith('to'))
.map(method => `${method}: ${(new Date())[method]()}`)
View numberToHsl.js
function numToColor (num, maxHue = 350, minHue = 0) {
const hue = num * (maxHue - minHue) + minHue
return `hsl(${hue}, 70%, 45%)`
}
@bradoyler
bradoyler / extract-folder-git.md
Created Sep 16, 2019
extract repo from git folder
View extract-folder-git.md

git commands

git clone --mirror ssh://git@gituhub.com/user/repo.git filtered-repo
cd filtered-repo
git filter-branch --prune-empty --subdirectory-filter some/folder/path/ master
cd ..
git clone ./filtered-repo new-repo
cd new-repo
git status
@bradoyler
bradoyler / csproj-scanner.js
Last active Jul 30, 2019
scan csproj files for usage of ProjectReference
View csproj-scanner.js
const glob = require('glob')
const fs = require('fs');
const xml2js = require('xml2js');
const path = require('path');
function parseFile (filePath, parser) {
fs.readFile(filePath, (err, data) => {
parser.parseString(data, (err, result) => {
const itemgroups = result.Project.ItemGroup;
if (itemgroups && itemgroups.length) {