Skip to content

Instantly share code, notes, and snippets.

View abratashov's full-sized avatar

Oleksandr Bratashov abratashov

  • Ukraine, Lviv
  • 16:04 (UTC +03:00)
View GitHub Profile
@abratashov
abratashov / active_record.rb
Last active September 9, 2019 14:36 — forked from jackrg/active_record.rb
Add bulk import functionality to Rails Active Record (add this file to config/initializers, call <model>.import!(array-of-record-hashes))
# frozen_string_literal: true
# Makes BULK INSERT for ActiveRecord rows
class ActiveRecord::Base
def import!(record_list, options = {})
batch_size = options[:batch_size] || 1000
raise ArgumentError "record_list not an Array of Hashes" unless valid_record_list?(record_list)
return record_list if record_list.empty?
record_list.each_slice(batch_size).each do |records|
@abratashov
abratashov / pergam.service
Last active January 25, 2018 23:17 — forked from arslan-gg/app_name.service
Simple systemd script to start Rails app with puma
[Unit]
Description=Puma HTTP Server
Requires=network.target
[Service]
Type=simple
User=deployer
WorkingDirectory=/home/deployer/apps/pergam/current
ExecStart=/bin/bash -lc 'bundle exec puma -C /home/deployer/apps/pergam/shared/puma.rb'
@abratashov
abratashov / gist:6f13df30ed54c1482f32247a25cff3f5
Created September 7, 2017 14:13 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@abratashov
abratashov / digital_ocean_setup.md
Last active June 8, 2020 19:14 — forked from ChuckJHardy/digital_ocean_setup.md
VPS Ubuntu 14.04(update to 16.04) x64 + Rails 4 + Nginx + Unicorn + MySQL + PostgreSQL + Capistrano 3 Setup Instructions