Skip to content

Instantly share code, notes, and snippets.

View MakChan's full-sized avatar

Mayank Chauhan MakChan

  • Berlin
  • 17:50 (UTC +02:00)
View GitHub Profile
@MichaelDimmitt
MichaelDimmitt / bash-helpers-for-jest.md
Last active April 8, 2024 11:20
bash helpers for jest

Identify what jest files have failing tests:

yarn test --maxWorkers=50% 2>&1 | grep FAIL | sort -u

How to find tests that take longer than 400ms

yarn test --testTimeout=400 2>&1 | grep FAIL

Some of these tests may take some time as they have user interaction.

import React from "react";
import { View, SafeAreaView, Text, Dimensions } from "react-native";
import Animated, {
useSharedValue,
useAnimatedStyle,
useAnimatedScrollHandler,
interpolate,
interpolateColor,
Extrapolate,
} from "react-native-reanimated";
// TODO: make `pages` optional and measure the div when unspecified, this will
// allow more normal document flow and make it easier to do both mobile and
// desktop.
import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
Seven different types of CSS attribute selectors
// This attribute exists on the element
[value]
// This attribute has a specific value of cool
[value='cool']
// This attribute value contains the word cool somewhere in it
[value*='cool']
@seeliang
seeliang / lint-only-changed-files.MD
Last active April 10, 2024 09:44
How to lint only changed files?

find out the differences

use git diff to generate file list

git diff --name-only master

limited to certain file types

add ext filter

@ireade
ireade / sw.js
Last active October 7, 2023 20:56
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@augbog
augbog / .Frontend Technical Interview Prep.md
Last active March 4, 2024 16:25
Frontend Technical Interview Prep: A study guide of things I constantly re-review when interviewing for frontend.

Frontend Technical Interview Prep

EDIT: Well this has been linked now so just an FYI this is still TBD. Feel free to comment if you have suggestions for improvements. Also here is an unrolled Twitter thread of a lot of the tips I talk about on here.

I've been doing frontend for a while now and one thing that really gripes me is the interview. I think the breadth of knowledge of a "Frontend Engineer" has been so poorly defined that people really just expected you to know everything. Many companies have made this a hybrid role. The Web is massive and there are many MANY things to know. Some of these things are just facts that you learn and others are things you really have to understand.

Every time I interview, I go over the same stuff. I wanted to create a gist of the TL;DR things that would jog my memory and hopefully yours too.

Lots of these things are real things I've been asked that caught me off guard. It's nice to have something you ca

@sunel
sunel / icon.js
Created September 21, 2018 09:17
// This icon file is generated by build/generateIcons.ts
// tslint:disable
export { default as AccountBookFill } from '@ant-design/icons/lib/fill/AccountBookFill';
export { default as AlertFill } from '@ant-design/icons/lib/fill/AlertFill';
export { default as AlipayCircleFill } from '@ant-design/icons/lib/fill/AlipayCircleFill';
export { default as AlipaySquareFill } from '@ant-design/icons/lib/fill/AlipaySquareFill';
export { default as AliwangwangFill } from '@ant-design/icons/lib/fill/AliwangwangFill';
export { default as AmazonCircleFill } from '@ant-design/icons/lib/fill/AmazonCircleFill';
export { default as AmazonSquareFill } from '@ant-design/icons/lib/fill/AmazonSquareFill';
export { default as ApiFill } from '@ant-design/icons/lib/fill/ApiFill';