Skip to content

Instantly share code, notes, and snippets.

View SurendraTamang's full-sized avatar
🎯
Focusing

surendra SurendraTamang

🎯
Focusing
View GitHub Profile
@SurendraTamang
SurendraTamang / sheets.gs
Created April 2, 2024 04:28
Nepali comma number system in Google Sheets
// Nepali format number system in Google sheets
>=10000000]##\,##\,##\,##0;[>=100000] ##\,##\,##0;##,##0
@SurendraTamang
SurendraTamang / app.py
Created March 23, 2024 05:40
divide the large file in simple chunk zipped
import os
import zipfile
required_mb = 850
def zip_folder(folder_path, max_chunk_size_mb=required_mb):
# Convert MB to bytes for comparison
max_chunk_size = max_chunk_size_mb * 1024 * 1024
current_chunk_size = 0
chunk_num = 1
zip_file = None
@SurendraTamang
SurendraTamang / psql.sh
Last active March 17, 2024 08:53
Cheetsheet for PostGresql learning
# For Restoring the the backup in the given database
# While running on docker I first copied the local file to docker container and docker cp and did below
psql -U {db_user} -d database_name -f {db}.sql
@SurendraTamang
SurendraTamang / numbertowords.js
Created March 12, 2024 02:06
Number to words
function numberToWords(num) {
if (num === 0) return "zero";
const underTwenty = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
"seventeen", "eighteen", "nineteen"];
const tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"];
const scales = ["", "thousand", "million", "billion", "trillion", "quadrillion"]; // Extend as needed
const toWords = (n) => {
@SurendraTamang
SurendraTamang / scrapy_feeds.py
Created March 7, 2024 05:05
FEEDS on Scrapy
FEEDS = {
f'data/{name}.csv':{
'format':'csv',
'overwrite':True # Will create every time new
}
}
@SurendraTamang
SurendraTamang / asyncio-await.py
Last active February 22, 2024 15:30
Asynchornous Programming in Python - asyncio.py
import asyncio
import time
# What is the difference between this I find same ?
# Coroutine
async def my_coroutine():
print("Coroutine is starting...")
await asyncio.sleep(5) # Simulate a non-blocking delay
@SurendraTamang
SurendraTamang / scrapy_cmdline.py
Created February 9, 2024 04:21
Running scrapy spider in python file using scrapy's cmdline module
from scrapy import cmdline
from datetime import datetime
region = 'depew'
date_now = datetime.now()
# tslco is my scrapy spider and other arguments
cmdline.execute(f"scrapy crawl tslco -a db_connection={region} -o {region}-{date_now.strftime('%Y-%m-%d')}.csv".split())
import cv2
from PIL import Image, ImageDraw, ImageFont
import datetime
import numpy as np
# Constants
total_seconds = 60 # 24 hours in seconds
fps = 1 # 1 frame per second
size = (800, 600) # Frame size
font_size = 200
@SurendraTamang
SurendraTamang / prompts.txt
Created January 4, 2024 11:46
Python Senior Developer
Act as Senior Python developer, Follow all the standard PEP8 Styles, Always provide required standard practise of Python
Guide me with complete for this given task
-----
@SurendraTamang
SurendraTamang / hms.py
Created December 28, 2023 23:54
Conversion of seconds to Hours, Minutes and Seconds format
def seconds_to_hms(seconds):
""" Convert seconds to a time format (HH:MM:SS).
Args:
seconds (float): The time duration in seconds.
Returns:
str: The time formatted as HH:MM:SS.
"""
# Ensure the input is a float and round it to the nearest whole number