Skip to content

Instantly share code, notes, and snippets.

drmikecrowe

Block or report user

Report or block drmikecrowe

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
@drmikecrowe
drmikecrowe / bootstrap.sh
Last active Mar 22, 2020
Bash Bootstrap
View bootstrap.sh
#!/usr/bin/env bash
function install {
FILE="$2"
URL="$1/$FILE"
wget $URL -O $FILE
sudo gdebi $FILE
rm $FILE
}
@drmikecrowe
drmikecrowe / docker-compose.yml
Created Sep 2, 2019
Ultimate docker-compose setup for home media center
View docker-compose.yml
#Reference: https://www.smarthomebeginner.com/docker-home-media-server-2018-basic
version: "3.6"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx
ports:
- "80:80"
volumes:
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@drmikecrowe
drmikecrowe / Account.js
Last active Jan 27, 2020
Auto-incrementing ID's in Loopback
View Account.js
module.exports = function (Account) {
Account.observe('before save', function addAccountId(ctx, next) {
if (!ctx.isNewInstance) {
debug('id is already set, returning', ctx.data);
return next();
}
app.dataSources.db.connector.collection("Sequences").findAndModify({name: 'Account'}, [['_id', 'asc']], {$inc: {value: 1}}, {new: true}, function (err, rec) {
if (err) {
console.err(err);
@drmikecrowe
drmikecrowe / results.md
Last active Jan 20, 2020
Time various loop structures
View results.md

Base code/idea comes from this blog post

The output:

Testing vanilla:      4.1ms
Testing lodash:      25.4ms -- 518% slower
Testing es6-for-of:   7.3ms --  78% slower
Testing forEach:      6.1ms --  48% slower
Testing map:          9.2ms -- 125% slower
@drmikecrowe
drmikecrowe / README.md
Last active Jan 10, 2020
Using debug with xstate
View README.md

For anyone else coming across this and wondering how this works, here's a summary.

NOTE: I'm still learning xstate, so there may be better ways to do this!

Step #1, install debug

debug is a small debugging library that can be used in the console or browser. In the screenshot above, each of the different colors comes from a different debug instance. For example, I instatiate the following in my console application:

const dbgM: debug.Debugger = require('debug')("fsm:master");
@drmikecrowe
drmikecrowe / test1-mutation-observer.js
Last active Jan 6, 2020
Watch elements as page loads
View test1-mutation-observer.js
const targets = ["#top-header", "#main-header"];
const config = {
attributes: true,
attributeOldValue: true,
subtree: true,
childList: true,
};
function logAllEvents(target, myElement) {
@drmikecrowe
drmikecrowe / searchImdb.py
Created Jan 3, 2020
Rename ripped directory from ARM based on search
View searchImdb.py
#!/home/mcrowe/Programming/Personal/imdb/.direnv/python-3.7.5/bin/python3
import sys
import imdb
import click
from os import listdir, system, rename
from os.path import isfile, join, getctime, basename
from lxml.builder import E
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
const RETRY_INTERVAL = 2000;
const MAX_RETRIES = 3;
const initHardwareState = "initHardware";
const connectNetworkState = "connectNetwork";
const provisionState = "provision";
const retryState = "retry";
const fatalState = "fatal";
const connectedState = "connected";
You can’t perform that action at this time.