Skip to content

Instantly share code, notes, and snippets.


Sarath C sharat

View GitHub Profile

I Am

I am Will Jessop. I am a contractor and consultant advising on Ruby on Rails performance, upgrades, scaling and hosting.

I deployed, scaled, and debugged Ruby on Rails applications at Engineyard before spending nearly six years working in operations at Basecamp (37signals), the company that created Ruby on Rails itself. After that I spent three years contracting for a large company helping them upgrade their Rails version and stack, implement strong parameters, and generally improve quality in their codebase by implementing data-collection, dashboards and reporting, writing documentation and providing advice, as well as updating code myself, all within the company's many Rails apps, including their main multi-million line monolith.

You are

You have an existing Rails app that you might want some assistance with. You might be in one of the following circumstances:

candostdagdeviren / pre-commit
Last active Aug 18, 2020
Git Pre-Commit hook with SwiftLInt
View pre-commit
#Path to swiftlint
#if $SWIFT_LINT >/dev/null 2>&1; then
if [[ -e "${SWIFT_LINT}" ]]; then
for file_path in $(git ls-files -m --exclude-from=.gitignore | grep ".swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path

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.

nagelflorian /
Last active Sep 30, 2020
Terraform config for static website hosting on AWS
# AWS S3 bucket for static hosting
resource "aws_s3_bucket" "website" {
bucket = "${var.website_bucket_name}"
acl = "public-read"
tags {
Name = "Website"
Environment = "production"
tonymtz / gist:d75101d9bdf764c890ef
Last active Sep 13, 2020
Uninstall nodejs from OSX Yosemite
View gist:d75101d9bdf764c890ef
# first:
lsbom -f -l -s -pf /var/db/receipts/ | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
johanneswuerbach / .travis.yml
Last active Jun 29, 2020
Deploy an iOS app to testflight using Travis CI
View .travis.yml
language: objective-c
- ./scripts/travis/
- ./scripts/travis/
- ./scripts/travis/
anthonywu /
Created Apr 18, 2013
Mac OS X – bash function to join pdfs on the command line
function pdf_join {
join_py="/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/"
read -p "Name of output file > " output_file && "$join_py" -o $output_file $@ && open $output_file
aaronzirbes /
Created Jan 19, 2013
This script will help you remove large files from your git repo history and shrink the size of your repository.
echo "Finding and Purging Big Files From Git History"
echo "=============================================="
echo ""
echo ""
echo ""
pushd "$(git rev-parse --show-toplevel)" > /dev/null
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

You can’t perform that action at this time.