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
1. Install oh-my-zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
2. Clone necessary plugins.
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
3. Add plugins to ~/.zshrc as
plugins = ( [plugins...] zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting)
@bitsnaps
bitsnaps / dirsize.js
Last active November 20, 2023 13:19
Get directory size (used in stackblitz as a replacement of `du -sh` command)
import { join } from 'path';
import { readdir, stat } from 'fs/promises';
function humanFileSize(bytes, si = false, dp = 1) {
const thresh = si ? 1000 : 1024;
if (Math.abs(bytes) < thresh) {
return bytes + ' B';
}
@bitsnaps
bitsnaps / commands.sh
Last active September 21, 2023 18:30
Replit & NixOS cheat sheet
# NixOS is a Linux distribution built on top of the Nix package manager, known for its declarative and reproducible approach to system configuration.
# read more: https://nixos.org/
# Replit uses NixOS under the hood in order with Nix which is a tool for managing packages and system configurations.
#https://docs.replit.com/programming-ide/nix-on-replit
# Update nix packages
nix-channel --update
# list all nix channels
@bitsnaps
bitsnaps / dataframe_viewer.py
Created June 25, 2023 18:09
A simple Qt5 python app to display a CSV or Excel in TableWidget
# pip install openpyxl, pandas, PyQt5... (if you don't use conda)
import sys
import pandas as pd
from PyQt5.QtCore import QSize, Qt, pyqtSlot, pyqtSignal
from PyQt5.QtWidgets import (QApplication, QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
QFileDialog, QVBoxLayout, QWidget, QDialog, QLabel, QLineEdit, QComboBox, QCheckBox, QHBoxLayout)
# Custom TableWidget class
class TableWidget(QTableWidget):
def __init__(self, df, parent=None):
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
@bitsnaps
bitsnaps / agent.py
Created June 21, 2023 09:56 — forked from hursh-desai/agent.py
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-********'
@bitsnaps
bitsnaps / text_similarity
Created April 20, 2023 15:45
A small script to benchmark different models for text similarity using SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
try:
import spacy
except:
!pip install spacy
import spacy
try:
from sentence_transformers import SentenceTransformer, util
@bitsnaps
bitsnaps / tool_size.py
Created March 21, 2023 09:48
A script to browse all python packages and show their sizes
#!/usr/bin/env python
import os
import pkg_resources
def calc_container(path):
total_size = 0
for dirpath, dirnames, filenames in os.walk(path):
for f in filenames:
fp = os.path.join(dirpath, f)
@bitsnaps
bitsnaps / curl-hack-.md
Last active March 13, 2023 08:32 — forked from lemajes/curl-hack-.md
Curl example #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.

@bitsnaps
bitsnaps / bypass_ssl_insecurities.py
Created February 26, 2023 18:04 — forked from sujit/bypass_ssl_insecurities.py
Selenium Bypass SSL Bad/Revoked Certificates
import sys
from time import sleep
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import WebDriverException
from eliot import start_action, to_file, log_call
# from selenium.webdriver.common.keys import Keys
# from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
# from selenium.webdriver.common.by import By
# from selenium.webdriver.support import expected_conditions as EC