Skip to content

Instantly share code, notes, and snippets.

View chavarera's full-sized avatar
💭
I may be slow to respond.

Ravishankar Chavare chavarera

💭
I may be slow to respond.
View GitHub Profile
@chavarera
chavarera / pythontread.py
Created April 5, 2019 03:01
pythonthreading
import threading
def Func1(num):
cal=num*10000
print("\nI am From Func1 ")
def Func2(num):
print("\nI am from Func2".format(num * num))
if __name__ == "__main__":
t1 = threading.Thread(target=Func1, args=(10,))
t2=threading.Thread(target=Func2,args=(11,))
@chavarera
chavarera / scrapy_debug_options.py
Created December 23, 2020 04:20
scrapy different way to debug scrapy code
#Default debugger
import pdb; pdb.set_trace()
# Use scrapy Logging
self.logger.info('this is Simple Log')
self.log('this is log example')
# Inspect in Shell
from scrapy.shell import inspect_response
@chavarera
chavarera / cinfo.sh
Created February 17, 2021 08:18
Get linux based System Information
# Created By : Ravishankar Chavare
# Reference : Cinfo(utility Tool)
# Link : github.com/chavarera/cinfo
# Date : 17-02-2021
echo ' Architecture Info '
echo '__________________________________________________________________________________'
hostnamectl | grep -e 'Machine ID' -e 'Boot ID' -e 'Operating System' -e Kernel -e Architecture
@chavarera
chavarera / ScrapyDelayMiddleware.py
Created March 2, 2021 10:15
scrapy request delay middleware
class RequestDelayMiddleware(object):
def process_request(self, request, spider):
# Add delay_by key in meta
delay_s = request.meta.get('delay_by', None)
if not delay_s:
return
deferred = Deferred()
reactor.callLater(delay_s, deferred.callback, None)
return deferred
@chavarera
chavarera / flatten_json.py
Created December 3, 2021 05:11
flatten json
import pandas as pd
from json import dump, load
def flat(object, sep='.'):
"""flatten nested object
Args:
object ([dict]): input document
sep (str, optional): an seperator. Defaults to '.'.
@chavarera
chavarera / pwbar.py
Last active July 7, 2023 08:41
Displays a progress bar while iterating over an iterable.
"""
Author: Ravishankar Chavare
Version: 1.0
File: pwbar.py
Description: This module provides a progress bar utility for tracking the
progress of iterative tasks.
1.1
===
import sqlglot
import time
import os
import pandas as pd
from sqlglot import parse_one, exp, optimizer
from sqlglot.optimizer.scope import traverse_scope
from sqlglot.errors import OptimizeError
# Define the SQL query string