Skip to content

Instantly share code, notes, and snippets.

class QrCodeController < ApplicationController
include Magick
def generate(issue_id, voucher_id)
qrcode = RQRCode::QRCode.new("https://example.com/issues/#{issue_id}")
# NOTE: showing with default options specified explicitly
png = qrcode.as_png(
bit_depth: 1,
border_modules: 4,
@dmitryfry
dmitryfry / web-fonts-asset-pipeline.md
Created March 31, 2018 06:23 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@dmitryfry
dmitryfry / app.rb
Last active February 20, 2018 11:01
def merge(src, part)
src.map do |src_item|
new_item = src_item.dup
part.each do |part_item|
new_item.merge! part_item if part_item[:key] == src_item[:key]
end
new_item
end
end
@dmitryfry
dmitryfry / app.rb
Last active February 19, 2018 16:59
src = [
{key: 'key1', value: 'value1', data: 'data1'},
{key: 'key2', value: 'value2', data: 'data2'},
{key: 'key3', value: 'value3', data: 'data3'}]
part = [
{key: 'key3', data: 'new_data3'},
{key: 'key2', value: 'new_value2'}]
@dmitryfry
dmitryfry / books_list.txt
Created January 18, 2018 09:27 — forked from fedorkk/books_list.txt
Список книг для обучения
Алгоритмы:
1) Стивен Скиена "Алгоритмы. Руководство по разработке"
2) Томас Кормен "Алгоритмы. Построение и анализ"
3) Дональд Кнут "Искусство программирования" (никто в реальности не читал этот многотомный труд целиком...)
Общее:
1) Род Хаггарти "Дискретная математика для программистов"
2) Романовский И.В. "Дискретный анализ"
Паттерны проектирования:
<script>
$('.slider-for').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
nextArrow: '<i class="arrow-right"><%= image_tag("/right.gif", :class => "", :alt => "arrow right") %></i>',
prevArrow: '<i class="arrow-left"><%= image_tag("/left.gif", :class => "", :alt => "arrow left") %></i>',
fade: true,
asNavFor: '.slider-nav'
});
function scrollToTop(scrollDuration) {
var cosParameter = window.scrollY / 2,
scrollCount = 0,
oldTimestamp = performance.now();
function step (newTimestamp) {
scrollCount += Math.PI / (scrollDuration / (newTimestamp - oldTimestamp));
if (scrollCount >= Math.PI) window.scrollTo(0, 0);
if (window.scrollY === 0) return;
window.scrollTo(0, Math.round(cosParameter + cosParameter * Math.cos(scrollCount)));
oldTimestamp = newTimestamp;
1. Знание основ Ruby, фреймворка Ruby on Rails
- http://guides.rubyonrails.org/
- http://rusrails.ru/
Вопросы:
1. Чем отличается статическая и динамическая типизации в языках программирования?
2. Какие виды наследования поддерживаются в Ruby?
3. Что такое модуль? Какая разница между классом и модулем?
4. Какие есть уровни контроля доступа к методам для классов и модулей?
5. Какие есть способы вызова методов в Ruby?
6. Что означает ключевое слово self?