Skip to content

Instantly share code, notes, and snippets.

View navinthomas's full-sized avatar

Navin Thomas navinthomas

View GitHub Profile
@fabianem
fabianem / Code.gs
Last active April 28, 2025 18:56
Google Apps Script to count emails by sender in batches
// Google Apps Script for counting emails by sender in batches. Stopps and resumes after 5mins of processing to avoid reaching script runtime limit.
// 1. Allow required permissions
// 2. Add gmail service to project
// 3. Fill <your-email> in `runProcessor` function and adjust query if needed
// 4. Run function `runProcessor`
// 5. Result will be saved in a new spreadsheet
// Based on ideas from https://stackoverflow.com/a/59222719/5162536 and
// https://medium.com/geekculture/bypassing-the-maximum-script-runtime-in-google-apps-script-e510aa9ae6da
@d-neri
d-neri / Code.gs
Last active May 5, 2025 15:59
Google Apps Script - Gmail count emails by sender
// Execute the "run" function below after setting up the appropriate APIs
// Original credit: https://stackoverflow.com/a/59222719/501042
function sender_list_paged(token) {
var dt = new Date().getTime();
var ss = SpreadsheetApp.create('Gmail count emails by sender ' + dt);
var sh = ss.getActiveSheet()
sh.clear();
sh.appendRow(['Email Address', 'Count']);
var token = token || null;
var query = "in:inbox is:unread";
@n1snt
n1snt / Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md
Last active June 23, 2025 07:41
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 19, 2025 14:33
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k