Skip to content

Instantly share code, notes, and snippets.

View letelete's full-sized avatar
:fishsticks:
hackin’ around

Bruno Kawka letelete

:fishsticks:
hackin’ around
View GitHub Profile
@letelete
letelete / build-path.ts
Last active March 19, 2025 11:45
Builds a path utility that allows replacing parameters in a given path template.
type PathParams<T extends string> =
T extends `${infer _}:${infer Param}/${infer Rest}`
? { [K in keyof PathParams<Rest> | Param]: string }
: T extends `${infer _}:${infer Param}`
? Record<Param, string>
: void;
/**
* Builds a path utility that allows replacing parameters in a given path template.
*
@letelete
letelete / use-schedule.ts
Last active March 8, 2025 05:03
A hook for scheduling function executions with deduplication and priority management. Requires: https://usehooks-ts.com/react-hook/use-unmount.
import { useCallback, useMemo, useRef } from 'react';
import { useUnmount } from '~lib/hooks/use-unmount';
import type { VoidFn } from '~lib/utils/types';
interface ScheduleOptions {
tag?: string;
}
interface ScheduleOnceOptions {
@letelete
letelete / recruitee-scrapper.js
Last active October 1, 2024 09:47
Recruitee offer kanban board scrapper.
/**
* @description Preloads all candidates belonging to specified tags, parses coderbyte report url from candidate notes, reads coderbyte data, and transforms results into readable CSV file (by default).
*
* @usage
* 1. Fill missing session tokens (copy from request headers on the recruitee/coderbyte page).
* 2. Paste the script into console on the recruitee offer page.
* 3. File with specified `output` parameters will be downloaded onto your machine.
*
*/
(async () => {
@letelete
letelete / README.md
Last active September 1, 2024 22:08
This Python script is designed to automate the process of refactoring React code in a project by replacing all occurrences of named imports from 'react' with equivalent usage of the default React import using dot notation. This is particularly useful for developers who wish to standardize their codebase to consistently use React.<name> syntax fo…

Replace react imports

This Python script is designed to automate the process of refactoring React code in a project by replacing all occurrences of named imports from 'react' with equivalent usage of the default React import using dot notation. This is particularly useful for developers who wish to standardize their codebase to consistently use React. syntax for accessing React functions and components.

Usage

  $ python replace-react-imports.py <ROOT_DIRECTORY_OF_YOUR_REACT_PROJECT>
$ python replace-react-imports.py src
@letelete
letelete / slack-members-scrapper.js
Last active October 1, 2024 10:28
Slack members scrapper
/**
* Slack members scrapper.
*
* Downloads a .csv file with members details.
*
* 1. Open /people on slack webapp: https://app.slack.com/client/<WORKSPACE_ID>/people
* 2. Paste it into the console
*/
(() => {
class CSVTransformer {
@letelete
letelete / process_videos.sh
Last active June 24, 2024 12:25
For each .mp4 file, generate a compressed .webm file, and a .webp thumbnail
#! /usr/bin/env bash
COLOR_RED="\e[31m"
COLOR_GREEN="\e[32m"
COLOR_YELLOW="\e[33m"
COLOR_END="\e[0m"
PATH_VIDEOS_DIR="./public/videos"
BASE_FILE_EXT="mp4"
@letelete
letelete / nextjs-image-preloader.tsx
Last active May 5, 2024 12:04
Preload all images. Insert them to the DOM, and hide from the user. Avoid unnecessary re-renders with `memo`.
import Image from 'next/image';
import { memo } from 'react';
import { ImageItem } from '~lib/images/provider';
export interface ImagesPreloaderProps {
items: ImageItem[];
width?: number;
height?: number;
}
@letelete
letelete / playlist.js
Last active August 25, 2022 13:14
Create youtube playlist from video urls in the DOM
const getPlaylistUrl = (firstId, comaSeparatedIds) => {
if (typeof comaSeparatedIds !== 'string') {
throw new Error(
'Ids must be a string of concatenated video ids separated with comma character'
);
}
return `https://www.youtube.com/embed/${firstId}?rel=0&version=3&playlist=${comaSeparatedIds}`;
};
const createPlaylistFromIds = (ids) => {
@letelete
letelete / vimadd.sh
Created November 14, 2020 22:58
Adds a vim plugin inside of the .vim/pack/plugins/start/<plugin-name> path and makes it a submodule to easily keep your plugins synced with the github repo initialized inside of the .vim/pack folder.
# $1 - A GitHub plugin's repository URL with a '.git' suffix.
vimadd () {
BUNDLE="" && [[ $1 =~ '\/(.+)\.git' ]] && BUNDLE=$match[1] || echo "Cannot match a repo name"
[[ -z "$BUNDLE" ]] && return 0
cd ~/.vim/pack
git submodule add $1 plugins/start/$BUNDLE
git submodule update --remote --merge
git commit -m "Add $BUNDLE plugin"
git push origin main
}