Skip to content

Instantly share code, notes, and snippets.

@yuvraj108c
yuvraj108c / invoke_lamda.js
Created May 4, 2022 09:04
Invoke lambda function from nodejs
import AWS from "aws-sdk";
AWS.config.region = "us-east-1";
(async () => {
const lambda = new AWS.Lambda();
const params = {
FunctionName: "FN-1",
InvocationType: "RequestResponse",
LogType: "Tail",
Payload:
@yuvraj108c
yuvraj108c / upload_s3.js
Created May 4, 2022 09:10
Upload file to s3 from nodejs
const axios = require("axios");
const AWS = require("aws-sdk");
AWS.config.region = "us-east-1";
const bucket_id = "BK-1";
module.exports.main = async (event) => {
const s3 = new AWS.S3();
await s3
.putObject({
@yuvraj108c
yuvraj108c / sleep.js
Created May 9, 2022 06:07
[js] Sleep for N miliseconds
const sleep = async (milliseconds) => {
await new Promise((resolve) => setTimeout(resolve, milliseconds));
};
@yuvraj108c
yuvraj108c / pm2.sh
Created June 3, 2022 11:39
Pm2 run command
pm2 start npm --name <name> -- run <script>
@yuvraj108c
yuvraj108c / random_num.js
Created July 12, 2022 10:31
Ger random number in range
function getRndInteger(min, max) {
return Math.floor(Math.random() * (max - min) ) + min;
}
@yuvraj108c
yuvraj108c / ffmpeg.sh
Last active October 6, 2022 08:58
FFMPEG commands
# Remove audio from video file
ffmpeg -i "video.mp4" -c copy -an "output.mp4"
# Merge (video file without audio) with audio file
ffmpeg -i "video.mp4" -i "audio.mp3" -c:v copy -c:a aac "output.mp4"
# Trim video using start/end time (hh:mm:ss)
ffmpeg -ss 00:00:00 -i "video.mp4" -c copy -t 00:00:15 "output.mp4"
# Write text at middle of a video file
function extractEmailFromString(text: string): string {
const matches = text.match(
/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi
);
return matches ? matches[0] : "";
}
@yuvraj108c
yuvraj108c / civitai.py
Created May 28, 2023 10:00
Download civitai model/lora
import requests
from bs4 import BeautifulSoup
web_url = "https://civitai.com/models/7371/rev-animated"
model_type = "model"
# Get download url
response = requests.get(web_url)
soup = BeautifulSoup(response.text, 'html.parser')
url = soup.select(".mantine-UnstyledButton-root.mantine-Button-root.mantine-1movwzg")[0].get("href")
from huggingface_hub import HfApi, hf_hub_url
import os
hf_config = {
"username":"",
"repo_name":"",
"token":""
}
def upload_file_hf(file_path):
for dir in custom_nodes/*/; do
if [ -d "$dir" ]; then
echo "Entering module: $dir"
(cd $dir && pip install -qq -r requirements.txt)
fi
done