Skip to content

Instantly share code, notes, and snippets.

View deckarts's full-sized avatar

detlef deckarts

View GitHub Profile
@deckarts
deckarts / vim-productive-start.md
Last active March 4, 2020 00:57
A Productive Start with Vim

Next Level Vim

It is definitely worth the time it takes to learn text manipulation with the ubiquitous Vi(m) command line text editor. There is a visual version, but we're going to focus on the command line interpreter version. If you only know how to open a file and enter text, edit some text, and especially how to save edited files and exit the program you will be much better off for it.

Vim is readily available in nearly all modern Linux (or BSD) distributions at the terminal emulator shell command prompt. Once you've defined Vim as your default editor for your user shell, then you can navigate builtin utilities like $ man etc. using familiar Vim key bindings. We'll highlight how to do that with bash and zsh, now distributed by Apple on the Mac since Catalina.

Bash

# ~/.bashrc (or alternatively) ~/.bash_profile
// Requires a Node environment
// Plus Axios https://github.com/axios/axios
'use strict'
const axios = require('axios');
// Get request json response data from source
function getUS() { return axios.get('https://covidtracking.com/api/us'); }
axios.all([getUS()])
// 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');
<!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 {
<!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() => {
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();
((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(`
@deckarts
deckarts / reactVueNodeSSRSEO.js
Last active October 15, 2020 19:48
Russ Jeffrey SSR & SEO
// 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>
{
"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"
}
},
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
const addPreloadBefore = (href) => ({
element: (el) => {