Skip to content

Instantly share code, notes, and snippets.

View vaibhavpandeyvpz's full-sized avatar
🐢
I may be slow to respond.

Vaibhav Pandey vaibhavpandeyvpz

🐢
I may be slow to respond.
View GitHub Profile
@vaibhavpandeyvpz
vaibhavpandeyvpz / embeddings.py
Created April 30, 2024 03:50
Generate word embeddings from sentences using "bge-large-en-v1.5" model.
from sentence_transformers import SentenceTransformer
EMBEDDING_MODEL = "BAAI/bge-large-en-v1.5"
model = SentenceTransformer(EMBEDDING_MODEL)
embeddings = model.encode(sentences=["Hey", "How are you?"], normalize_embeddings=True)
@vaibhavpandeyvpz
vaibhavpandeyvpz / Fingerprint.cs
Last active February 11, 2024 11:09
Generate unique device ID or fingerprint for licensing etc. on Windows based system.
using System;
using System.Linq;
using System.Management;
using System.Security.Cryptography;
using System.Text;
namespace DeviceID
{
internal class Fingerprint
{
@vaibhavpandeyvpz
vaibhavpandeyvpz / Dockerfile
Created September 22, 2023 11:16
Chromium's Docker image based on AlpineLinux
FROM alpine:3
RUN apk update && apk upgrade
RUN apk add --no-cache chromium chromium-chromedriver
RUN mkdir -p /usr/src/app \
&& adduser -D chromium \
&& chown -R chromium:chromium /usr/src/app
@vaibhavpandeyvpz
vaibhavpandeyvpz / mybak.sh
Last active June 18, 2023 17:17
Shell script to backup MySQL/MariaDB database to Dropbox.
#!/bin/bash
localBackupDir=${LOCAL_BACKUP_DIR:-$HOME/backup}
remoteBackupDir=${REMOTE_BACKUP_DIR:-backups}
dbHost=${DB_HOST:-localhost}
dbPort=${DB_PORT:-3306}
echo "Changing to '$localBackupDir'..."
cd "$localBackupDir"
@vaibhavpandeyvpz
vaibhavpandeyvpz / encrypt.cpp
Last active May 31, 2023 05:28
AES-256-CBC encryption in Qt with OpenSLL
#include <QCryptographicHash>
#include <QRandomGenerator>
#include <QStringList>
#include <openssl/conf.h>
#include <openssl/evp.h>
#include "SecurityUtil.h"
static char *bytes2chara(const QByteArray &bytes) {
auto size = bytes.size() + 1;
auto data = new char[size];
@vaibhavpandeyvpz
vaibhavpandeyvpz / ubuntu-16-vps-lamp.sh
Last active April 27, 2023 16:23
Install and setup LAMP stack + Composer on a clean Ubuntu 16.04 VPS
#!/usr/bin/env bash
APACHE_USER=wwwhost
VHOSTS_DOMAINS=(example.com second.example.com)
sudo ufw allow in "OpenSSH"
# Install Apache
sudo apt-get update
sudo apt-get install apache2
sudo nano /etc/apache2/apache2.conf # Add ServerName ... directive at bottom
@vaibhavpandeyvpz
vaibhavpandeyvpz / Example.php
Last active March 6, 2023 20:10
Populate `created_at` and `updated_at` columns with Symfony & Doctrine.
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ExampleRepository")
* @ORM\HasLifecycleCallbacks()
* @ORM\Table("examples")
@vaibhavpandeyvpz
vaibhavpandeyvpz / wso-backdoor.php
Created July 28, 2014 06:56
Beware! Most WSO 2.5.1 Scripts Over Internet Are Back-Doored
<?php
/**
* v2.5.1
* Hosted at: http://pastebin.com/BXmWGhMu (Line: #1037)
* Hosted at: http://snipplr.com/view/70661/ (Line: #1037)
* Hosted at: http://dl.packetstormsecurity.net/UNIX/penetration/rootkits/wso2.5.1.zip (Line: #1037)
* Hosted at: http://pastebin.com/KCtz6XA9 (Line: #1037)
*/
// Obfuscated
$x10 = "\x6dai\154";
@vaibhavpandeyvpz
vaibhavpandeyvpz / useWindowSize.js
Created July 25, 2021 11:36
React hook to track window resize events.
import { useEffect, useState } from 'react';
/**
* @return {{width: Number, height: Number}}
*/
function getWindowSize() {
return {
width: window.innerWidth,
height: window.innerHeight,
};
@vaibhavpandeyvpz
vaibhavpandeyvpz / infosec-iq-qa.js
Last active June 15, 2022 16:08
Complete a InfoSec institute course automatically.
function getCsrfToken() {
var parts = ('; ' + document.cookie)
.split("; csrf=");
if (parts.length === 2) {
const value = parts.pop().split(";").shift();
return decodeURIComponent(value);
}
}
function sendXhr(url, method, data = null, headers = {}) {