Skip to content

Instantly share code, notes, and snippets.

Mike Heavers heaversm

Block or report user

Report or block heaversm

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
@heaversm
heaversm / common-js-tasks.js
Last active Jan 17, 2020
Common JS Tasks and Functions
View common-js-tasks.js
//basic async await
// this is the function we want to schedule. it's a promise.
const addOne = (x) => {
return new Promise(resolve => {
setTimeout(() => {
console.log(`I added one! Now it's ${x + 1}.`)
resolve()
}, 2000);
})
}
View useful-npm-commands.sh
# see outdated modules
npm outdated
# update all modules (latest minor version)
npm update --save/--save-dev
@heaversm
heaversm / useful-wp-commands.sh
Created Oct 31, 2019
Useful helpers for wordpress
View useful-wp-commands.sh
#Add a new user
wp user create <username> <email> --role=administrator --user_pass=mypassword
@heaversm
heaversm / common-js-workflows.md
Last active Oct 16, 2019
Common JS Workflows
View common-js-workflows.md

COMMON JS WORKFLOWS

Use an ES6 Module

With Unpkg

Add type="module" to script tags:

<script type="module">
  //then make sure to use the param module in unpkg:
@heaversm
heaversm / git-commands.sh
Created Oct 16, 2019
Useful git commands
View git-commands.sh
#verify remotes
git remote -v
#edit git config
git config -e
@heaversm
heaversm / eslint-commands.js
Created Oct 16, 2019
ESLint helpful notes and commands
View eslint-commands.js
//disables the current line:
// eslint-disable-line
//at top of file, disables linting on the entire file:
/* eslint-disable */
@heaversm
heaversm / useful-terminal-commands.sh
Last active Oct 16, 2019
Terminal commands, workflows, and utilities
View useful-terminal-commands.sh
# download a blob url for a video
#Use the HLS Downloader Google Chrome extension to get the link to the M3U playlist
#Copy that url into the script below
youtube-dl --all-subs -f mp4 -o "file-name-to-save-as.mp4" "[M3U_List_URL]"
# - - -
# run ngrok with host header for vuejs / react apps
ngrok http 8080 -host-header="localhost:8080"
@heaversm
heaversm / js-utilities.js
Last active Jan 3, 2020
Common JS Utility Functions
View js-utilities.js
//MAP A NUMBER FROM ONE RANGE TO ANOTHER:
function map_range(value, low1, high1, low2, high2) {
return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
}
//GET A RANDOM INTEGER BETWEEN [MIN] and [MAX]:
function randomIntFromInterval(min, max) { // min and max included
return Math.floor(Math.random() * (max - min + 1) + min);
}
@heaversm
heaversm / common-python-commands.sh
Created Sep 11, 2019
Frequently used python commands
View common-python-commands.sh
#pyenv
#install particular versions
pyenv install X.X.X
#list installed pyenv versions
pyenv versions
#set a local (current directory) python version
pyenv local 3.x.x
View server-commands.sh
php -S localhost:8080
#boots a local php server
python -m SimpleHTTPServer
#boots a local http server on python 2
python -m http.server
#boots a local http server on python 3
sass --watch main.scss main.css
You can’t perform that action at this time.