Skip to content

Instantly share code, notes, and snippets.

View jhadev's full-sized avatar

Josh A jhadev

View GitHub Profile
@jhadev
jhadev / compare-har.json
Created July 19, 2022 19:42
compare-har.json
{
"har1": {
"url": "https://github.com/jhadev/har-test/blob/main/coach-plp-har-5-15.har",
"label": "Before any change 5-15",
"run": 1
},
"har2": {
"url": "https://github.com/jhadev/har-test/blob/main/coach-plp-har-6-13.har",
"label": "After 2 spikes 6-13",
"run": 1

Story:

LCP is abnormally high and it is being called out as an h2 tag. After inspecting webpagetest json we can see that the LCP event fires multiple times. This lines up with page visibilty as the element in question is visible to the user well before the browser captures the final LCP.

https://www.webpagetest.org/result/220823_BiDcKW_AEJ/

As seen above LCP is captured at 1.9s and is identified as a text element. But it also fires again after hydration occurs and the DOMNodeId has been changed. This is the same issue that has been identified by Patrick Meenan here.

https://forums.webpagetest.org/t/lcp-varies-wildly-across-runs-with-no-code-difference/11701/9

@jhadev
jhadev / create_repo.zsh
Last active December 13, 2022 23:17
ZSH Create Repo
export GH_TOKEN="<YOUR TOKEN>"
export REPO_NAME="$USER-automated-repo"
create_repo() {
echo default $REPO_NAME
vared -c -p 'Please enter a repo name: ' REPO_NAME
echo new $REPO_NAME
curl \
-X POST \
@jhadev
jhadev / create_html_repo.zsh
Last active October 12, 2022 11:06
create_html_repo.zsh
source ${ZDOTDIR-$HOME}/.zsh/create_html_repo.zsh
export GH_TOKEN=<TOKEN>
export REPO_NAME="$USER-automated-repo"
# create_html_repo my-cool-project
create_html_repo() {
cd ~/Desktop && mkdir $1 && cd $1 && touch index.html && mkdir assets && mkdir assets/js && mkdir assets/css && touch assets/js/script.js && touch assets/css/style.css && echo '<!DOCTYPE html>
@jhadev
jhadev / .gitignore.txt
Created November 4, 2022 18:52
gitignore
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,node
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos,node
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
@jhadev
jhadev / kill_old_ssh_agents
Created November 21, 2022 17:49 — forked from gubatron/kill_old_ssh_agents
Linux command (script) to kill old ssh-agent processes, (could be parametrized to change the process name)
#!/usr/bin/env python
# Author: @gubatron
# License: MIT License, Copyright 2019
import os
import sys
if __name__ == '__main__':
cmd_get_process_list = 'ps -ef --sort=start_time | grep ssh-agent | grep -v grep'
output = os.popen(cmd_get_process_list)
lines = output.read().split("\n")
@jhadev
jhadev / scaffold.zsh
Last active December 13, 2022 23:14
Scaffold an entire simple html, css, js project in one command
# put in .zshrc
# cd into the folder you want to put your project in
# scaffold [PROJECT NAME]
scaffold() {
mkdir $1 && cd $1 && touch index.html && mkdir assets && mkdir assets/js && mkdir assets/css && touch assets/js/script.js && touch assets/css/style.css && echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@jhadev
jhadev / Clone a forked repo and all it's branches.md
Created December 23, 2022 12:14
Clone a forked repo and bring all branches with it

All the answers I saw here were valid, but there is a much cleaner way to clone a repository and to pull all the branches at once.

When you clone a repository, all the information of the branches is actually downloaded, but the branches are hidden. With the command

git branch -a

you can show all the branches of the repository, and with the command

@jhadev
jhadev / reuseable-fetch.js
Last active December 14, 2023 19:15
reuseable-fetch.js
function client(endpoint, { body, ...customConfig } = {}) {
const headers = { 'Content-Type': 'application/json' };
const config = {
method: body ? 'POST' : 'GET',
...customConfig,
headers: {
...headers,
...customConfig.headers,
},
};