Skip to content

Instantly share code, notes, and snippets.

View Evshved's full-sized avatar
🌬️
Yes Yes No. I grabbed the wind.

Eugene Shved Evshved

🌬️
Yes Yes No. I grabbed the wind.
View GitHub Profile
@kmayer
kmayer / fizzbuzz.rb
Last active March 13, 2017 03:55
FizzBuzz to 100 in one line of (very compact) ruby. And other variants
# How to use and experiment
# $ irb -I. -rfizzbuzz
# => fb = FizzBuzz.new
# => fb.enumerator_with_array_indices.take(30) == FizzBuzz.EXPECTATIONS
# => true
class FizzBuzz
EXPECTATIONS=[1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz", 16, 17, "Fizz", 19, "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26, "Fizz", 28, 29, "FizzBuzz"]
def shortest # 100 chars of ruby
@iansheridan
iansheridan / closures.rb
Created July 7, 2014 15:27
A demonstration of Ruby closures by Paul Cantrell
# CLOSURES IN RUBY Paul Cantrell http://innig.net
# Email: username "cantrell", domain name "pobox.com"
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
# A closure is a block of code which meets three criteria:
#
class User < ActiveRecord::Base
# keep the default scope first (if any)
default_scope { where(active: true) }
# constants come up next
COLORS = %w(red green blue)
# afterwards we put attr related macros
attr_accessor :formatted_date_of_birth
1. Знание основ Ruby, фреймворка Ruby on Rails
- http://guides.rubyonrails.org/
- http://rusrails.ru/
Вопросы:
1. Чем отличается статическая и динамическая типизации в языках программирования?
2. Какие виды наследования поддерживаются в Ruby?
3. Что такое модуль? Какая разница между классом и модулем?
4. Какие есть уровни контроля доступа к методам для классов и модулей?
5. Какие есть способы вызова методов в Ruby?
6. Что означает ключевое слово self?
@leopoldodonnell
leopoldodonnell / Readme.md
Last active July 14, 2024 20:34
Install and run Postgres with an extension using docker-compose

Local Postgres

This gist is an example of how you can simply install and run and extended Postgres using docker-compose. It assumes that you have docker and docker-compose installed and running on your workstation.

Install

  • Requires docker and docker-compose
  • Clone via http: git clone https://gist.github.com/b0b7e06943bd389560184d948bdc2d5b.git
  • Make load-extensions.sh executable
  • Build the image: docker-compose build