Skip to content

Instantly share code, notes, and snippets.

View jaredwilli's full-sized avatar
🏄‍♂️

Jared Williams jaredwilli

🏄‍♂️
View GitHub Profile
@jaredwilli
jaredwilli / asyncawait.html
Created November 28, 2017 13:36 — forked from CrabDude/asyncawait.html
BayNode Node Night 11/3/15: async/await by Adam Crabtree
<!DOCTYPE html>
<html>
<head>
<title>Async Await</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
@jaredwilli
jaredwilli / index.js
Created November 25, 2017 12:40
HOC boiled eggs
import React, { Component, PropTypes } from 'react'
import window from 'global/window'
import wrapDisplayName from 'recompose/wrapDisplayName'
import { createChangeEmitter } from 'change-emitter'
export const reactHOC = BaseComponent => {
return class ReactHOC extends Component {
static displayName = wrapDisplayName(BaseComponent, 'ReactHOC')
static propTypes = {
b: PropTypes.bool,
@jaredwilli
jaredwilli / asyncToReact.js
Created November 24, 2017 09:10 — forked from sebmarkbage/asyncToReact.js
Convert Async Function to React Component
function asyncToReact(fn) {
class PromiseComponent extends React.Component {
state = { waiting: true, result: null };
componentDidMount() {
fn(...this.props.args).then(result => this.setState({ waiting: false, result }));
}
componentDidUpdate() {
fn(...this.props.args).then(result => this.setState({ waiting: false, result }));
}
shouldComponentUpdate(newProps) {
@jaredwilli
jaredwilli / Enhance.js
Created November 24, 2017 09:06 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# Add yarn to PATH
export PATH="$PATH:/opt/yarn-[version]/bin"
#!/usr/bin/env bash
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
@jaredwilli
jaredwilli / coverage.js
Created November 10, 2017 22:39 — forked from paulirish/coverage.js
JS coverage profiler data via protocol
'use strict';
const chromeLauncher = require('chrome-launcher');
const CDP = require('chrome-remote-interface');
const launchChrome = () =>
chromeLauncher.launch({
chromeFlags: ['--disable-gpu', '--headless']
});
componentWillReceiveProps( nextProps, nextContext)
shouldComponentUpdate(nextProps,nextState,nextContext)
componentWillUpdate(nextProps,nextState,nextContext)
componentDidUpdate(prevProps,prevState,prevContext)
@jaredwilli
jaredwilli / UnmaskPendoEmails.js
Last active November 8, 2017 00:09
Documentation for unmasking Pendo emails for Cloudlock NPS report
/**
* Cloudlock NPS report email address unmasking.
*
* Original DevTools snippet is here:
* https://gist.github.com/jaredwilli/013a74dbdd6d630a254ee1a12f08c2c8
*
* I have the above script saved as a DevTools snippet. For info on how to do that check this out:
* https://developers.google.com/web/tools/chrome-devtools/snippets
*
*
@jaredwilli
jaredwilli / unmaskPendoEmails.js
Last active November 8, 2017 00:10
Unmask Pendo email addresses for Cloudlock NPS report CSV
// use comma delimiter tool
// https://delim.co/#
// After setting an array var a; with the array of user emails run this script to unmask
// the emails, console.log them and automatically copy them to clipboard.
var r = [];
for (var i = 0; i < a.length; i++) {
var email = a[i].split('user-')[1];
r.push(window.atob(email.split('@')[0]));
}