Skip to content

Instantly share code, notes, and snippets.

🦄
Love Coffee

Tommy Parnell TerribleDev

🦄
Love Coffee
Block or report user

Report or block TerribleDev

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
@TerribleDev
TerribleDev / TimeReporterPlugin.js
Created Nov 7, 2019
Webpack 4 plugin to measure how long an entry takes to build
View TimeReporterPlugin.js
const { performance, PerformanceObserver } = require('perf_hooks');
const PluginName = "TimeReporterPlugin";
class TimeReporterPlugin {
constructor(filterPattern = /HtmlWebpackPlugin|mini-css-extract-plugin/i) {
this.FilterPattern = filterPattern;
}
apply(compiler) {
let _timeEvents = [];
@TerribleDev
TerribleDev / Img.js
Created Oct 12, 2019
A component to render responsive images in gatsby
View Img.js
import React from "react"
import { useStaticQuery, graphql } from "gatsby"
import Img from "gatsby-image"
const Image = ({ imgName }) => {
const data = useStaticQuery(graphql`
query images {
allFile(filter: { sourceInstanceName: { eq: "images" } }) {
nodes {
name
View lazyLoadImages.js
if(window.IntersectionObserver) {
document.addEventListener("DOMContentLoaded", function() {
var lazyImages = [].slice.call(document.querySelectorAll(".lazy"));
var lazyImageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
var lazyImage = entry.target;
if(lazyImage.dataset.src) {
lazyImage.src = lazyImage.dataset.src;
}
@TerribleDev
TerribleDev / node.sh
Created Apr 30, 2019
force reinstall of node
View node.sh
brew uninstall --ignore-dependencies node@10
brew uninstall --ignore-dependencies node
brew uninstall --ignore-dependencies yarn
brew uninstall --ignore-dependencies icu4c
brew install node@10
brew install --ignore-dependencies yarn
brew link --overwrite --force node@10
brew link --overwrite yarn
@TerribleDev
TerribleDev / checkstyle.java
Created Apr 18, 2019
run checkstyle as git hook when java files have changed
View checkstyle.java
javaCount=`git diff --cached --name-status | grep -i .java | wc -l | awk '{print $1}'`
if [ $javaCount -eq 0 ];
then
exit 0
else
exec ~/cargurus/cg-main/cargurus-build/local/devbox-push/run-checkstyle.sh
fi
@TerribleDev
TerribleDev / TargetLinkExtension.cs
Created Jan 22, 2019
A markdig extension so add target blank to absolute urls
View TargetLinkExtension.cs
public class TargetLinkExtension : IMarkdownExtension
{
public void Setup(MarkdownPipelineBuilder pipeline)
{
}
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
{
var htmlRenderer = renderer as HtmlRenderer;
@TerribleDev
TerribleDev / createMarkedSelector.js
Last active Jan 15, 2019
Wrap reselect's createSelector with a function that measures how long selectors take to run
View createMarkedSelector.js
import {createSelector} from 'reselect';
const hasPerformanceApi =
window &&
window.performance &&
window.performance.measure &&
window.performance.mark;
const createFuncWithMark = (name, callback) => (...args) => {
const startMark = `${name}-Startmark`;
@TerribleDev
TerribleDev / replace
Created Jan 2, 2019
Regex to Replace createSelector with createMarkedSelector
View replace
const(\s?)(\w*)(\s?)=(\s)createSelector\(
const$1$2$3=$4createMarkedSelector('$2',
@TerribleDev
TerribleDev / exitCode.sh
Created Dec 14, 2018
put exit codes in shell
View exitCode.sh
# Custom bash prompt via kirsle.net/wizards/ps1.html
export PS1="\[$(tput bold)\]\$?|\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \[$(tput setaf 5)\]\W\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]"
@TerribleDev
TerribleDev / ConsoleAppenderExample.cs
Created Oct 7, 2017
The console appender example from apache's log4net site
View ConsoleAppenderExample.cs
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
You can’t perform that action at this time.