Skip to content

Instantly share code, notes, and snippets.

View UberMouse's full-sized avatar

Taylor Lodge UberMouse

View GitHub Profile
@UberMouse
UberMouse / breadcrumbMiddleware.js
Created July 3, 2017 21:18
Log Raygun4JS Breadcrumbs from Redux actions
const breadcrumbMiddleware = store => next => action => {
const previousState = store.getState();
const nextAction = next(action);
const state = store.getState();
rg4js('recordBreadcrumb', {
message: `Executing Redux action '${action.type}'`,
metadata: {
action,
state,
@UberMouse
UberMouse / errorReportingMiddleware.js
Created July 3, 2017 21:08
Redux exception logging with Raygun4JS
const errorReportingMiddleware = store => next => action => {
try {
return next(action);
} catch(err) {
console.error('Caught an exception!', err);
window.rg4js('send', {
error: err,
customData: {
action,
@UberMouse
UberMouse / middleware.js
Created July 3, 2017 21:03
Simple Redux middleware for logging exceptions to Raygun
const errorReportingMiddleware = store => next => action => {
try {
return next(action);
} catch(err) {
console.error('Caught an exception!', err);
rg4js('send', {
error: err,
customData: {
action,
@UberMouse
UberMouse / logRenderTime.js
Last active July 3, 2017 05:08
Log a React components render time to Raygun with a custom timing
import React from 'react';
// This has not been tested with a browser that doesn't support the window.performance api
export default function LogRenderingTime(Component) {
let boot = 0;
class LogRenderTime extends React.Component {
constructor(props) {
super(props);
@UberMouse
UberMouse / App.js
Created July 3, 2017 04:30
Tracking React Router navigation events with Raygun4JS
import { withRouter } from 'react-router'
class App extends Component {
constructor(props) {
super(props);
this.props.history.listen((location, action) => {
window.rg4js('trackEvent', { type: 'pageView', path: location.pathname });
});
function INCOME_TAX(input) {
var taxBrackets = {
14000: 0.105,
34000: 0.175,
22000: 0.30,
99999: 0.33
}
var salary = parseInt(input, 10)
return Object.keys(taxBrackets).reduce(function(acc, taxAmount) {
export default function StoryLayout(props) {
return (
<div>
<div className="row">
<div className="medium-8 columns">
<p><span style={{textDecoration: 'underline'}}>My stories</span> / {props.metadata.title}</p>
<ViewSwitcher />
</div>
</div>
<div className="row">
// ==UserScript==
// @name Wanikani Override
// @namespace wkoverride
// @description Adds an "Ignore Answer" button during reviews that makes WaniKani ignore the current answer (useful if, for example, you made a stupid typo)
// @include http://www.wanikani.com/review/session*
// @include https://www.wanikani.com/review/session*
// @version 1.1.3
// @author Rui Pinheiro
// @grant GM_addStyle
// @grant unsafeWindow
// ==UserScript==
// @name WaniKani Improve
// @namespace http://www.michaelfrank.com.br/wanikani_improve/
// @include https://www.wanikani.com/review/session
// @include http://www.wanikani.com/review/session
// @version 2.2.2
// @grant GM_addStyle
// @grant GM_getResourceText
// @run-at document-end
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js
metrics.forEach(function(metric) {
const extendedMetric = ExtendedMetric(metric)
const metricDay = extendedMetric.day
// TODO: Fix duplication
extendedMetric.record.forEach((m) => {
if(this.facets[m.id] == null)
this.facets[m.id] = {[metricDay]: {}}
this.facets[m.id][metricDay]['record'] = m