Skip to content

Instantly share code, notes, and snippets.

View sergey-alekseev's full-sized avatar
🇺🇦
#StandWithUkraine

Sergey Alekseev sergey-alekseev

🇺🇦
#StandWithUkraine
View GitHub Profile
@henrik
henrik / hash_deep_diff.rb
Created July 14, 2009 08:38
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@kinopyo
kinopyo / gist:2426829
Created April 20, 2012 07:23
Ruby: Get module name or class name without module
n = Notification::Answer.new
n.class.name.split('::').last || ''
# => "Answer"
n.class.name.split('::').first || ''
# => "Notification"
@jwo
jwo / mysql.database.yml
Last active March 28, 2024 15:32
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
@ryansobol
ryansobol / gist:5252653
Last active November 22, 2023 11:53
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.

@briarsweetbriar
briarsweetbriar / README.md
Last active December 16, 2015 22:28 — forked from linjunpop/README.md
@matthewrobertson
matthewrobertson / base_serializer.rb
Last active June 14, 2016 07:16
A simple pattern for creating classes that encapsulate JSON serialization logic. Simply inherit from the `BaseSerializer` and override the hook methods as necessary.
# An abstract base class used to create simple serializers
# for ActiveRecord objects
class BaseSerializer
include Rails.application.routes.url_helpers
attr_reader :serialized_object
def initialize(serialized_object)
@serialized_object = serialized_object
end
@MitinPavel
MitinPavel / ruby_digest
Created March 24, 2014 06:53
Ruby дайджест #N
Привет всем.
Хочу продолжить [хорошее начинание](http://dou.ua/lenta/digests/ruby-digest-0/). Вот моя версия того, на что должен посмотреть новичок в Ruby и рельсах.
Первые книги
------------
* [Practical Object-Oriented Design in Ruby: An Agile Primer](http://www.poodr.com/) by Sandi Metz - Отличная книга об объектно-ориентированном дизайне и связанных с ним аспектах. Автор рассматривает плюсы и минусы различных подходов, говорит о тестирование.
* [Agile Web Development with Rails 4](http://pragprog.com/book/rails4/agile-web-development-with-rails-4) by Sam Ruby, Dave Thomas and David Heinemeier Hansson - Новый Завет Rails от самого автора религии.
@timurkhafizov
timurkhafizov / rails_admin.ru.yml
Last active October 11, 2016 22:03 — forked from ramusus/rails_admin.ru.yml
Русская локализация для гема `rails_admin`. Форк со старого перевода. Исправлены грамматические и стилистические ошибки.
# Russian. Updated 2014-04-01
ru:
admin:
js:
true: 'True'
false: 'False'
is_present: 'Не пустое'
is_blank: 'Пустое'
date: 'Дата ...'
@jamesmartin
jamesmartin / application_controller.rb
Created May 25, 2015 01:47
Testing ApplicationController before_filter methods using RSpec's "anonymous" controller instance
class ApplicationController < ActionControllerBase
helper :do_something
def do_something
@from_do_something = params[:for_do_something]
end
end
@wvengen
wvengen / README.md
Last active March 25, 2024 07:53
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the