Skip to content

Instantly share code, notes, and snippets.

View sadeghbarati's full-sized avatar
🤨

Sadegh Barati sadeghbarati

🤨
  • Iran, Mashhad
  • 11:43 (UTC +03:30)
View GitHub Profile
@srestraj
srestraj / gsi-with-nuxt.md
Last active December 13, 2023 04:50
Integrate Google Sign-in and One-tap with Nuxt.js

Integrate Google Sign-in (Popup method) with Nuxt.js - Works in Incognito mode as well

Nuxt 3 version here.
Add GSI client in your nuxt.config.js
export default {
  ...
@DavidWells
DavidWells / github-proxy-client.js
Last active March 15, 2024 08:28
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@loilo
loilo / use-query-selector.js
Last active March 13, 2024 20:50
Vue useQuerySelector composable
import { readonly, ref, watch } from 'vue'
import { useMutationObserver } from '@vueuse/core'
export function useQuerySelector(selector, { root = document } = {}) {
selector = ref(selector)
root = ref(root)
const result = ref(null)
// Find first matching element inside a root element
@bluwy
bluwy / sequence.js
Last active March 29, 2022 03:42
Run Svelte preprocessors in the sequence they are declared
import { preprocess } from 'svelte/compiler'
/**
* @typedef {import("svelte/types/compiler/preprocess").PreprocessorGroup} PreprocessorGroup
* @param {PreprocessorGroup[]} preprocessors
* @returns {PreprocessorGroup[]}
*/
export function sequence(preprocessors) {
return preprocessors.map((preprocessor) => ({
markup({ content, filename }) {
@areknawo
areknawo / LazyHydrate.vue
Created August 13, 2021 11:18
Vue 3 lazy hydration component
<script lang="ts">
import { defineComponent, onMounted, PropType, ref, watch } from "vue";
type VoidFunction = () => void;
const isBrowser = () => {
return typeof window === "object";
};
export default defineComponent({
props: {
@eduardo-mior
eduardo-mior / disable-form-auto-complete.md
Last active April 1, 2024 15:59
How to disable HTML Input Autocomplete

Definitive guide → 6 ways to solve

I would very much like there to be a WEB standard for this, but unfortunately there is not!

I studied this for several days and gathered a lot of information and I will share it with you.

Before developing or using an internet hack you need to know that there are 2 types of Autocomplete. There is the autocomplete of the page and the autocomplete of the browser.

This is the global browser autocomplete. It appears whenever you define autocomplete="off" or when you define no autocomplete but define type="email" for example. The global autocomplete suggests emails you've used on other sites. The global autocomplete has a manage button at the bottom and can be disabled in the browser config. image

@CryogenicPlanet
CryogenicPlanet / .eslintrc
Created June 6, 2021 12:29
Typescript Mono Repo Guide
// .eslintrc
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"react-app",
"plugin:react/recommended",
@pom421
pom421 / form-next-ts-rhf-zod-demo.tsx
Last active December 22, 2023 16:28
Form with React Hook form and zod rules (Next.js page example)
// try it : https://codesandbox.io/s/sample-next-ts-rhf-zod-9ieev
import React from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
import type { FieldError } from "react-hook-form";
// JSON.stringify(error) will not work, because of circulare structure. So we need this helper.
@mogelbrod
mogelbrod / babel.config.js
Last active December 5, 2023 22:18
Prevent core-js polyfills of APIs that should be supported by IE11 for general use (incomplete list)
module.exports = {
presets: [
['@babel/preset-env', {
useBuiltIns: 'usage',
debug: false,
loose: true,
corejs: {
version: 3,
proposals: true,
},
@azu
azu / TypeScriptの設定の良し悪し.md
Last active April 1, 2024 10:23
TypeScriptの設定の良し悪し

tsconfig.json の設定についてのメモ書きです。

Node.jsのバージョンごとの設定

target は 変換後のコードのECMAScriptバージョンを指定する たとえば、Node.js 14はES2020をサポートしている。そのため、Node.js 14向けのコード(サーバなど)ならtarget: "ES2020"を指定することで、余計なTranspileが省かれててコードサイズや実行時間が最適化される。