Skip to content

Instantly share code, notes, and snippets.

View varun-nambiar's full-sized avatar
💭
<script>System.out.println("This is not javascript")</script>

Varun Nambiar varun-nambiar

💭
<script>System.out.println("This is not javascript")</script>
View GitHub Profile
@btoo
btoo / usePrevious.ts
Last active April 27, 2025 07:13
typescript type-safe version of usePrevious taken directly from the react docs https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
import { useRef, useEffect } from 'react';
/**
* a type-safe version of the `usePrevious` hook described here:
* @see {@link https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state}
*/
export function usePrevious<T>(
value: T,
): ReturnType<typeof useRef<T>>['current'] {
const ref = useRef<T>();
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active November 26, 2025 12:38
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {