Skip to content

Instantly share code, notes, and snippets.

View snehesht's full-sized avatar

Snehesh snehesht

View GitHub Profile
@snehesht
snehesht / uuidv7.ts
Last active June 20, 2024 02:51
UUID v7
// https://antonz.org/uuidv7/#javascript
export function uuidv7(): string {
// random bytes
const value = new Uint8Array(16);
crypto.getRandomValues(value);
// current timestamp in ms
const timestamp = BigInt(Date.now());
// timestamp
@snehesht
snehesht / RemoveYTShortVideos.js
Created August 15, 2023 04:43 — forked from Shubhang/RemoveYTShortVideos.js
Remove short videos from youtube recommendations
// Open YouTube: Navigate to the YouTube homepage.
// Open Developer Console: Press F12 or right-click anywhere on the page and select "Inspect" to open the developer console. Then, click on the "Console" tab.
// Paste and Run the Script: Copy and paste the following code into the console, then press Enter.
// This code searches for video duration elements on the page and hides the corresponding video if its duration is less than 10 minutes.
// Repeat as Needed: If you scroll down and more videos load, or if you navigate to a different page, you'll need to run the script again.
@snehesht
snehesht / clarify-error.ts
Created March 3, 2022 04:45
Clarify Error Stacks
function splitStack(err: Error | string): Array<string> {
if (typeof err === 'string') return [`Error: ${err}`];
else if (err.stack) return err.stack.split('\n');
else return [`${err.name}: ${err.message}`];
}
export = function clarify(innerError: Error | string, message: string): Error {
const outerError = new Error(message);
const outerStack = outerError.stack!.split('\n');
outerStack.splice(1, 1);
@snehesht
snehesht / install.sh
Created February 26, 2022 10:27
Install Wireguard
#!/bin/bash
# Secure WireGuard server installer
# https://github.com/angristan/wireguard-install
RED='\033[0;31m'
ORANGE='\033[0;33m'
NC='\033[0m'
function isRoot() {
@snehesht
snehesht / esm-package.md
Created September 14, 2021 03:43 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from 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.

Inlets free binary

@snehesht
snehesht / terraform-kubernetes-docker-macos.md
Created June 24, 2021 21:42 — forked from ivaravko/terraform-kubernetes-docker-macos.md
The simple Terraform and Kubernetes with Docker on macOS

If you'd like to experiment with Terraform and Kubernetes on macOS locally, a great provider for doing so is the Kubernetes provider. You can get set up in a few simple steps, like so:

1. Install Docker

Install Docker for Mac if you have not already.