Skip to content

Instantly share code, notes, and snippets.

View adamjohnson's full-sized avatar

Adam Johnson adamjohnson

View GitHub Profile
@cdsaenz
cdsaenz / index.html
Created August 19, 2022 14:11
Demo Alpine JS and Fetch from Remote API
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alpine Ajax test</title>
</head>
<body>
<h1>Users API Retrieval Test</h1>
@LewisJEllis
LewisJEllis / getRelativeTimeString.ts
Last active November 8, 2024 00:35
Simplified getRelativeTimeString
// from https://twitter.com/Steve8708/status/1504131981444980739
// simplified to a function body of 8 tidy lines
// no loop needed, no 2d array of 3-tuples needed
// just 2 arrays, a findIndex call, and some indexing :)
export function getRelativeTimeString(
date: Date | number,
lang = "en"
): string {
const timeMs = typeof date === "number" ? date : date.getTime();
@acidtone
acidtone / README.md
Last active September 26, 2024 19:05
<aside> element: What's it for?

Aside: Proper Use

In HTML5, aside is only "related to the content around the aside element".

In HTML 5.1 (CR) the definition became more specific: aside is "related to the content of the parenting sectioning content".

Following the newer definition, the aside element should be inside of the section element to which it is related.

Sectioning elements

  • body
  • header
const PIE = 3.14;
function f() {
console.log('function f inside module a');
}
function f123() {
//not accessible
}
Seven different types of CSS attribute selectors
// This attribute exists on the element
[value]
// This attribute has a specific value of cool
[value='cool']
// This attribute value contains the word cool somewhere in it
[value*='cool']
@cferdinandi
cferdinandi / performance.html
Last active January 29, 2025 03:46
Testing DOM injection performance with a few different techniques. https://gomakethings.com/testing-dom-injection-performance-with-vanilla-js/
<!DOCTYPE html>
<html>
<head>
<title>DOM Injection Performance Testing</title>
</head>
<body>
<div id="app1"></div>
<ul id="app2"></ul>
@wayanjimmy
wayanjimmy / soFetch.js
Created November 30, 2018 02:41
Reusable fetch function from wesbos
// https://twitter.com/wesbos/status/1063515277911052290/photo/1
async function soFetch(input, settings = {}) {
const response = await fetch(input, {
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
...settings
});
@pascalandy
pascalandy / markdown-style-guide.txt
Last active April 21, 2022 03:47
Markdown sources. Search for « Style guide » on live demos from https://play-with-ghost.com
---
<a id="sources"></a>
## Markdown sources
**From this point, everything you see is formatted using Markdown syntax.** It will work in every editor that supports Markdown because it's an open standard on the web. There are two ways to find the sources for this page.
#### 1. On GitHub
@kieranmv95
kieranmv95 / _spacing-helper.scss
Last active February 6, 2019 02:10
Generates a array of spacing helper classes for margin and padding
// Customisable spacing units. these can be changed and new ones added
$spacing-units: (
1: 3px,
2: 5px,
3: 8px,
4: 13px,
5: 21px,
);
// These will not change this is just to help generate the classes with the correct naming
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 14, 2025 04:53
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example