Skip to content

Instantly share code, notes, and snippets.

View mhsattarian's full-sized avatar
🎯
Focusing

Mohammad H. Sattarian mhsattarian

🎯
Focusing
View GitHub Profile
@inorganik
inorganik / app.js
Last active March 31, 2024 21:13
Using CountUp.js in React
import { useEffect, useRef } from 'react'
// playground: https://stackblitz.com/edit/react-ts-nv5fxe?file=App.tsx
export default function App() {
// create a ref and declare an instance for each countUp animation
const countupRef = useRef(null);
let countUpAnim;
@mahmoud-eskandari
mahmoud-eskandari / README.md
Last active February 28, 2024 00:27
Install v2ray on Bridge:(Ubuntu +18 via systemd) - Upstream (Ubuntu +18/CentOS +7 via docker)

پنل x-ui

پنل تحت وب مدیریت V2ray و ساخت کاربر و مدیریت سرور

mkdir x-ui && cd x-ui
docker run -itd --network=host \
    -v $PWD/db/:/etc/x-ui/ \
 -v $PWD/cert/:/root/cert/ \
@marcus-at-localhost
marcus-at-localhost / 1info.md
Last active October 30, 2022 10:40
[JSON Path with Alpine CSP build in Postman Visualizer] Query JSON Response with JSON Path

JSON Path with Alpine.js CSP build in Postman Visualizer

Query JSON Response with JSON Path

2022-04-30_13-58-39_2

To work more easily with Postman JSON results, I implemented JSONPath in a Postman Visualizer, to query the results.

JSONPath is to JSON what XPath is to XML, and it helps to dig into large nested objects and get what you are looking for faster.

First I was using just a jQuery version that can be found in the examples and that worked just fine. (JSONpath Visualizer | Postman Team Collections | Postman API Network)

@steveruizok
steveruizok / findSnapPoints.ts
Last active June 23, 2023 01:50
Find the snap points between a bounding box and several other bounding boxes.
interface TLBoundsWithCenter {
minX: number
midX: number
maxX: number
minY: number
midY: number
maxY: number
width: number
height: number
}
@idleberg
idleberg / vscode-macos-context-menu.md
Last active May 1, 2024 12:01
“Open in Visual Studio Code” in macOS context-menu

Open in Visual Studio Code

  • Open Automator
  • Create a new document
  • Select Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
    • your default shell should already be selected, otherwise use /bin/zsh for macOS 10.15 (”Catalina”) or later
    • older versions of macOS use /bin/bash
  • if you're using something else, you probably know what to do 😉
@sindresorhus
sindresorhus / esm-package.md
Last active May 4, 2024 15:48
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 May 1, 2024 15:06
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();