Skip to content

Instantly share code, notes, and snippets.

View aholachek's full-sized avatar

Alex Holachek aholachek

View GitHub Profile
@aholachek
aholachek / challenges.md
Last active May 2, 2019 16:58
CSS Grid Challenges
@aholachek
aholachek / instructions.md
Last active January 29, 2020 15:43
Source-map-explorer workflow: View all bundles loaded in a certain entrypoint

1. Download Coverage Report

Create a coverage report to see which code was downloaded, and which code was actually used for a given entry point of your app. Download the report and put it in the top level directory of your project. Make sure it's named coverage.json.

2. Prepare script

Create this file in the top level directory of your project:

build-bundles.js

@aholachek
aholachek / coverage.json
Created February 3, 2020 17:28
Reddit coverage.json
This file has been truncated, but you can view the full file.
[
{
"url": "https://www.reddit.com/",
"ranges": [
{ "start": 0, "end": 99 },
{ "start": 447, "end": 629 },
{ "start": 655, "end": 1210 },
{ "start": 1221, "end": 1494 },
{ "start": 1505, "end": 1507 }
],

Here's a rough draft proposal for an extension to the animated component that can handle both simple and advanced FLIP use cases.

Example usage

1. Simplest example

Initiate a FLIP animation on a component by updating the flipKey prop.

Demo

Code

@aholachek
aholachek / useDeepEqualCallback.ts
Last active March 29, 2020 23:47
For the rare times when you need to do a deep object comparison in React's useCallback
import { useRef } from "react";
import cloneDeep from "lodash.clonedeep";
import isEqual from "lodash.isequal";
const useDeepEqualCallback = (callback: any, deps: any[]) => {
const callbackRef = useRef(callback);
const cachedDeps = useRef(cloneDeep(deps));
if (!isEqual(deps, cachedDeps.current)) {
callbackRef.current = callback;
cachedDeps.current = cloneDeep(deps);
@aholachek
aholachek / testUtils.ts
Last active April 7, 2020 18:29
mockFetch function for jest
export type FetchConfig = RequestInit & {
postman?: boolean;
method?: keyof typeof HTTPMethods;
body?: any;
root: string;
path?: string;
params?: Record<string, any>;
};
export interface Global {
@aholachek
aholachek / protect-yourself-on-the-web.md
Last active June 4, 2021 15:05
High impact, low-effort ways to protect yourself on the web

A Basic Guide to Protecting Yourself On the Web

Step One: Secure your passwords

How

Use a password manager and use different, complex passwords for every site. (The password manager will make it easy to generate and save new, secure passwords.) The one I use is OnePassword (paid plan).

Why

@aholachek
aholachek / README.md
Last active September 23, 2023 20:51
Calendar Day View Layout

##D3 Calendar Day View Layout

This script demonstrates a layout algorithm I developed for a day calendar view. The height and y-axis placement of each calendar item are solely determined by its start and end times, but the width and x-axis placement of each item is dependent on how many other items occur during the same time as it.

You can change the layout by adding items using the form to the left, or clicking on items to remove them.

###There are three main steps for the layout calculation: