Skip to content

Instantly share code, notes, and snippets.

View dimorphic's full-sized avatar
🤖
*void 0*

Sabin Tudor dimorphic

🤖
*void 0*
View GitHub Profile
@MichaelSimons
MichaelSimons / RetrievingDockerImageSizes.md
Last active May 15, 2025 19:17
Retrieving Docker Image Sizes

Retrieving Docker Image Sizes

There are two metrics that are important to consider when discussing the size of Docker images.

  1. Compressed size - This is often referred to as the wire size. This affects how fast/slow images can be pulled from a registry. This impacts the first run experience on machines where images are not cached.
  2. Uncompressed size - This is often referred to as the size on disk. This affects how much local storage is required to support your Docker workloads.

The example commands shown below will work on Windows, MacOS, and Linux.

How to Measure the Compressed Size

@tannerlinsley
tannerlinsley / onWindowFocus.ts
Last active January 30, 2024 09:37
A utility function to detect window focusing without false positives from iframe focus events
type State = {
added: boolean;
interval: false | ReturnType<typeof setInterval>;
inFrame: boolean;
callbacks: Array<SetFocusedCallback>;
};
type EnrichedHTMLIFrameElement = HTMLIFrameElement & { ___onWindowFocusHandled: boolean };
type SetFocusedCallback = (focused?: boolean) => void;
const easeInOutCubic = t => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1)
function timeline(t, number, slot, cb) {
const range = slot * (1 / number)
if (t >= range && t <= range + 1 / number) cb(easeInOutCubic((t - range) * number))
}
function useTimeline(factor = 1, number, offset, callback) {
useFrame(state => {
const t = (Math.sin(state.clock.getElapsedTime() * factor) + 1) / 2
@heyitsarpit
heyitsarpit / .eslintignore
Created June 28, 2020 07:13
ESlint and Prettier for React apps (Bonus - Next.js and TypeScript)
node_modules
@benhatsor
benhatsor / IDFromTime.js
Last active February 10, 2024 15:47
Generate a unique ID based on the current time. Note: If you need a truly unique ID, use something like the JS Crypto API instead.
// Both numbers and letters
function mixedID() {
var now = new Date();
timestamp = now.getFullYear().toString();
timestamp += (now.getMonth < 9 ? '0' : '') + now.getMonth().toString();
timestamp += ((now.getDate < 10) ? '0' : '') + now.getDate().toString();
timestamp += now.getHours().toString();
timestamp += now.getMinutes().toString();
timestamp += now.getSeconds().toString();
@kidGodzilla
kidGodzilla / dokku_on_digital_ocean.md
Created October 25, 2020 06:43 — forked from henrik/dokku_on_digital_ocean.md
Notes from running Dokku on Digital Ocean.

My notes for Dokku on Digital Ocean.

These may be a bit outdated: Since I originally wrote them, I've reinstalled on a newer Dokku and may not have updated every section below.

Commands

Install dokku-cli (gem install dokku-cli) for a more Heroku-like CLI experience (dokku config:set FOO=bar).

# List/run commands when not on Dokku server (assuming a "henroku" ~/.ssh/config alias)

ssh henroku dokku

@SuwakoMmh
SuwakoMmh / Gitbridge.md
Last active May 14, 2023 14:30
Using the same SSH key for multiple Github (& co) accounts

Using the same SSH key for multiple Github (& co) accounts

The most known hack is to edit ~/.ssh/config and use a different hostname in place of github.com for each account. (ref this gist)

However, one might still want to use github.com as a hostname for various reasons. Hence this hack idea I had.

1. Creating a bridge user

This may vary depending on the distribution, but for ubuntu or any given useradd :

# useradd -r -m -d /opt/git git
@jfet97
jfet97 / DFS.js
Last active August 26, 2023 10:02
Simple Depth First Search in JavaScript
function isObject(entity) {
return typeof entity === "object" && entity !== null;
}
function getAdjacentNodes(obj) {
return (
Object.entries(obj)
.filter(([, v]) => isObject(v))
)
}
@kidGodzilla
kidGodzilla / geoip.js
Created February 22, 2022 20:08
Geo IP node / express
const requestIp = require('request-ip');
function getIp (req) {
let ip = null;
try {
//ip = (req.headers['x-forwarded-for'] || '').split(',').pop() ||
// req.connection.remoteAddress ||
// req.socket.remoteAddress ||
// req.connection.socket.remoteAddress;
@kidGodzilla
kidGodzilla / browser-icon.js
Created May 29, 2022 17:34
Infer Browser by input string & return an icon
/***
* Given a slightly messy set of input strings, attempt to match a well-known browser name, and return an icon
*
* Examples:
* inferBrowserIcon('safari') // exact match
* inferBrowserIcon('Safari Mobile 15.4') // matches "safari" from input string
* inferBrowserIcon('Firefox 99', 128) // pick a specific size (from sizes)
* inferBrowserIcon('unknownbrowser') // fallback if no match
* inferBrowserIcon(null, 128, 'brave') // You know the browser-logos repo key
*/