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 March 6, 2024 13:31
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();
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 June 2, 2023 20:33
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 July 22, 2024 06:03
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

@PieterScheffers
PieterScheffers / OpenWithSublimeText3.bat
Created January 2, 2017 09:18 — forked from cstewart90/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 10)
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f