Skip to content

Instantly share code, notes, and snippets.

# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
#!/bin/bash
wget https://credis.googlecode.com/files/credis-0.2.3.tar.gz
tar -zxvf credis-0.2.3.tar.gz
cd credis-0.2.3
make

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

if ENV["PROFILE"]
#!/usr/bin/env ruby
# Seems a bit silly to have a script to run redcloth considering you can just run
# $ redcloth inputfile.textile > outputfile.html
# but whatever
class Textilize
require 'rubygems'
require 'redcloth'
#!/bin/sh
#uncrustify -l OC -c ~/.uncrustify --no-backup $(find -x -E $SRCROOT -not -regex '.*/\.?External/*.*' -name "*.[mh]")
if [ $# -ne 1 ]; then
echo "Please pass the name of the directory to format"
exit 1;
fi
if [ ! -d $1 ]; then
echo "$1 is not a directory"
@adamvduke
adamvduke / install-graphite-ubuntu-10.04.sh
Created April 30, 2012 04:13 — forked from garethr/install-graphite-ubuntu-10.04.sh
Install Graphite 0.9.9 on Ubuntu 10.04
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Updated by Gareth Rushgrove (http://morethanseven.net)
# Last tested & updated 8th April 2012
####################################
sudo apt-get update
sudo apt-get upgrade
set func_call_user NilOrNotNSNull
indent_align_string=false
indent_braces=false
indent_braces_no_func=false
indent_brace_parent=false
indent_namespace=false
indent_extern=false
indent_class=false
indent_class_colon=false
@adamvduke
adamvduke / nginx.conf
Created November 14, 2013 21:11 — forked from plentz/nginx.conf
#don't send the nginx version number in error pages and Server header
server_tokens off;
# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
# to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
@adamvduke
adamvduke / .zshrc
Last active November 22, 2016 19:01 — forked from bmhatfield/.zshrc
OSX Keychain Environment Variables
# If you use bash, this technique isn't really zsh specific. Adapt as needed.
source ~/keychain-environment-variables.sh
# AWS configuration example, after doing:
# $ set-keychain-environment-variable AWS_ACCESS_KEY_ID
# provide: "AKIAYOURACCESSKEY"
# $ set-keychain-environment-variable AWS_SECRET_ACCESS_KEY
# provide: "j1/yoursupersecret/password"
export AWS_ACCESS_KEY_ID=$(keychain-environment-variable AWS_ACCESS_KEY_ID);
export AWS_SECRET_ACCESS_KEY=$(keychain-environment-variable AWS_SECRET_ACCESS_KEY);
@adamvduke
adamvduke / service-checklist.md
Last active May 8, 2017 05:11 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?