Skip to content

Instantly share code, notes, and snippets.

View anuj2110's full-sized avatar
🎯
Focusing

ANUJ TREHAN anuj2110

🎯
Focusing
  • India
View GitHub Profile
@anuj2110
anuj2110 / Crawler.go
Created March 31, 2025 10:38
A Crawler in golang
package main
import (
"flag"
"log"
"net/http"
"net/url"
"strings"
"sync"
"time"
@anuj2110
anuj2110 / Crawler.go
Created March 31, 2025 10:35
A crawler with race condition in golang
package main
import (
"flag"
"log"
"net/http"
"net/url"
"strings"
"sync"
"time"
@anuj2110
anuj2110 / app.py
Created June 10, 2023 09:49
Setup SQLAlchemy in FastAPI
from fastapi import FastAPI,Depends
from .database import engine,SessionLocal,get_db
from sqlalchemy.orm import Session
import psycopg2
from psycopg2.extras import RealDictCursor
app = FastAPI()
models.Base.metadata.create_all(bind=engine)
def printbinaryStringsWithoutConsecutive1s(n,i,osf,lastDigit):
if i==n:
print(osf)
return
if lastDigit==0:
printbinaryStringsWithoutConsecutive1s(n,i+1,osf+'0',0)
printbinaryStringsWithoutConsecutive1s(n,i+1,osf+'1',1)
else:
printbinaryStringsWithoutConsecutive1s(n,i+1,osf+'0',0)
printbinaryStringsWithoutConsecutive1s(4,0,'',0)
def printStringSubsets(n,i,osf,char,string):
if(i==n):
print(f'"{osf}"')
return
printStringSubsets(n,i+1,osf+originalString[i-1],originalString[i-1],string)
printStringSubsets(n,i+1,osf,originalString[i-1],string)
originalString = 'xyza'
printStringSubsets(len(originalString)+1,1,'',originalString[0],originalString)
@anuj2110
anuj2110 / Download Files From Firebase Storage As Zip.js
Last active January 25, 2022 08:19
This gist showcases how to download files from the folder in firebase storage into the client system. Before running the script follow the instructions in the link given: https://firebase.google.com/docs/storage/web/download-files#cors_configuration
import JSZip from 'jszip';
import { saveAs } from 'file-saver';
// TODO: Initialize the firebase project in the client side
const storage = firebase.storage().ref('<Folder_Name')
const getFileUrls = async (dest_storage_path:string) => {
const files = await (await storage.listAll()).items
const jszip = new JSZip();
# making the imports ----------------------------------------------------
import os
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.applications.mobilenet_v2 import MobileNetV2, preprocess_input
from tensorflow.keras.layers import Dense,Flatten
from tensorflow.keras.models import Model, Sequential
# import section end ------------------------------------------------------
from PIL import ImageFile
def stackImages(scale,imgArray):
rows = len(imgArray)
cols = len(imgArray[0])
rowsAvailable = isinstance(imgArray[0], list)
width = imgArray[0][0].shape[1]
height = imgArray[0][0].shape[0]
if rowsAvailable:
for x in range ( 0, rows):
for y in range(0, cols):
if imgArray[x][y].shape[:2] == imgArray[0][0].shape [:2]:
def convert_to_sequences(tokens:list):
'''
Function to convert the sequences to tokens.
params:
tokens(list): The text converted to a list of cleaned tokens.
returns:
sequnces(list): The list of sequences formed from tokens.abs
'''
length = 50 + 1
sequences = list()
import string
import numpy as np
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.layers import Dense,LSTM,Dropout,Embedding
from tensorflow.keras.models import Sequential
from tensorflow.keras.utils import to_categorical
def load_file(path:str):
'''
Function to load the text file for training the language model.