Skip to content

Instantly share code, notes, and snippets.

@mzabriskie
mzabriskie / README.md
Last active February 5, 2024 15:10
Check git status of multiple repos

If you're like me you have a dir like ~/Workspace/Github where all your git repos live. I often find myself making a change in a repo, getting side tracked and ending up in another repo, or off doing something else all together. After a while I end up with several repos with modifications. This script helps me pick up where I left off by checking the status of all my repos, instead of having to check each one individually.

Usage:

git-status [directory]

This will run git status on each repo under the directory specified. If called with no directory provided it will default to the current directory.

@mzabriskie
mzabriskie / nps.js
Created September 8, 2015 19:01
Calculate Net Promoter Score
// Expects an array of scores from 0-10
// Example: nps([10, 9, 10, 4]); -> 50
// See http://www.medallia.com/net-promoter-score/
function nps(scores) {
var promoters = 0;
var detractors = 0;
for (var i=0, l=scores.length; i<l; i++) {
if (scores[i] >= 9) promoters++;
if (scores[i] <= 6) detractors++;
/**
* Creates an array containing a range of values.
*
* <p>
* Examples:
*
* <code>
* // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
* Array.range(1, 10);
*
@mzabriskie
mzabriskie / random-attendee.js
Last active March 6, 2021 16:13
Select random Meetup attendee
// Run this from your browser console on your meetup event page (http://www.meetup.com/AngularJS-Utah/events/183104032/)
(function () {
// Query document for attendees and select a random one
const list = document.querySelector('ul.attendees-list').children,
item = list[Math.floor(Math.random() * list.length)],
name = item ? item.querySelector('h4.text--bold').innerText : 'N/A';
// Remove item so they can only be selected once
item && item.parentNode.removeChild(item);
@mzabriskie
mzabriskie / abort.js
Created March 18, 2015 15:35
axios abort request
/**
* The problem with using Promises for a request API is that Promises
* make it difficult to abort the request. Typically when using XHR
* some factory will wrap the actual XHR, but ultimately will return
* the XHR object.
*
* ```
* var request = performRequest('/user/12345');
* request.abort();
* ```
@mzabriskie
mzabriskie / Base64.js
Created April 3, 2013 20:02
Base64 encode/decode for JavaScript
// http://www.webtoolkit.info/javascript-base64.html
(function () {
var KEY_STR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
// private method for UTF-8 encoding
function _utf8_encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {

Enzyme 3 Gotchas

Some things have changed with enzyme 3 that deviate from version 2, and in some cases deviate from what even the enzyme docs suggest. Here's some of the gotchas I came across in upgrading from enzyme 2 to 3.

Accessing the DOM node

React

render () {
 return (
import React, { Component } from 'react'
import PropTypes from 'prop-types'
class MessageModalBody extends Component {
render () {
return (
<TabList>
<TabPanel title="Score Range">
<MessageForm showScoreFilter={true} />
</TabPanel>
@mzabriskie
mzabriskie / .gitignore
Last active July 17, 2017 16:21
Releasing ES6 node modules to npm
build/
node_modules/

Dialog Components Refactor

The purpose of this document is to help define the components that comprise Instructure UI's dialog components. Dialog components typically render outside the context of the application and are the primary focal point when rendered.

This represents a refactor as specified by Jen Stern.

Building Blocks

These are the low-level components needed for dialogs.