Skip to content

Instantly share code, notes, and snippets.

@karlhorky
karlhorky / try-catch.ts
Last active October 19, 2022 23:43
Try-catch helper for promises and async/await
export default async function tryCatch<Data>(
promise: Promise<Data>,
): Promise<{ error: Error } | { data: Data }> {
try {
return { data: await promise };
} catch (error) {
return { error };
}
}
@sibelius
sibelius / LookingForTheFirstJob.md
Last active July 3, 2023 08:48
Looking for the First Job state

Looking for the First Job

Versão em Português

This is a very common state for people in college, people before/after a bootcamp, or people from another area.

The first job will be the hardest one to get, but it will get easier over time.

The interview will be harder than the job itself

@tricinel
tricinel / createIndex.ts
Created March 30, 2021 06:42
Creating a lunr index
import lunr from 'lunr';
import { pick, propEq, map, filter, prop } from 'ramda';
interface FieldConfigAttributes {
boost: number;
}
interface FieldConfig<T> {
name: keyof T;
store: boolean;
@sindresorhus
sindresorhus / esm-package.md
Last active June 16, 2024 19:05
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@ThePredators
ThePredators / readme-mde.md
Last active June 8, 2024 09:56
Setup Mobile Development Environment

⭐ Setup Mobile Development Environment

⚠️ The following configuration has been tested on Intel, M1 & M2 Ships ⚠️

Pre-requisit :

If you have any issues with macOS, or need anything related to it check this documentation

Install Xcode Command Line tools :

@progrium
progrium / README.md
Last active October 17, 2021 18:33
Large Type CLI utility for Mac in less than 80 lines of Go

largetype

largetype screenshot

Building

Note: For now, Apple Silicon users need to be set up for x86 mode

First, download Go or brew install go. Then, put largetype.go in a directory called largetype and from there run:

$ go mod init largetype
@claus
claus / _app.js
Created May 14, 2020 05:35
Restore scroll position after navigating via browser back/forward buttons in Next.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;
@Potherca
Potherca / solutions-stacks.csv
Last active May 20, 2024 19:57
Solution Stack Acronyms
Stack Name Stack Type Operating System / Platform Server Database Language or SDK Framework UI Message Bus / Queue
AMP Web (Backend) Apache MySQL / MariaDB Perl / PHP / Python
BAMP Web (Backend) BSD Apache MySQL / MariaDB Perl / PHP / Python
BAPP Web (Backend) BSD Apache PostgreSQL Perl / PHP / Python
BCHS Web (Backend) BSD SQLite httpd C
DAMP Web (Backend) Darwin Apache MySQL / MariaDB Perl / PHP / Python
ELK Time Series Data Logstash Elasticsearch Kibana
ELKB Time Series Data Logstash Elasticsearch Beats Kibana
FAMP Web (Backend) FreeBSD Apache MySQL / MariaDB Perl / PHP / Python
FWAP Web (Backend) Windows Apache Firebird Perl / PHP / Python
@swyxio
swyxio / Tailwindcssunreset.scss
Last active February 14, 2024 01:19
Tailwind CSS Un-Reset - un-reset Tailwind's Preflight CSS Reset so that autogenerated HTML looks consistent with the rest of your Tailwind site. - https://www.swyx.io/writing/tailwind-unreset
.unreset {
a {
@apply text-blue-700 underline;
}
p {
@apply my-4;
}
blockquote,
figure {
@slikts
slikts / react-memo-children.md
Last active June 16, 2024 14:24
Why using the `children` prop makes `React.memo()` not work

nelabs.dev

Why using the children prop makes React.memo() not work

I've recently ran into a pitfall of [React.memo()][memo] that seems generally overlooked; skimming over the top results in Google just finds it mentioned in passing in a [React issue][regit], but not in the [FAQ] or API [overview][react-api], and not in the articles that set out to explain React.memo() (at least the ones I looked at). The issue is specifically that nesting children defeats memoization, unless the children are just plain text. To give a simplified code example:

const Memoized = React.memo(({ children }) => (<div>{children}</div>));
// Won't ever re-render
<Memoized>bar</Memoized>
// Will re-render every time; the memoization does nothing