Skip to content

Instantly share code, notes, and snippets.

@4r7ur-sid
4r7ur-sid / venv.sh
Last active November 9, 2024 17:58
Oh My ZSH. Automatically Turn ON/Off Virtual Environment
# Function to activate virtual environment
function auto_activate_env() {
# Check for the presence of your custom environment file, e.g., `.venvfile`
if [ -f ".venvfile" ]; then
# Read the full path to the activate script from .venvfile
ENV_PATH=$(cat .venvfile)
if [ -f "$ENV_PATH" ]; then
# Check if already activated to prevent redundant activations
if [[ "$VIRTUAL_ENV" != "$(dirname "$ENV_PATH")" ]]; then
source "$ENV_PATH"
@4r7ur-sid
4r7ur-sid / checkEmail.js
Created November 10, 2022 06:09
JavaScript | Function to check if email is valid and cleanup if required
/*
This function checks if the email is valid and return the email if it is valid or return false if it is not valid
If covers all the modern email formats and top level domains.
*/
const checkEmail = (email, cleanEmail = false) => {
const cleanUp = () => {
// Removing all spaces from the email
email = email.replace(/\s/g, '');
@4r7ur-sid
4r7ur-sid / share.js
Created October 21, 2022 06:03
JavaScript | Function For Native Sharing on Mobile and Desktop
const _share = (url,title,text)=>{
// Check if native share is supported
if(navigator.share){
navigator.share({
url,
title,
text
})
.then(()=>{
// Analytics event for share