Skip to content

Instantly share code, notes, and snippets.

View pH-7's full-sized avatar
:octocat:
💡Creative Engineer 🚀 Enjoying Learning New Exciting Things! 😋 =>My Way of Life 🏝

♚ PH⑦ de Soria™♛ pH-7

:octocat:
💡Creative Engineer 🚀 Enjoying Learning New Exciting Things! 😋 =>My Way of Life 🏝
View GitHub Profile
@pH-7
pH-7 / LineBreak.tsx
Last active November 10, 2024 21:45
React Native Line Break component - Add easily line breaks in your React Native app
/**
* (c) 2024 Pierre-Henry Soria.
*/
import { StyleSheet, View, ViewStyle, DimensionValue } from 'react-native';
type LineBreakProps = {
width?: DimensionValue;
color?: string;
style?: ViewStyle;
};
@pH-7
pH-7 / keybindings.json
Last active August 22, 2024 07:30
Productivity Add Custom VS Code Keybindings. Move Cursor Up/Down by 2 Lines
[
{
"key": "alt+up",
"command": "cursorMove",
"when": "textInputFocus",
"args": {
"to": "up",
"by": "line",
"value": 2
}
@pH-7
pH-7 / ai-video.ts
Created July 1, 2024 12:15
Generate AI videos from a given image using Neon DB, Pinecone, and Replicate
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();
@pH-7
pH-7 / PhoneLinkComponent.tsx
Created June 9, 2024 01:58
React Native PhoneLink component. e.g. <PhoneLink phoneNumber="+442011145678" />
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}`);
@pH-7
pH-7 / .tmux.conf
Created June 3, 2024 12:28
My tmux conf file ~/.config/tmux/tmux.conf
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
run '~/.tmux/plugins/tpm/tpm'
@pH-7
pH-7 / WarningLeaveTab.tsx
Last active September 28, 2024 15:18
Show warning message when a user attempts to leave the tab (the webpage)
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}
@pH-7
pH-7 / retry.ts
Last active May 15, 2024 14:54
Retry - A generic retry function (handy for various use cases)
/**
* 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) {
@pH-7
pH-7 / fonts-coding-vs-code.md
Last active June 10, 2024 04:28
My favorite fonts for convenient coding on VS Code

Best fonts for your IDE

  1. Space Mono (my favorite one)
  2. Fira Code (my second favorite one 😄)
  3. MonoLisa
  4. Inconsolata
  5. Apercu Mono
  6. Input Mono
  7. Gintronic
@pH-7
pH-7 / get-mac-finder-preferences.md
Last active April 25, 2024 17:23
Copy Mac Finder preferences to another Mac

Apple's iCloud isn't able to sync the Finder preferences. However, you can copy/paste the following two plist files to your new Mac.

Copy the following two files to your other Mac computer

~/Library/Preferences/com.apple.dock.plist
~/Library/Preferences/com.apple.finder.plist
@pH-7
pH-7 / .vimrc
Last active January 29, 2024 12:07
My ~/.vimrc configuration file
syntax on