Skip to content

Instantly share code, notes, and snippets.

View kuldp18's full-sized avatar
:shipit:
Something's happening...

Kuldeep Solanki kuldp18

:shipit:
Something's happening...
View GitHub Profile
@kuldp18
kuldp18 / react-native.txt
Created July 7, 2024 10:04
Fixes to avoid errors while building react native apps
// add following in .eslintrc.js
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
// in android\gradle\wrapper\gradle-wrapper.properties
@kuldp18
kuldp18 / cloudinary.js
Created June 5, 2024 12:24
simple cloudinary util
import { v2 as cloudinary } from 'cloudinary';
import fs from 'fs';
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});
const uploadToCloudinary = async (localFilePath) => {
@kuldp18
kuldp18 / mp3.txt
Created May 19, 2024 11:19
yt-dlp one liner to download high quality mp3 of a youtube video
yt-dlp -x --audio-format mp3 --extract-audio --audio-quality 0 video_url
@kuldp18
kuldp18 / smol.js
Created February 27, 2024 12:01
smollest js framework that can do state management
const $ = (selector) => {
if (!selector || typeof selector !== "string") {
return;
}
const els = document.querySelectorAll(selector);
if (els.length > 1) {
return els;
} else if (els.length === 1) {
return els[0];
@kuldp18
kuldp18 / captions_init.py
Created February 16, 2024 17:32
Generate txt files for each image in a dir and add some initial caption text to each.
import os
import argparse
def generate_text_files(directory, init_text):
# Create a list of image files in the directory
image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp']
image_files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f)) and os.path.splitext(f)[1].lower() in image_extensions]
# Iterate through the image files
for image_file in image_files:
@kuldp18
kuldp18 / getRandomNumber.js
Created September 20, 2023 11:27
generate a random number on a specific range in javascript
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@kuldp18
kuldp18 / setInputHeight.js
Created June 10, 2023 17:52
Handler for textarea that grows vertically on text overflow
export default (element, defaultHeight) => {
if (element) {
const target = element.target ? element.target : element;
target.style.height = defaultHeight;
target.style.height = `${target.scrollHeight}px`;
}
};
@kuldp18
kuldp18 / audio_splitter.py
Created May 25, 2023 12:14
Splits an audio file into x number of equal pieces
import argparse
from pydub import AudioSegment
import math
import os
def split_audio_file(file_path, num_pieces):
# Load the audio file
audio = AudioSegment.from_file(file_path)
# Calculate the duration of each piece
@kuldp18
kuldp18 / clean.py
Created May 16, 2023 14:23
Python script that can delete empty text files along with corresponding images, handful while captioning for AI/ML stuff
#Make sure your dataset looks like x.txt, x.jpg, y.txt, y.png, z.txt, z.jpeg.....etc
import os
# Set the path to your dataset directory
dataset_directory = './dataset'
# Loop through the files in the dataset directory
for filename in os.listdir(dataset_directory):
if filename.endswith('.txt'):
# Get the full path of the text file
@kuldp18
kuldp18 / txt-gen.ps1
Created May 2, 2023 14:01
Powershell script that generates x number of text files
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,Position=0)]
[int]$f
)
for ($i=1; $i -le $f; $i++) {
New-Item -ItemType File -Path "$i.txt"
}