Skip to content

Instantly share code, notes, and snippets.

Avatar
🦆
Sometimes I git ducky

detlef deckarts

🦆
Sometimes I git ducky
View GitHub Profile
View unblockCSS()
const unblockCSS = () => ({
element: (el) => {
el.removeAttribute('media');
el.setAttribute('rel', 'preload');
el.setAttribute('as', 'style');
el.setAttribute('onload', "this.onload=null;this.rel='stylesheet';this.media='all'");
el.after(`
<noscript><link rel="stylesheet" href="${el.getAttribute("href")}"></noscript>
`, { html: true }); }});
View testbed-deckarts-workers-dev
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
const addPreloadAfter = (href) => ({
element: (el) => {
View sel-deckart-workers-dev
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
const addPreloadBefore = (href) => ({
element: (el) => {
View seo4dev01.lighthouse.report.json
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
"environment": {
"networkUserAgent": "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4420.0 Mobile Safari/537.36 Chrome-Lighthouse",
"hostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36",
"benchmarkIndex": 1366,
"credits": {
"axe-core": "4.1.2"
}
},
@deckarts
deckarts / reactVueNodeSSRSEO.js
Last active Oct 15, 2020
Russ Jeffrey SSR & SEO
View reactVueNodeSSRSEO.js
// React App.js
import React from 'react';
import { Route, Switch, NavLink } from 'react-router-dom';
import Home from './Home';
import Posts from './Posts';
export default props => {
return (
<div>
<ul>
View calculatepp.js
((arg) => {
const USD = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2 })
if (isNaN(Number(arg)) || arg < 0) { return; } //fail test the initial value
let amt = Number(arg);
function fee (num) { return num * .029 + .3; }
do { amt += .01; } while (amt - fee(amt) < arg);
console.log(`
View covidcountystats.js
const {StringStream} = require('scramjet');
const request = require('request');
// requires two arguments (county and state) which must be wrapped in quotes if a phrase i.e. 'new york city' 'new york'
let counter = 0;
let death = 0;
let cases = 0;
let args = process.argv;
do {
args.shift();
View covid-19-us-states.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>US Covid-19</title>
<style> ul { list-style: none; } ul li { margin: 0px 0px 5px 0px; } </style>
<script>
const getCovidStats = async() => {
View covid-19.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>US Covid-19</title>
<script>
const getCovidStats = async() => {
try {
View covid19async.js
// needs $ npm install node-fetch
// https://github.com/node-fetch/node-fetch
const fetch = require('node-fetch');
const getCovidStats = async() => {
console.log('\nCovid-19');
try {
const response = await fetch('https://covidtracking.com/api/us');