Skip to content

Instantly share code, notes, and snippets.

View shanewholloway's full-sized avatar
🗜️
I may be slow to respond.

Shane Holloway shanewholloway

🗜️
I may be slow to respond.
View GitHub Profile
@shanewholloway
shanewholloway / iter_subnet_matches.js
Created May 5, 2022 04:57
NodeJS snippet for iterating the `networkInterfaces()` in the same subnet as `ip_query`
import {networkInterfaces} from 'os'
import {isIP, BlockList} from 'net'
export function * iter_subnet_matches(ip_query) {
let family = isIP(ip_query)
let ipv = 'ipv'+family
for (let [if_name, if_addrs] of Object.entries(networkInterfaces())) {
for (let each of if_addrs) {
if (family != each.family)
@shanewholloway
shanewholloway / box.css
Created June 15, 2022 19:06
aspect-ratio center box CSS
/* from Kevin Powell's [3 useful CSS tricks](https://www.youtube.com/watch?v=HOM47v73yG8)
* for <div class=box></div>
* useful for iframes, videos, pictures, etc.
*/
.box {
width: 25rem;
aspect-ratio: 1 / 1;
position: fixed;
inset: 0rem; /* sets top/bottom/left/right to same value */
@shanewholloway
shanewholloway / searchFragment.js
Created February 2, 2023 14:30
Search a page using text-fragment in the URL hash.
// See https://web.dev/text-fragments/
// location.hash = searchFragment('text to find in page')
export const searchFragment = txt => `#:~:text=${encodeURI(txt)}`
@shanewholloway
shanewholloway / imtiny.js
Created April 21, 2025 23:15
imtiny.js is the 100 char tl;dr of imm-dom-core.js
export default (e,a,...z)=>
z.reduce((e,c)=>(e.append(c),e)
,Object.assign(e.nodeType ? e : document.createElement(e), a))