Skip to content

Instantly share code, notes, and snippets.

Dmytro Rymar drymar

  • Ukraine, Kyiv
Block or report user

Report or block drymar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@drymar
drymar / rbenv-howto.md
Created Feb 21, 2018 — forked from MicahElliott/rbenv-howto.md
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler
View rbenv-howto.md

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.
aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev
View 2013-01-07-profiling-memory-leaky-sidekiq-applications-with-ruby-2.1.md

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"]
View install-pdf2htmlEX-ubuntu-14.04.sh
#!/bin/sh
RESTORE=$(echo '\033[0m')
BOLD=$(echo '\033[1m')
GREEN=$(echo '\033[1;32m')
echo
echo ${GREEN}
echo "------------------------------"
echo " Installing prerequisites "
echo "------------------------------"
echo
View R.rb
def tickets
case
when filters.excel
range_tickets
when filters.avia_offset.present? == false
range_tickets[0..24]
when filters.from_postsale
range_tickets[0...filters.avia_offset]
else
range_tickets[filters.avia_offset..filters.avia_offset + 9] || []
@drymar
drymar / migration.rb
Created Apr 11, 2017 — forked from matfiz/migration.rb
Reversible change_column Rails migration
View migration.rb
reversible do |dir|
dir.up { change_column :posts, :name, :text }
dir.down { change_column :posts, :name, :string }
end
View nokogiri_example.rb
require 'open-uri'
require 'nokogiri'
def words
uri = 'http://www.languagedaily.com/learn-german/vocabulary/common-german-words'
html = open(uri)
doc = Nokogiri::HTML(html)
germans = doc.css('td.bigLetter')
View links.rb
View example.json
{
"request": {
"airline": {
"requestedCode": "PS",
"fsCode": "PS"
},
"flight": {
"requested": "777",
"interpreted": "777"
},
View contr.rb
class TicketsController < ApplicationController
respond_to? :js
def index
form = TicketFormValidator.new(form_params)
if form.valid?
@ticket = ticket_service(form.pnr_number)
@pnr = form.pnr_number
if @ticket.is_a? String
flash.now[:error] = @ticket
@drymar
drymar / savon_client.rb
Created Jul 3, 2016 — forked from hoverlover/savon_client.rb
Using my forks of Akami and Savon to sign a request with a X.509 certificate. See https://github.com/genuitytech/akami and https://github.com/genuitytech/savon.
View savon_client.rb
client = Savon::Client.new do
# This can be a URL also
wsdl.document = "/Path/to/your.wsdl"
# These are optional, only if your WSDL sucks :)
wsdl.endpoint = "https://your_endpoint"
wsdl.namespace = "http://your_namespace"
certs = Akami::WSSE::Certs.new :cert_file => "/path/to/cert.crt", :private_key_file => "/path/to/private/key.pem", :private_key_password => "password"
wsse.sign_with = Akami::WSSE::Signature.new certs
You can’t perform that action at this time.