Skip to content

Instantly share code, notes, and snippets.

View kikoanis's full-sized avatar
🏠
Working from home

Ali Hmer kikoanis

🏠
Working from home
View GitHub Profile
import path from 'path';
import { fileURLToPath } from 'url';
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import nextPlugin from '@next/eslint-plugin-next';
import eslintConfigPrettier from 'eslint-config-prettier';
import hooksPlugin from 'eslint-plugin-react-hooks';
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
@tanishqsh
tanishqsh / DOBPicker.tsx
Created July 3, 2023 03:54
DOB Calendar
/**
/DOBPicker.tsx
**/
'use client';
import * as React from 'react';
import { format, subYears } from 'date-fns';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
@gaearon
gaearon / 00-README-NEXT-SPA.md
Last active May 19, 2024 10:27
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Don't like Next? Here's how to do the same in Gatsby.

@richlander
richlander / modernizing-csharp9.md
Last active April 26, 2024 17:14
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";
@lesstif
lesstif / settings.json
Last active September 15, 2023 08:48
windows terminal settings json file for wsl2, wsl(Windows Subsystem For Linux)
// This file was initially generated by Windows Terminal 0.11.1191.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@dwighthouse
dwighthouse / ThisLikeRef.js
Created September 11, 2019 20:31
Using This-Like Ref Structure to Solve Hook State Updating and Function Reference Problems
import React, { memo, useCallback } from 'react';
import ChildComponent from './wherever/ChildComponent.js';
const updateChild = (props, childId, changes) => {
props.onUpdate({
type: 'childChanged',
childId: childId,
changes: changes,
});
};
@schettino
schettino / useUserReducer.ts
Created March 30, 2019 20:23
Better Reducers with React and Typescript 3.4
import { useReducer } from 'react'
export function updateName(name: string) {
return <const>{
type: 'UPDATE_NAME',
name
}
}
export function addPoints(points: number) {
@samsch
samsch / stop-using-jwts.md
Last active May 22, 2024 14:27
Stop using JWTs

Stop using JWTs!

TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.

If you've got a bit of time to watch a presentation on it, I highly recommend this talk: https://www.youtube.com/watch?v=pYeekwv3vC4 (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)

A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens: https://www.rdegges.com/2018/please-stop-using-local-storage/

The reason to avoid JWTs comes down to a couple different points:

  • The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active May 23, 2024 16:23
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@alexeychikk
alexeychikk / actions.js
Created December 27, 2017 11:27
Cancellation middleware for redux-axios-middleware
import {
CANCEL_ACTION_REQUESTS,
CANCEL_ALL_ACTION_REQUESTS
} from './constants';
export function cancelActionRequest(actionType) {
return { type: CANCEL_ACTION_REQUESTS, actionType };
}
export function cancelAllActionRequests() {