Skip to content

Instantly share code, notes, and snippets.

@barretts
barretts / getAppliedJobInfo.js
Created March 26, 2025 03:29
get applied job information from LinkedIn
function extractJobs(linkedInResponse) {
const jobs = [];
const jobElements = linkedInResponse?.data?.data?.searchDashClustersByAll?.elements?.[0]?.items || [];
const jobDetails = linkedInResponse?.included || [];
jobElements.forEach(({ item }) => {
const entityUrn = item?.["*entityResult"];
if (!entityUrn) return;
@barretts
barretts / undirectedGraphNodeComponents.js
Last active March 31, 2025 23:08
turning interview questions into learning opportunities
/*
Given n, i.e. total number of nodes in an undirected graph numbered
from 1 to n and an integer e, i.e. total number of edges in the
graph. Calculate the total number of connected components in the graph.
A connected component is a set of vertices in a graph that are linked
to each other by paths.
O(E^2 log E)
mine un-sorted: 15421ms
mine un-sorted and Set nodes: 41ms
@barretts
barretts / openMeetingsHammerspoon.lua
Last active May 23, 2025 18:01
automatically open meeting links for calendar events in the next 5 minutes using Hammerspoon
local lastOpenedLink = nil
local lastOpenedTime = 0
function openMeetingLink(link)
local now = os.time()
if link and (link ~= lastOpenedLink or now - lastOpenedTime > 600) then
hs.urlevent.openURL(link)
lastOpenedLink = link
lastOpenedTime = now
else
@barretts
barretts / check_undefined_methods.rb
Last active June 26, 2025 00:36
ruby check for undefined method calls
#!/usr/bin/env ruby
# Simple undefined method checker
# This script looks for potential undefined method calls by checking:
# 1. Method calls on objects that might not have those methods
# 2. Common patterns that could indicate undefined methods
# 3. Caching previous results to highlight new findings
require 'find'
require 'json'