Skip to content

Instantly share code, notes, and snippets.

Brandon Newton btnwtn

Block or report user

Report or block btnwtn

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
@btnwtn
btnwtn / resources.md
Last active Nov 6, 2018
frontend engineering resources
View resources.md

Pony Foo Weekly

Web/JS-focused newsletter. Usually has really great content. No spam either, I always sign up for this on new email accounts.

Google Web Fundamentals

There is a ton of stuff in here, pick something from the left sidebar that you don't know about and check it out. There's interesting stuff on PWAs, performance, security, etc..

Also if you go to the updates tab and select "BY YEAR". You will find the developers web blog which just has a ton of articles. A lot of it is about brand new Web APIs in coming to Chrome.

@btnwtn
btnwtn / 50.js
Last active Sep 18, 2019
Automat dat +50 clapping on Medium.com
View 50.js
(() => {
const up$ = new MouseEvent("mouseup", { bubbles: true });
const down$ = new MouseEvent("mousedown", { bubbles: true });
const node = document.querySelector(
`.js-postActionsFooter button[data-action="multivote"]`
);
let attempts = 0;
View withTrackingClass.js
const withTracking = WrappedRoute => {
return class PageViewWrapper extends Component {
componentDidMount() {
console.log(this.props);
if (window.dataLayer) {
window.dataLayer.push({
event: "pageview or something"
});
}
View withTracking.js
const withTracking = WrappedRoute => props => {
console.log(props);
if (window.dataLayer) {
window.dataLayer.push({
event: "pageview or something",
// https://developers.google.com/tag-manager/devguide
});
}
View Beuracracy.js
import React, { Component } from 'react';
const mockAPI = {
emailExists(email) {
return new Promise(resolve => setTimeout(resolve(true), 300))
}
}
const validateEmail = async email => new Promise(resolve => {
mockAPI.emailExists(email).then(exists => {
View monkeyPatchEventMethods.js
// Logs all calls to preventDefault / stopPropagation in an user-friendly way
if ( process.env.NODE_ENV !== "production" ) {
(function monkeyPatchEventMethods() {
const logEventMethodCall = (event,methodName) => {
const MinimumMeaningfulSelectors = 3; // how much meaningful items we want in log message
const target = event.target;
const selector = (function computeSelector() {
View Video.js
import React, { Component } from 'react'
import YouTube from 'react-youtube'
export default class Video extends Component {
constructor(props) {
super(props)
this.state = {
progress: 0,
duration: 0,
player: null,
You can’t perform that action at this time.