Skip to content

Instantly share code, notes, and snippets.

View TerribleDev's full-sized avatar
🦄
Love Coffee

Tommy Parnell TerribleDev

🦄
Love Coffee
View GitHub Profile
@TerribleDev
TerribleDev / notes.md
Last active August 20, 2022 12:59
some notes of components

Component Library:

css modules

```css` .button { width: 1em;

@TerribleDev
TerribleDev / TargetLinkExtension.cs
Created February 26, 2022 22:17
A markdig extension to add norel and noopener to external links
public class TargetLinkExtension : IMarkdownExtension
{
public void Setup(MarkdownPipelineBuilder pipeline)
{
}
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
{
var htmlRenderer = renderer as HtmlRenderer;
if (htmlRenderer != null)
@TerribleDev
TerribleDev / index.js
Created February 5, 2022 21:30
Dedupe
function dedupeWithDictionary(numbers) {
return Object.keys(numbers.reduce((accum, current) => {
accum[current] = true
return accum
}, {}))
}
function dedupeWithSet(numbers) {
return new Set(numbers).values()
@TerribleDev
TerribleDev / Main.cs
Created July 27, 2021 22:11
Calling Quala API from UnityWebRequest
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
public class Main
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void OnBeforeSceneLoadRuntimeMethod()
@TerribleDev
TerribleDev / a11y.js
Last active June 23, 2022 15:49
Use axe core to put ugly borders around elements that are not accessible
import axe from 'axe-core';
function debounce(fn, wait) {
let timeout = null;
return function (...args) {
const next = () => fn.apply(this, args);
clearTimeout(timeout);
timeout = setTimeout(next, wait);
};
}
@TerribleDev
TerribleDev / TimeReporterPlugin.js
Created November 7, 2019 14:16
Webpack 4 plugin to measure how long an entry takes to build
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 October 12, 2019 22:22
A component to render responsive images in gatsby
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
@TerribleDev
TerribleDev / lazyLoadImages.js
Created May 23, 2019 15:16
Lazy load images :)
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 April 30, 2019 13:44
force reinstall of node
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 April 18, 2019 16:13
run checkstyle as git hook when java files have changed
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