Skip to content

Instantly share code, notes, and snippets.

View whatif-dev's full-sized avatar

WhatIfDev whatif-dev

View GitHub Profile
@whatif-dev
whatif-dev / useTextSelection.ts
Created February 13, 2024 07:43 — forked from KristofferEriksson/useTextSelection.ts
A React Typescript hook that tracks user text selections & their screen positions
import { useEffect, useState } from "react";
type UseTextSelectionReturn = {
text: string;
rects: DOMRect[];
ranges: Range[];
selection: Selection | null;
};
const getRangesFromSelection = (selection: Selection): Range[] => {
@whatif-dev
whatif-dev / useSpeechToText.ts
Created February 13, 2024 07:49 — forked from KristofferEriksson/useSpeechToText.ts
An experimental React hook for real-time speech-to-text using the Web Speech API
import { useCallback, useEffect, useState } from "react";
// Define custom types for SpeechRecognition and SpeechRecognitionEvent
interface ISpeechRecognitionEvent extends Event {
results: SpeechRecognitionResultList;
resultIndex: number;
}
interface ISpeechRecognition extends EventTarget {
lang: string;
@whatif-dev
whatif-dev / useGesture.ts
Created February 13, 2024 07:49 — forked from KristofferEriksson/useGesture.ts
A custom React Typescript hook for advanced touch gestures in UI
import { useEffect, useRef } from "react";
type GestureType =
| "swipeUp"
| "swipeDown"
| "swipeLeft"
| "swipeRight"
| "tap"
| "pinch"
| "zoom";
@whatif-dev
whatif-dev / clx.go
Created April 27, 2024 01:39 — forked from Sh4yy/clx.go
Generate CLI commands for common tasks.
package main
import (
"context"
"errors"
"fmt"
"io"
"log"
"os"
"runtime"
@whatif-dev
whatif-dev / private_fork.md
Last active July 11, 2024 20:05 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

NEW WAY

  1. Go to this link.

  2. Insert the repo link to fork

  3. If you want, add the original repo as remote to fetch (potential) future changes. Make sure you also disable push on the remote (as you are not allowed to push to it anyway).

@whatif-dev
whatif-dev / postgres-cheatsheet.md
Last active July 13, 2024 02:20 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)