Skip to content

Instantly share code, notes, and snippets.

Build the logic for a network quality indicator:

Requirements:

  1. Every time the REPORT_NETWORK_QUALITY event comes in, I want to assign its results to context (no matter what else happens)
  2. If the network quality is bad or worse, we want to show a warning
  3. If the network quality gets better, we want to hide the warning again
  4. The warning must show for a minimum of 2 seconds, we don't want any weird flickering.
  5. The user should be able to dismiss the warning forever using the DISMISS_NETWORK_QUALITY_WARNING. The warning should never show again.
@miguelkashir
miguelkashir / caps-lock-hjkl-arrows-ubuntu.md
Last active July 31, 2022 16:43
Linux - Use Caps Lock + HJKL as arrow keys

Step 0 : install xclip and xcape

sudo apt install xclip xcape

Step 1 : create ~/.xmodmap

Copy the following text:

@RafaelDavisH
RafaelDavisH / Base_cs.txt
Last active December 21, 2020 18:03
Base_cs Club schedule and links
Learning Goal: Learn the basics of computer science with Base_cs series
Learning Curriculum:
Schedule its based on the first link, a compiled list of base_cs series content. The rest of links are other forms of the content to support our learning
- Github Repo
Link: https://github.com/vaidehijoshi/basecs-series
- Podcast
Link: https://overcast.fm/itunes1304168963/base-cs-podcast
@flybayer
flybayer / Link.tsx
Last active July 1, 2021 07:40
Much nicer and more intuitive Next.js Link abstraction
// stick this somewhere in your local @types/** files
interface NetworkInformation extends EventTarget {
readonly downlink: number;
readonly downlinkMax?: number;
readonly effectiveType: 'slow-2g' | '2g' | '3g' | '4g';
readonly rtt: number;
readonly saveData: boolean;
readonly type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
onchange: EventListener;
function setFocusIfFocusable(node) {
if (node.nodeType !== Node.ELEMENT_NODE) {
// Text and comment nodes aren't focusable.
return false;
}
if (node.disabled === true) {
// Disabled elements can't be focused.
return false;
}
@tjluoma
tjluoma / youtube-rss.sh
Last active January 3, 2023 09:00
Did you know YouTube has RSS feeds? No? Probably because YouTube makes them nearly impossible to find. But here's an easy way to get the RSS feed for any YouTube user. Inspired by <https://eggfreckles.net/notes/youtube-rss/>
#!/usr/bin/env zsh -f
# Purpose: get the RSS feed for a YouTube page
# Inspired By: https://eggfreckles.net/notes/youtube-rss/
# Gist: https://gist.github.com/tjluoma/fdbc63ceb78a2aecd3d638fd18b6ec6e
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2020-01-17; updated 2021-01-10
# 2021-01-10 YouTube currently has both 'rssUrl' and
import React from "react";
import { Link } from "react-router-dom";
export function createResource(getPromise) {
let cache = {};
let inflight = {};
let errors = {};
function load(key) {
inflight[key] = getPromise(key)

The problem

When a MobileSafari keyboard-receing input (e.g. an input[type=text]) receives focus in Safari, the system will try to verify whether there is ample room to bring up the soft keyboard without needing to scroll. The amount of wiggle room needed for Safari to consider available scroll height "ample" seems to increase with every major iOS release (surely to work around the very real problem of focus being granted to inputs that are subsequently oscured by the keyboard).

However, for "app-ey" web sites that carefully place each text input in a relatively fixed layout, this can be a maddening arms of scooching up my content more and more with each iOS release to avoid awkward jutters every time the keyboard is shown (example video here. In practice, it seems like the input's scrollHeight can only really be about the equivalent of 15vh before you're likely to get an automated scrolling whiplash from the soft keyboard, which isn't much

@iamandrewluca
iamandrewluca / oss-tools.md
Last active May 24, 2024 08:20
Open source software tools