Skip to content

Instantly share code, notes, and snippets.

// Updated extractLinkedInPosts function with continuous scrolling
async function extractLinkedInPosts() {
const postsData = [];
const seenTexts = new Set();
let lastLength = 0;
while (postsData.length < 20) {
window.scrollTo(0, document.body.scrollHeight);
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait for more posts to load
(function() {
// Initialize an array to hold the conversation data
let conversationData = [];
// Select all conversation blocks
let conversationBlocks = document.querySelectorAll('[data-testid^="conversation-turn"]');
conversationBlocks.forEach(block => {
// Determine the role directly from data attributes in the HTML
let roleElement = block.querySelector('[data-message-author-role]');
@RohanAwhad
RohanAwhad / extractAndDownloadApolloSearchResults.js
Last active October 29, 2024 15:51
Extract details from the search response in Apollo.io
function extractRowData(rowElement) {
// Function to extract text or attribute from an element if it exists
function getElementData(selector, attribute = 'text') {
const element = rowElement.querySelector(selector);
if (!element) return null;
if (attribute === 'text') return element.textContent.trim();
return element.getAttribute(attribute);
}
// Extracting the values based on their aria-label, role, or data-* attributes
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function clickShowTranscriptButton() {
// Selecting the button based on its class and aria-label
var buttons = document.querySelectorAll(
"button.yt-spec-button-shape-next.yt-spec-button-shape-next--outline.yt-spec-button-shape-next--call-to-action.yt-spec-button-shape-next--size-m"
);
@RohanAwhad
RohanAwhad / github2file.py
Last active April 17, 2024 22:22
A utility script to download and process files from a GitHub repository based on language-specific criteria.
# Inspiration from Eric Hartford github2file: https://github.com/cognitivecomputations/github2file
"""
A utility script to download and process files from a GitHub repository based on language-specific criteria.
Features:
- Download files from a specific branch or tag of a GitHub repository.
- Filter files based on their extension to include only those relevant to the specified programming language.
- Exclude files located in certain directories or those that match a set of predefined non-useful criteria.
- Check and exclude test files based on content indicators specific to each supported language.
@RohanAwhad
RohanAwhad / init.lua
Created July 29, 2024 13:10
My neovim config
--[[
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
======== .-----. ========
======== .----------------------. | === | ========
======== |.-""""""""""""""""""-.| |-----| ========
======== || || | === | ========
======== || KICKSTART.NVIM || |-----| ========
import dataclasses
import openai
import os
import re
import yaml
from pydantic import BaseModel, ValidationError
from typing import Optional
from transformers import AutoTokenizer, AutoModel
import torch
# MODEL CKPT is downloaded from: "jinaai/jina-embeddings-v2-base-en" # has context len of 8192
MODEL_CKPT = "/Users/rohan/3_Resources/ai_models/jina-embeddings-v2-base-en"
def recursive_splitter(text: str, separators: list[str], chunk_size: int) -> list[str]:
if len(separators) == 0:
words = text.strip().split(' ')
import base64
import cv2
import os
import openai
import whisper
import pyaudio
import wave
import uuid
import threading
from queue import Queue
import json
import openai
from typing import Any
from jupyter_client.manager import KernelManager
kernel_manager: KernelManager = None
def execute_code_in_notebook(code: str) -> list[Any]:
if not code: return []
global kernel_manager
if kernel_manager is None: