Skip to content

Instantly share code, notes, and snippets.

View cgarrovillo's full-sized avatar
📈

Christian Garrovillo cgarrovillo

📈
View GitHub Profile
@cgarrovillo
cgarrovillo / check git diff under 400 lines.sh
Last active May 1, 2024 23:13
verify that the total insertions/deletions for both unstaged (tracked & untracked) and staged files are under 400 lines
git_diff_summary() {
# Check if the current directory is a git repository
git rev-parse --is-inside-work-tree > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Not a git repository."
return 1 # Exit the function if not in a git repository
fi
echo "Staged Changes:"
local last_line_staged=$(git diff --staged --stat | tail -n 1)
@cgarrovillo
cgarrovillo / expo install in monorepo.md
Created April 26, 2024 00:37
Installing dependencies by 'expo install' in a monorepo

apps/mobile/package.json

    "expo install": "npx expo install"

bash; from root

npm run "expo install" --workspace=mobile -- zustand
@cgarrovillo
cgarrovillo / useInterval.test.tsx
Last active March 22, 2024 17:10
useInterval with watched returns
import { renderHook } from "@testing-library/react";
import useInterval from "./useInterval";
describe("useInterval", () => {
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.clearAllTimers();
@cgarrovillo
cgarrovillo / useInterval.tsx
Created March 22, 2024 17:09
useInterval with watched returns
import { useEffect, useMemo, useRef } from "react";
type UseIntervalTypes = {
callback: () => void;
delay: number;
};
/**
* React lifecycle-aware implementation of setInterval.
* This allows for a quick implementation of setInterval in React without having to worry about cleanup.
@cgarrovillo
cgarrovillo / mkdir + cd in one command
Last active December 6, 2020 21:41
Add to shell configs (.zshrc or .bashrc)
mkdirc ()
{
mkdir -p -- "$1" &&
cd -P -- "$1"
}