Skip to content

Instantly share code, notes, and snippets.

View balazsorban44's full-sized avatar
🌍
Coding from anywhere

Balázs Orbán balazsorban44

🌍
Coding from anywhere
View GitHub Profile
@lawrencecchen
lawrencecchen / $.ts
Last active April 11, 2024 04:23
next-auth with remix
// app/routes/api/auth/$.ts
import NextAuth from "~/lib/next-auth/index.server";
export const { action, loader } = NextAuth({
providers: [
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
}),
],
@orta
orta / rfc.md
Last active February 20, 2024 02:23
A proposal for improving TS2322 error messages

This is a work in progress. Please don't take this as something that will definitely happen, we all know what happens to well laid plans and I need to present it to the rest of the TypeScript team in order to figure out a lot of feasibility questions.

Intro

The examples in this PR assumes [CLI DX] Improve positioning of compiler error messaging info #45717 is merged

In 4.4, all diagnostic messages from TypeScript are treated the same, we have a massive .JSON file of ±2000 diagnostic messages which are used everywhere from compiler messages to CLI help. Aside from some simple string manipulation, these are effectively what we output for all error messages. I'd like to propose that we break this pattern, just for error TS2322.

TS2322 is our 'type x is not assignable to y' error, you'd see it for const str: string = 123 and I expect it is the most seen

@iDVB
iDVB / useScrollSpy.js
Created April 21, 2020 19:23
useScrollSpy similar to MUI docs https://bit.ly/3cArBBr
import { useState, useEffect, useRef, useCallback } from 'react';
import useThrottledOnScroll from './useThrottledOnScroll';
const useScrollSpy = ({ items = [], target = window } = {}) => {
const itemsWithNodeRef = useRef([]);
useEffect(() => {
itemsWithNodeRef.current = getItemsClient(items);
}, [items]);
const [activeState, setActiveState] = useState(null);
import { Machine, assign } from 'xstate';
import firebase from './firebase';
const chart = {
id: 'auth',
context: {
auth: null,
error: null,
loggedoutTime: null
},

Everything I Know About UI Routing

Definitions

  1. Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
    1. pathname - The "file/directory" portion of the URL, like invoices/123
    2. search - The stuff after ? in a URL like /assignments?showGrades=1.
    3. query - A parsed version of search, usually an object but not a standard browser feature.
    4. hash - The # portion of the URL. This is not available to servers in request.url so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things.
    5. state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
@gaearon
gaearon / MyResponsiveComponent.js
Created November 1, 2018 10:05
Examples from "Making Sense of React Hooks"
function MyResponsiveComponent() {
const width = useWindowWidth(); // Our custom Hook
return (
<p>Window width is {width}</p>
);
}
@bvaughn
bvaughn / index.md
Last active May 4, 2024 11:25
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@thebuilder
thebuilder / jest.config.js
Last active October 29, 2022 02:42
Use Jest Projects to run both JSDom and Node tests in the same project
module.exports = {
projects: [
{
displayName: 'dom',
testEnvironment: 'jsdom',
snapshotSerializers: ['enzyme-to-json/serializer'],
testMatch: ['**/__tests__/**/*.test.js?(x)']
},
{
displayName: 'node',
@dcasati
dcasati / export-kubeconfig-from-aks
Created February 6, 2018 15:30
Export KUBECONFIG from AKS
az aks get-credentials --resource-group k8s-demo-ss --name k8s-demo-cluster-ss --file kubeconfig-ss