Skip to content

Instantly share code, notes, and snippets.

View mtcrutch's full-sized avatar

Matthew Crutchfield mtcrutch

View GitHub Profile
@mtcrutch
mtcrutch / captureError.js
Created October 1, 2021 13:18
captureError.js
import * as Sentry from "@sentry/react";
import { YellowBox, ErrorUtils } from "react-native";
// https://medium.com/@benhurott/dealing-with-global-errors-in-react-native-expo-as-simple-as-possible-bc8e440caeae
//TODO: This will not capture native exception because we are living in JS land
// for now, should probalby consider added native capture at some point too
if (ErrorUtils) {
ErrorUtils.setGlobalHandler((error, isFatal) => {
// Capture the unhandled error and send to sentry.
// Sentry doesn't see this as unhandled, add a tag to provide that context.
// SWIFT
// ------------------------------------------------------------
import WMCCPADNS
let ccpaDNSService = WMCcpaDnsService()
ccpaDNSService.dnsToggle(userId: "user id",vendors: ["vendor1","vendor2"],doNotSell:true)
// CHECK
import WMCCPADNS
let ccpaDNSService = WMCcpaDnsService()
ccpaDNSService.getPreference(userId:"user id")
@mtcrutch
mtcrutch / page-visibility.js
Created September 10, 2016 15:50
Wraps a supplied React Component with one that handles watching the page visibility API for changes. When page visibility changes, the wrapper component's internal state is passed down to the supplied component as a prop.
import React, { Component } from 'react';
/**
* Wraps a supplied React Component with one that handles watching the page
* visibility API for changes. When page visibility changes, the wrapper
* component's internal state is passed down to the supplied component as a prop.
*
* @example
* ```js
* const Test = PageVisbility(YourComponent);
@mtcrutch
mtcrutch / refactor.js
Created July 9, 2015 13:31
Refactoring Code Helpers
// link: https://www.youtube.com/watch?v=X8WgkMbEAVQ
function beaconError(msg) {
try {
throw new Error();
} catch (e) {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/beacon');
xhr.send(msg + '\n' + e.stack);
}
@mtcrutch
mtcrutch / timeline-show-current.js
Last active August 29, 2015 14:08
Example timemachine payload to spec out current model
{
"actual_show_time_eastern_string":"2014-10-23T00:00:10-04:00",
"ad_segments":[
{
"duration":121,
"start_timestamp":1414039726,
"show_id":"urn:ngtv-show:78676",
"segment_id":"urn:ngtv-segment:257839",
"state":"Actual",
"title":"Commercial Break 5",
@mtcrutch
mtcrutch / pull-requests.js
Created February 27, 2014 18:21
Standardize Bitbucket PRs
javascript:(function() {var e = document.getElementById('id_description');if (e) {e.value += '# Jira ticket link(s)\n\n\n# What does this do and why is it needed?\n\n\n# How to test\n\n\n# Updates\n\n\ncc: @user1 @user2 @user3';}})();
@mtcrutch
mtcrutch / nav-timing-api.js
Created October 1, 2013 14:13
js performance benchmarker
// http://mattandrews.info/talks/port80-2013/#/33
var perf = window.performance,
// just before page is requested
start = perf.timing.requestStart,
// first byte received
end = perf.timing.responseStart,
total_time = end - start;
@mtcrutch
mtcrutch / webdev-resources.md
Created November 13, 2012 16:44
Web Dev Resources

Web Dev Resources

Links to articles, screencasts, and authors I find interesting.


Table of Contents

  1. Twitter
  2. Blogs
  3. Articles
  4. Screencasts
@mtcrutch
mtcrutch / snippets.css
Created October 25, 2012 18:13
snippets.css—a series of useful snippets I use all the time…
/* Simple top-bottom gradient */
div {
background: -webkit-linear-gradient(top, #fff, #000);
background: -moz-linear-gradient(top, #fff, #000);
background: -ms-linear-gradient(top, #fff, #000);
background: -o-linear-gradient(top, #fff, #000);
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#000));
background: linear-gradient(top, #fff, #000);
}