Skip to content

Instantly share code, notes, and snippets.

View skydan's full-sized avatar

Evgeniy Skidan skydan

View GitHub Profile
@skydan
skydan / check.rb
Last active August 29, 2015 14:10 — forked from christopher-b/check.rb
#!/usr/bin/env ruby
# Do sanity check on imported data by comparing the number of rows in each table
require 'pg'
require 'mysql2'
tables = %w( { list the talbes to compare here })
p = PG.connect(dbname:'canvas', host: 'postgres.ocad.ca', user: 'canvas_user')
@skydan
skydan / install-comodo-ssl-cert-for-nginx.rst
Last active September 3, 2015 20:39 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

activerecord (3.2.8) lib/active_record/relation/finder_methods.rb:341:in `find_one'
friendly_id (4.0.8) lib/friendly_id/finder_methods.rb:17:in `find_one'
activerecord (3.2.8) lib/active_record/relation/finder_methods.rb:312:in `find_with_ids'
activerecord (3.2.8) lib/active_record/relation/finder_methods.rb:107:in `find'
activerecord (3.2.8) lib/active_record/querying.rb:5:in `find'
inherited_resources (1.3.1) lib/inherited_resources/base_helpers.rb:44:in `resource'
cancan (1.6.8) lib/cancan/inherited_resource.rb:12:in `load_resource_instance'
cancan (1.6.8) lib/cancan/controller_resource.rb:32:in `load_resource'
cancan (1.6.8) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
cancan (1.6.8) lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
@skydan
skydan / es.sh
Created September 16, 2012 21:05 — forked from aaronshaf/es.sh
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get update
sudo apt-get install unzip curl python-software-properties -y
#sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
c:\Sites\HigginsMD>cap deploy
triggering load callbacks
* ←[32m2012-11-12 21:27:10 executing `staging'←[0m
triggering start callbacks for `deploy'
* ←[32m2012-11-12 21:27:10 executing `multistage:ensure'←[0m
* ←[32m2012-11-12 21:27:10 executing `deploy'←[0m
* ←[32m2012-11-12 21:27:10 executing `deploy:update'←[0m
** transaction: start
* ←[32m2012-11-12 21:27:10 executing `deploy:update_code'←[0m
←[33mexecuting locally: "git ls-remote git@github.com:Pelesend/HigginsMD.git master"←[0m
➜ demon_app bundle update
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.7.6)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
### Current Style
Feature: Admin Login
In order to access the admin functionality of the site
As a registered admin of it
I need to be able to login into it
Scenario Outline: Successfully login with correct credentials
Given an admin account exists with email <email> and password <password>
And I am at the admin login page
When I fill in the email <email>
@skydan
skydan / System Design.md
Created April 24, 2016 18:42 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?

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"]