Skip to content

Instantly share code, notes, and snippets.

@lao
lao / secret-santa.py
Created January 18, 2024 12:31
Tiny secret santa py
import datetime
import random
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def secret_santa(names):
"""Assigns a Secret Santa for each person in the list avoiding cycles of two."""
# Check for a valid number of participants
@lao
lao / useIndexedDB.js
Created February 13, 2024 14:55
This file contains a custom hook for interacting with IndexedDB, a low-level API for client-side storage of significant amounts of structured data.
/**
* File: useIndexedDB.js
*
* This file contains a custom hook for interacting with IndexedDB, a low-level API for client-side storage of significant amounts of structured data.
*
* The hook takes three parameters:
* 1. `databaseName`: The name of the IndexedDB database you want to interact with.
* 2. `storeName`: The name of the object store in the database.
* 3. `key`: The key of the value you want to read or write in the object store.
*
# THIS IMPLEMENTATION IS PART OF A BLOG POST ABOUT:
# "Achieving Reliable Zero Downtime Re-indexing with Searchkick"
module Searchkick
# Module to check for reindexing and duplicate jobs to the new index
module ReindexCheck
def perform(*args, **options)
job_type = self.class.name.demodulize
class_name, index_name, record_ids = extract_job_details(job_type, args, options)
@lao
lao / .zshrc
Last active February 10, 2025 15:37
# Git AI Shell Functions and Utilities
# Author: Lucas Oliveira
# Last Modified: 2024-03-16
###############################################################################
# CONFIGURATION
###############################################################################
# Update the default Claude model to use the latest version
@lao
lao / clear-sidekiq-jobs.sh
Created March 25, 2025 17:59 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear