Skip to content

Instantly share code, notes, and snippets.

@everdimension
everdimension / python-env-setup.md
Created August 14, 2023 07:56
python3 on ubuntu 20
@everdimension
everdimension / rdns.md
Created August 8, 2023 21:10
Reverse-DNS reference

Reverse Domain Notation

The Reverse-DNS convention implies that the value should start with a reversed DNS domain name controlled by the author of the applicatoin.
The domain name should be followed by a subdomain or a product name. Example: com.example.MyProductName.

References:

@everdimension
everdimension / promiseAnyFallback.ts
Last active May 17, 2023 12:07
Implementation of Promise.any using Promise.all
/**
* As of writing, Promise.any is Stage 4 (Finished)
* This code is just a fun reminder of how Promise.any can be implemented using Promise.all
* Proposal: https://github.com/tc39/proposal-promise-any
*/
class AggregateErrorFallback extends Error {
errors: Array<Error>;
constructor(message: string, errors: Array<Error>) {
super(message);
@everdimension
everdimension / JsSpinner.tsx
Created October 7, 2022 15:22
A javascript spinner used to visually help detect freezes in the UI
function JsSpinner() {
const ref = useRef<HTMLDivElement | null>(null);
useEffect(() => {
let deg = 0;
let id = 0;
function rotate() {
id = requestAnimationFrame(() => {
ref.current.style.transform = `rotate(${(deg += 2) % 360}deg)`;
rotate();
});
// just a reminder of a nice API for a <Script /> component,
// reference: https://nextjs.org/docs/basic-features/script#executing-code-after-mounting-onready
import { useRef } from 'react'
import Script from 'next/script'
export function Home() {
const mapRef = useRef()
return (
<>
import { useEffect, useMemo } from 'react';
import debounce from 'lodash/debounce';
export function useDebouncedCallback(
callback: (...args: any) => any,
delay: number,
) {
const debouncedCallback = useMemo(
() => debounce(callback, delay),
[callback, delay],
@everdimension
everdimension / useStaleQuery.ts
Created July 20, 2022 11:52
A helper on top of useQuery hook
import { useCallback, useState } from 'react';
import { useQuery } from 'react-query';
import type {
QueryKey,
QueryFunction,
UseQueryOptions,
UseQueryResult,
} from 'react-query';
/**

0x05baa67af0201cf90f07237b4fcd77ff375a391f705d31a007802a92c480a950

@everdimension
everdimension / git-rebase-onto.sh
Created May 20, 2020 17:23
"git rebase --onto" — used to rebase only latest (or several latest) commits onto a new branch
# This is just a note to self
git rebase --onto <base-branch> <current-branch>~ <current-branch>
# e.g. git rebase --onto master feature/something~ feature/something
# it's important here to use branch name and not other commit id.
# Can't use "HEAD" instead of "feature/something" ¯\_(ツ)_/¯
@everdimension
everdimension / gist:590395dd20831f9a787101c4c3084085
Created May 20, 2020 17:23
"git rebase --onto" — used to rebase only latest (or several latest) commits onto a new branch
# This is just a note to self
git rebase --onto <base-branch> <current-branch>~ <current-branch>
# e.g. git rebase --onto master feature/something~ feature/something
# it's important here to use branch name and not other commit id.
# Can't use "HEAD" instead of "feature/something" ¯\_(ツ)_/¯