Skip to content

Instantly share code, notes, and snippets.

@webbower
webbower / CSS for <sup> and <sub>
Created July 9, 2021 17:03 — forked from unruthless/CSS for <sup> and <sub>
CSS for <sub> and <sup>
sub, sup {
/* Specified in % so that the sup/sup is the
right size relative to the surrounding text */
font-size: 75%;
/* Zero out the line-height so that it doesn't
interfere with the positioning that follows */
line-height: 0;
/* Where the magic happens: makes all browsers position
@webbower
webbower / multi-var-set.js
Created July 2, 2021 17:16
HTML/CSS/JS Patterns
// Option 1
let var1, var2, var3;
if (someCondition) {
var1 = 'value1';
var2 = 'value2';
var3 = 'value3';
} else {
var1 = "other1";
var2 = "other2";
var3 = "other3";
@webbower
webbower / useConstant.js
Last active November 1, 2023 17:56
Custom hooks
import { useState, useRef } from 'react';
// Can't use React State because setting the constant to a function will execute that function in `useState`
// const useConstant = value => useState(value)[0];
const useConstant = value => useRef(value).current;
const myConst = useConstant('foo');
@webbower
webbower / rally-btree-serialize-post-interview.js
Last active July 9, 2020 00:00
Rally Binary tree question
//// POST INTERVIEW VERSION
// NOTE Rado, Yi: I took the code where I left off and got it working in this second Gist file. It's probably not
// the most elegant solution, but it works. The code as of the end of the interview is in the other Gist.
// Given a binary tree, how would you serialize it into a string?
//Example input
var input = {
value: "a",
left: {
@webbower
webbower / interview-coderpad.js
Last active March 4, 2024 01:06
Interviewing utilities
const { isEqual } = require('lodash');
const { bold, yellow, red, green } = require('chalk');
/**
* List of test outcomes
* @type {[('PASS' | 'FAIL'), string][]}
*/
const outcomes = [];
/**
@webbower
webbower / ducks-module-tmpl.js
Last active May 4, 2020 19:16
Template for a Redux Ducks module
const prop = key => obj => obj[key];
// Action Types
const MY_ACTION = '{my}-app/{module}/MY_ACTION';
// Action Creators
export const myAction = (value) => ({
type: MY_ACTION,
payload: value,
});
<html lang="en">
<head>
<meta charset="UTF-8">
<title>a11y for HTML</title>
<style>
/**
* Visually hide an element, but leave it available for screen readers
* @link https://github.com/h5bp/html5-boilerplate/blob/master/dist/css/main.css
* @link http://snook.ca/archives/html_and_css/hiding-content-for-accessibility
@webbower
webbower / package.json
Last active May 1, 2020 19:32
Simple, composable, instanced-enabled model factories
{
"name": "simple-model",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {},
"scripts": {
"start": "watch 'yarn run test' src",
"test": "tape -r esm src/*.test.js"
},
@webbower
webbower / extract-error-data.js
Created November 9, 2019 02:06
Extract data from error objects for serialization since Error instances are weirdly finicky and not straightforward to pull data from
const builtInErrorTypes = [
Error,
EvalError,
RangeError,
ReferenceError,
SyntaxError,
TypeError,
URIError,
];
@webbower
webbower / asciimoji.txt
Last active February 21, 2022 01:57
ASCII Emoji Reference
Shrug ¯\_(ツ)_/¯
Googley shrug ¯\(º_o)/¯
Flip all tables ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
Reset table ┬─┬ ノ( ゜-゜ノ)
Cthulhu /|\(;,;)/|\