Skip to content

Instantly share code, notes, and snippets.

:octocat:
heads down...

brad oyler bradoyler

:octocat:
heads down...
Block or report user

Report or block bradoyler

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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) {
@bradoyler
bradoyler / .block
Last active May 7, 2019
US Flight animation (svg)
View .block
license: mit
@bradoyler
bradoyler / rest-client.js
Last active Jan 7, 2019
Simple Rest API client for node with support for JWT (bearer authentication) - requires Axios
View rest-client.js
const debug = require('debug')('rest-client')
const axios = require('axios')
const https = require('https')
module.exports = ({ baseURL, timeout = 20000 } = {}) => {
if (!baseURL) {
baseURL = 'https://localhost:5001/api'
}
const instance = {}
@bradoyler
bradoyler / node-standards-v6.md
Last active Sep 27, 2018
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
@bradoyler
bradoyler / .block
Last active Sep 17, 2018
crime rates in US cities
View .block
license: mit
@bradoyler
bradoyler / mapReduce-WordCounter.js
Last active Sep 10, 2018
Using Map-Reduce in Javascript: counting words in a string.
View mapReduce-WordCounter.js
// for counting words in a string
var words="Hi there and hello there. Welcome and hello there.";
var wordcnt = words.replace(/[^\w\s]/g, "").split(/\s+/).reduce(function(map, word){
map[word] = (map[word]||0)+1;
return map;
}, Object.create(null));
@bradoyler
bradoyler / .block
Last active Sep 6, 2018
Annotated Venn
View .block
license: mit
View walmartpoints.js
// TODO: convert to geojson
var features = [["5992", [44.6504003, -93.2971104], "m"], ["2925", [38.3090139, -122.2833277], "m"], ["3258", [44.0459028, -123.1693478], "m"], ["3829", [36.3089363, -82.4037918], "m"], ["4108", [36.1961294, -94.1839461], "m"], ["3126", [39.6252614, -104.7940466], "m"], ["2058", [35.8372108, -78.6074304], "m"], ["3758", [47.7915764, -96.6073175], "m"], ["1447", [46.6945384, -92.1069175], "m"], ["296", [35.2178954, -93.1664602], "m"], ["5639", [33.8009759, -117.9423561], "m"], ["3646", [32.9700244, -80.0031996], "m"], ["2548", [37.6589269, -82.2710627], "m"], ["3894", [38.0377086, -84.4220326], "m"], ["6480", [33.3078738, -111.9016392], "m"], ["5300", [27.8472347, -82.354341], "m"], ["913", [43.2915783, -91.7537152], "m"], ["4648", [30.6780894, -88.1948548], "m"], ["829", [35.652383, -105.9998077], "m"], ["3485", [34.8639269, -83.9980185], "m"], ["3415", [28.1472522, -82.7435188], "m"], ["4147", [35.8181516, -78.8449974], "m"], ["3355", [36.1561688, -115.0796748], "m"], ["2876", [35
You can’t perform that action at this time.