Skip to content

Instantly share code, notes, and snippets.

View codebycarlos's full-sized avatar
🚢
Shipping

Carlos Vieira codebycarlos

🚢
Shipping
View GitHub Profile
@codebycarlos
codebycarlos / stats.py
Last active June 10, 2024 15:14
stats
"""
This script fetches and processes GitHub repository statistics.
- Fetches contributor statistics and pull requests from a specified GitHub repo
- Aggregates data by quarter and author
- Saves the aggregated data to a CSV file
- Saves raw data to a JSON file for troubleshooting
Functions:
- get_repo_stats: Fetches contributor statistics from GitHub
@codebycarlos
codebycarlos / debounce.ts
Created February 20, 2024 09:56
debounce
/**
* Creates a debounced function that delays invoking `func` only for subsequent
* calls within the `debounceDelayMs` period after the first call.
*
* - `func`: Function to debounce. Can be asynchronous.
* - `debounceDelayMs`: Milliseconds to delay subsequent calls.
* - Returns: A function returning a promise with `func`'s result.
*
* The first call to the debounced function is executed immediately, while
* subsequent calls within the `debounceDelayMs` period are debounced.
@codebycarlos
codebycarlos / withPreventDefault.ts
Created January 29, 2024 19:10
withPreventDefault
/**
* A higher-order function that wraps a given function with a call to
* `preventDefault` on the event.
*/
export function withPreventDefault<T extends (...args: any[]) => any>(
originalFunction: T
) {
return function (...args: Parameters<T>): ReturnType<T> {
const event = args[0];
@codebycarlos
codebycarlos / connectRouter.tsx
Last active May 17, 2024 15:48
connectRouter
import type { ReactElement, ComponentType } from "react";
import { useLocation, useNavigate, useParams } from "react-router-dom";
export type Router = {
location: ReturnType<typeof useLocation>;
navigate: ReturnType<typeof useNavigate>;
params: ReturnType<typeof useParams>;
};