This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, RefObject } from 'react'; | |
/** | |
* Custom hook to handle click outside events for modals and dropdowns | |
* @param ref - Reference to the element to detect clicks outside of | |
* @param handler - Function to call when click outside is detected | |
* @param enabled - Whether the click outside detection is enabled (default: true) | |
*/ | |
export const useClickOutside = ( | |
ref: RefObject<HTMLElement>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Convert text to lowercase. | |
## | |
to_lowercase <- function(input_text) { | |
# Check if input is character | |
if (!is.character(input_text)) { | |
stop("Input must be a character string") | |
} | |
# Convert to lowercase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Alias | |
alias vi="nvim" | |
alias c="clear" | |
alias push="git push origin head" | |
alias pull="git pull" | |
alias amend="git amend" | |
alias gi="git" | |
alias g="git" | |
alias gp="git push" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* (c) 2024 Pierre-Henry Soria. | |
*/ | |
import { StyleSheet, View, ViewStyle, DimensionValue } from 'react-native'; | |
type LineBreakProps = { | |
width?: DimensionValue; | |
color?: string; | |
style?: ViewStyle; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"key": "alt+up", | |
"command": "cursorMove", | |
"when": "textInputFocus", | |
"args": { | |
"to": "up", | |
"by": "line", | |
"value": 2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Client } from 'pg'; | |
import { PineconeClient } from '@pinecone-database/pinecone'; | |
import Replicate from 'replicate'; | |
// Initialize clients | |
const neonClient = new Client({ | |
connectionString: 'your_neon_connection_string' | |
}); | |
const pinecone = new PineconeClient(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, TouchableOpacity, Linking } from 'react-native'; | |
interface PhoneLinkProps { | |
phoneNumber: string; | |
} | |
export const PhoneLink: React.FC<PhoneLinkProps> = ({ phoneNumber }) => { | |
const handlePress = () => { | |
Linking.openURL(`tel:${phoneNumber}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g @plugin 'tmux-plugins/tpm' | |
set -g @plugin 'tmux-plugins/tmux-sensible' | |
run '~/.tmux/plugins/tpm/tpm' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useCallback } from 'react'; | |
interface LeaveBrowserWarningProps { | |
shouldWarn: boolean; | |
} | |
/** | |
* Component that displays a warning message when the user attempts to leave the page. | |
* @param {LeaveBrowserWarningProps} props - The component props | |
* @returns {null} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A generic retry function (handy for various use cases). | |
*/ | |
const retry = async <T>(fn: () => Promise<T>, maxRetries = 3, delay = 1000): Promise<T> => { | |
let retries = 0; | |
while (retries < maxRetries) { | |
try { | |
return await fn(); | |
} catch (error) { |
NewerOlder