Skip to content

Instantly share code, notes, and snippets.

View wooyakob's full-sized avatar

Jacob wooyakob

View GitHub Profile
@wooyakob
wooyakob / ca-eateries.sql
Created October 3, 2025 15:47
SQL++ query for Couchbase that retrieves restaurants (landmark documents) in California with activity type "eat". It ensures only complete records are returned by requiring non-null values for key fields like name, content, price, URL, geo, and phone.
-- Bucket: travel-sample
-- Scope: inventory
-- Collection: landmark
SELECT
l.name,
l.content,
l.price,
l.url,
l.geo,
@wooyakob
wooyakob / restaurant-vector-search.py
Created October 3, 2025 15:45
Performs a semantic restaurant search using Couchbase’s vector search. The function embeds a user query, retrieves matching documents from a Couchbase search index, and enriches results with Google Maps reverse-geocoded addresses and embed URLs for easy integration into apps.
def search_restaurants(self, question):
vector = self.embeddings_model.embed_query(question)
try:
search_req = search.SearchRequest.create(search.MatchNoneQuery()).with_vector_search(
VectorSearch.from_vector_query(VectorQuery('embedding', vector, num_candidates=3))
)
result = self.scope.search(
self.search_index,
search_req,
SearchOptions(limit=13, fields=["name", "content", "phone", "price", "url", "geo.lat", "geo.lon"])
@wooyakob
wooyakob / cb-property-search.py
Created October 2, 2025 23:03
Utility function performs a personalized property search using Couchbase’s vector similarity capabilities. It returns the top k most relevant properties for a given query, automatically excluding any properties the user has already saved (using flexible deduplication keys: ID, address, name, price).
def couchbase_property_search(vector_store, query, k=5, saved_properties=None):
"""
Search properties in Couchbase using vector similarity, excluding saved properties.
- vector_store: CouchbaseSearchVectorStore instance
- query: search string
- k: number of results to return
- saved_properties: list of dicts (already saved by user)
Returns: list of property dicts
"""
@wooyakob
wooyakob / audio-vggish.py
Created October 2, 2025 22:51
Extract audio embeddings to a JSON doc from a .wav file, using Google’s VGGish model, useful for tasks such as audio classification, retrieval, clustering and feature extraction.
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import soundfile as sf
# Load VGGish model from TensorFlow Hub
vggish = hub.load('https://tfhub.dev/google/vggish/1')
def load_wav_for_vggish(file_path):
wav, sr = sf.read(file_path)