Skip to content

Instantly share code, notes, and snippets.

View nathansmith's full-sized avatar
😎
Ask me about free high fives!

Nathan Smith nathansmith

😎
Ask me about free high fives!
View GitHub Profile
@nathansmith
nathansmith / html5_template.html
Created December 7, 2011 01:41
Simple HTML5 Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>untitled</title>
<link rel="stylesheet" href="" />
</head>
<body>
@nathansmith
nathansmith / [1] tweet-delete.md
Last active April 1, 2026 13:18
Browser script to prune Twitter content

🐦 Look, I'm not saying you should do this.

  1. Go to your Twitter profile page.

  2. Paste this into the console.

  3. Hit enter.

But if you did — and left it running for a long while — it might eventually delete all tweets and retweets from your Twitter account.

@nathansmith
nathansmith / deepFreeze.js
Last active December 31, 2025 18:09
Type safe, recursive `Object.freeze`.
// ======
// Types.
// ======
/**
* @template T
* @typedef {{
* readonly [K in keyof T]: T[K] extends Record<PropertyKey, unknown>
* ? DeepReadonly<T[K]>
* : T[K];
@nathansmith
nathansmith / web-design-development-learning-resources.md
Last active December 7, 2025 13:37
Resources for learning web design & front-end development

➡️ NOTE:

This was written by my son in December 2017. It may/not still be accurate.


Minecraft: How to make TNT arrows

First, you will need a command block.

@nathansmith
nathansmith / module_pattern_init.js
Created January 11, 2010 17:08
Init + Module Pattern JS
// JS Module Pattern:
// http://j.mp/module-pattern
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
APP.go();
});
@nathansmith
nathansmith / html_reset.css
Created January 28, 2010 00:02
Reset for HTML4 / HTML5
/* `XHTML, HTML4, HTML5 Reset
----------------------------------------------------------------------------------------------------*/
a,
abbr,
acronym,
address,
applet,
article,
aside,
@nathansmith
nathansmith / [1] convertToMarkup.js
Last active March 11, 2025 10:27
Handy utilities for dealing with `<div contenteditable="true">` areas.
// Helpers.
import { convertToText } from './';
/*
You would call this when receiving a plain text
value back from an API, and before inserting the
text into the `contenteditable` area on a page.
*/
const convertToMarkup = (str = '') => {
return convertToText(str).replace(/\n/g, '<br>');
@nathansmith
nathansmith / [1] getRandomId.ts
Last active October 24, 2024 17:00
Helper to reduce a large string to a smaller ID.
/*
=====
NOTE:
=====
➡️ Actually, if you just want a random ID that works
even outside of SSL (localhost) you can just do this.
*/
// ======================
@nathansmith
nathansmith / waitForDeps.js
Created July 25, 2024 19:57
JS function that waits for dependencies, then calls them.
// Define function.
function waitForDeps(obj, list) {
// Expose promise.
return new Promise((resolve) => {
// Start polling.
const interval = setInterval(() => {
// Get missing.
const listMissing = list.filter(key => !obj[key]);
// All clear?