Skip to content

Instantly share code, notes, and snippets.

View mhsattarian's full-sized avatar
🎯
Focusing

Mohammad H. Sattarian mhsattarian

🎯
Focusing
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active April 26, 2025 12:29
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.
@codemzy
codemzy / useDelay.js
Created February 25, 2021 11:03
React useDelay hook - to avoid flash of loading content
import React from "react";
// delay a state change (used for loading or waiting for async to avoid flash of loading state)
export default function useDelay(initial, { delay = 300, delayedValue = true, minDuration = 700 }) {
const [state, setState] = React.useState(initial);
const [change, setChange] = React.useState(initial);
const end = React.useRef(0);
React.useEffect(() => {
let timer;
@bluewalk
bluewalk / GetNordVPNWireGuardDetails.md
Last active April 29, 2025 08:31
Getting NordVPN WireGuard details

About

Instructions to obtain WireGuard details of your NordVPN account. These can be used to setup a WireGuard tunnel on your router to NordVPN.

Source: https://forum.gl-inet.com/t/configure-wireguard-client-to-connect-to-nordvpn-servers/10422/27

Prerequisites

If you have any linux machine, use that or install a vm if you don't have one.

Get their official linux app installed. Make sure you have wireguard installed too. And set the used technology to Nordlynx by running nordvpn set technology nordlynx

@Jack-Works
Jack-Works / 2018.js
Last active March 1, 2024 02:23
cRAzY eSnEXt (*all* proposals mixed in)
#! Aaaaaaaaaaa this is JS!!!
// https://github.com/tc39/proposal-hashbang
// This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics
// Enjoy!!!
// Created at Nov 23, 2018
for await(const x of (new A // https://github.com/tc39/proposal-pipeline-operator
|> do { // https://github.com/tc39/proposal-do-expressions
case(?) { // https://github.com/tc39/proposal-pattern-matching
when {val}: class {
@gaearon
gaearon / Classes.js
Created May 27, 2020 17:38
Beneath Classes: Prototypes
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
@bergmannjg
bergmannjg / rearct-native-app-in-wsl2.md
Last active April 15, 2025 09:32
Building a react native app in WSL2
import React, { Component } from 'react';
import WaveSurfer from 'wavesurfer.js';
import { WaveformContianer, Wave, PlayButton } from './Waveform.styled';
class Waveform extends Component {
state = {
playing: false,
};
@farbod-s
farbod-s / fix_mac_app.sh
Last active April 12, 2025 11:58
How to Fix App “is damaged and can’t be opened. You should move it to the Trash” Error on Mac
# Bypass MacOS Gatekeeper
#------------------------
#usage: xattr [-l] [-r] [-s] [-v] [-x] file [file ...]
# xattr -p [-l] [-r] [-s] [-v] [-x] attr_name file [file ...]
# xattr -w [-r] [-s] [-x] attr_name attr_value file [file ...]
# xattr -d [-r] [-s] attr_name file [file ...]
# xattr -c [-r] [-s] file [file ...]
@CSTDev
CSTDev / auto-increment-version.sh
Last active October 23, 2024 23:42
Script that will find the last Git Tag and increment it. It will only increment when the latest commit does not already have a tag. By default it increments the patch number, you can tell it to change the major or minor versions by adding #major or #minor to the commit message.
#!/bin/bash
#get highest tag number
VERSION=`git describe --abbrev=0 --tags`
#replace . with space so can split into an array
VERSION_BITS=(${VERSION//./ })
#get number parts and increase last one by 1
VNUM1=${VERSION_BITS[0]}
@bvaughn
bvaughn / index.md
Last active April 17, 2025 15:47
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.