Skip to content

Instantly share code, notes, and snippets.

View bitsnaps's full-sized avatar
🌍
Working @ CorpoSense

Ibrahim H. bitsnaps

🌍
Working @ CorpoSense
View GitHub Profile
@paolosalvatori
paolosalvatori / app.py
Last active August 27, 2024 09:01
A Streamlit chat written in Python and based on Azure OpenAI. The application was successfully tested on Azure Kubernetes Service (AKS)
"""
MIT License
Copyright (c) 2023 Paolo Salvatori
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
from flask import Flask, jsonify, request
import requests
import PyPDF2
import tempfile
import pickle
import retrying
from langchain.llms import OpenAI
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.docstore.document import Document
from langchain.embeddings.openai import OpenAIEmbeddings
@liviaerxin
liviaerxin / README.md
Last active August 13, 2025 07:49
FastAPI and Uvicorn Logging #python #fastapi #uvicorn #logging

FastAPI and Uvicorn Logging

When running FastAPI app, all the logs in console are from Uvicorn and they do not have timestamp and other useful information. As Uvicorn applies python logging module, we can override Uvicorn logging formatter by applying a new logging configuration.

Meanwhile, it's able to unify the your endpoints logging with the Uvicorn logging by configuring all of them in the config file log_conf.yaml.

Before overriding:

uvicorn main:app --reload
@hursh-desai
hursh-desai / agent.py
Created January 13, 2023 10:17
obsidian + langchain
import os
import re
import faiss
from langchain import FAISS
import obsidiantools.api as otools
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.llms import OpenAI
os.environ["OPENAI_API_KEY"] = 'sk-********'
@kilianplapp
kilianplapp / scrape.py
Created November 29, 2022 20:21
Scrape 50 most recent pastes on PasteBin.com
import requests
from lxml import html
def getPastes():
for link in html.fromstring(requests.get("https://pastebin.com/archive").text).xpath('//tr//a'):
if str(link.get('href')).startswith('/archive/'): continue
yield (str(link.get('href')).replace('/', ''))
for i in getPastes():
print(i)
@lemajes
lemajes / curl-hack-.md
Created September 2, 2022 16:15
[CURL HACK] Curl Hack #bash #curl #hack

Hacking With cURL

A list of examples and references of hacking with Bash and the Curl command.

What the heck is cURL?

cURL is short for "Client URL" and is a computer software project providing a library (libcurl) and command-line tool (curl) first released in 1997. It is a free client-side URL transfer library that supports the following protocols: Cookies, DICT, FTP, FTPS, Gopher, HTTP/1, HTTP/2, HTTP POST, HTTP PUT, HTTP proxy tunneling, HTTPS, IMAP, Kerberos, LDAP, POP3, RTSP, SCP, and SMTP Although attack proxies like BurpSuitePro are very handy tools, cURL allows you to get a bit closer to the protocol level, leverage bash scripting and provides a bit more flexibility when you are working on a complex vulnerability.

cURL GET parameters

HTTP GET variables can be set by adding them to the URL.

@nanusdad
nanusdad / ssl-cert-on-ubuntu-lightsail-for-Moodle.md
Last active February 21, 2025 00:49
Setting up LetsEncrypt SSL certificate for Moodle on Ubuntu

Setting up LetsEncrypt SSL certificate for Moodle on Ubuntu

  1. Install certbot

sudo apt install certbot python3-certbot-apache
  1. Enable firewall to allow Apache https and ssh

sudo ufw status
sudo ufw enable
@Aditya1001001
Aditya1001001 / build_train_doc2vec.py
Last active January 5, 2025 23:44
Comparing Text Similarity Measures & Text Embedding Methods
def tagged_document(list_of_list_of_words):
for i, list_of_words in enumerate(list_of_list_of_words):
yield gensim.models.doc2vec.TaggedDocument(list_of_words, [i])
training_data = list(tagged_document(data))
model = gensim.models.doc2vec.Doc2Vec(vector_size=40, min_count=2, epochs=30)
model.build_vocab(training_data)
model.train(training_data, total_examples=model.corpus_count, epochs=model.epochs)

Everything You Need To Become A Machine Learner

Part 1:


Everything You Need To Become A Machine Learner

Part 1:

@prof3ssorSt3v3
prof3ssorSt3v3 / README.md
Last active May 12, 2024 13:54
Code from Getting Started with WebPack 5 (2021) video

File Details

  • webpack.config.js goes in the root folder of your project
  • package.json goes in the root folder of your project

Run this command to install all the dependecies from the package.json file

npm install