Skip to content

Instantly share code, notes, and snippets.

Avatar

Sarath C sharat

View GitHub Profile
View pitch.md

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

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
nagelflorian / buckets.tf
Last active Sep 30, 2020
Terraform config for static website hosting on AWS
View buckets.tf
# 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
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/org.nodejs.pkg.bom | 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
johanneswuerbach / .travis.yml
Last active Jun 29, 2020
Deploy an iOS app to testflight using Travis CI
View .travis.yml
---
language: objective-c
before_script:
- ./scripts/travis/add-key.sh
after_script:
- ./scripts/travis/remove-key.sh
after_success:
- ./scripts/travis/testflight.sh
env:
global:
@anthonywu
anthonywu / osx_pdf_join.sh
Created Apr 18, 2013
Mac OS X – bash function to join pdfs on the command line
View osx_pdf_join.sh
function pdf_join {
join_py="/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py"
read -p "Name of output file > " output_file && "$join_py" -o $output_file $@ && open $output_file
}
@aaronzirbes
aaronzirbes / shrink-git-repo.sh
Created Jan 19, 2013
This script will help you remove large files from your git repo history and shrink the size of your repository.
View shrink-git-repo.sh
#!/bin/bash
echo "Finding and Purging Big Files From Git History"
echo "=============================================="
echo ""
echo "http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history/"
echo ""
pushd "$(git rev-parse --show-toplevel)" > /dev/null
@piscisaureus
piscisaureus / pr.md
Created Aug 13, 2012
Checkout github pull requests locally
View pr.md

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 = git@github.com:joyent/node.git

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.