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
@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 vpnwall-services/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
@bitsnaps
bitsnaps / InstallGLPK.md
Last active February 11, 2023 16:31
Setup and install glpk on Windows 7

GLPK Installation process on Windows 7 SP1

Prerequists:

  • Visual C++ (for GLPK v4.65 you'll need VC v2010 Express)

  • Download the latest GLPK zip package: https://sourceforge.net/projects/winglpk/files/winglpk/ then extract its content to the C:\glpk.

  • Create the environment variable %GLPK_HOME% pointing to the C:\glpk path you've created, and add to the system path the following value: SET PATH=%PATH%;%GLPK_HOME%\w64

@bitsnaps
bitsnaps / JScienceTest.groovy
Created September 25, 2022 22:04 — forked from kimukou/JScienceTest.groovy
JScienceTest.groovy
// reference http://www.geocities.jp/tomtomf/JScience/JScience.htm
//
@GrabResolver (name='jcurl-repository', root='http://jcurl.berlios.de/m2/repo/')
@Grab(group = 'org.jscience', module='jscience', version='4.3.1')
import org.jscience.mathematics.number.Complex
import org.jscience.mathematics.vector.ComplexMatrix
//計算結果の出力様関数
def show(cm) {
@bitsnaps
bitsnaps / base64coding.groovy
Created September 24, 2022 09:45 — forked from mujahidk/base64coding.groovy
Base64 encoding and decoding in Groovy.
def text = "Going to convert this to Base64 encoding!"
// Encode
def encoded = text.bytes.encodeBase64().toString()
println encoded
// Decode
byte[] decoded = encoded.decodeBase64()
println new String(decoded)
@bitsnaps
bitsnaps / upper_confidence_bound.py
Last active July 30, 2022 14:08 — forked from devamitranjan/UCB.py
Upper Confidence Bound Implementation
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import math
class UpperConfidenceBound:
def __init__(self, dataframe, N, m):
self.__dataset = dataframe
self.__N = N
self.__m = m
@bitsnaps
bitsnaps / plot_rbm_logistic_classification.py
Last active July 29, 2022 05:45 — forked from understar/plot_rbm_logistic_classification.py
scikit-learn RBM feature extraction and logistic classification
"""
Update: (07.29.2022): Fix: train_test_split import
==============================================================
Restricted Boltzmann Machine features for digit classification
==============================================================
For greyscale image data where pixel values can be interpreted as degrees of
blackness on a white background, like handwritten digit recognition, the
Bernoulli Restricted Boltzmann machine model (:class:`BernoulliRBM
<sklearn.neural_network.BernoulliRBM>`) can perform effective non-linear