Skip to content

Instantly share code, notes, and snippets.

View smostovoy's full-sized avatar

Sergii Mostovyi smostovoy

View GitHub Profile
# frozen_string_literal: true
class BaseOperation
# DSL method to create wrapped operations with a transaction
# Creates both #some_action and #some_action! method versions
# A 'bang' version of a method does not process validation exceptions (to bubble up)
#
# All block arguments are converted to a method params
#
# Examples:
[user]
name = Sergey Mostovoy
email = svmostovoy@gmail.com
[color]
diff = auto
status = auto
branch = auto
[alias]
a = add
s = status
@smostovoy
smostovoy / homework.md
Last active February 26, 2016 13:17
homework.md

В данном задании мы поэтапно реализуем сайт электронных петиций, аналог https://petition.kievcity.gov.ua/, только базовый функционал. Сделайте форк (ссылка). В нем есть тесты которые должны проходить. (для частей 2-3 будут добавлены)

Часть 1

  • Создать главную страницу
  • Создать модель User
  • Создать форму регистрации. Пароль пользователя должен быть сохранен НЕ в откртытом виде.
  • Создать модель Petition
first_name: 'Cool',
last_name: 'Man',
gender: '?',
avatar: 'url',
title: "Software Developer",
email: "@gmail.com",
summary: '',
custom_fields: [
{custom_type_id: 1, value: 'some'}
],
@smostovoy
smostovoy / gist:2cc913f7397edf4415af
Created June 5, 2015 19:52
cicrcleci config for
#https://circleci.com/docs/parallel-manual-setup
test:

override:

- bundle exec rspec:

parallel: "if [ `git rev-parse --symbolic-full-name --abbrev-ref HEAD` != master ]; then echo true; else echo false; fi"
@smostovoy
smostovoy / keychain.gemspec
Last active August 29, 2015 14:05
Keychain - store service keys encrypted in rails config
Gem::Specification.new do |s|
s.name = "keychain"
s.files = ['keychain.rb']
s.require_path = '.'
s.version = '0.0.1'
s.add_runtime_dependency 'aes', '~> 0.5.0'
end
@smostovoy
smostovoy / gist:4963139
Created February 15, 2013 20:10
rbtrace
HelloWorld#response
............
HelloWorld#response <0.000274>
HelloWorld#response <0.009817>
HelloWorld#response <0.018580>
HelloWorld#response
HelloWorld#response
HelloWorld#response <0.002102>
HelloWorld#response <0.009876>
HelloWorld#response <0.016827>
@smostovoy
smostovoy / Gemfile
Last active December 13, 2015 17:58
investigate goliath performance issue
source 'https://rubygems.org'
gem 'goliath', :git =>'https://github.com/postrank-labs/goliath.git'
gem 'em-http-request'
gem 'redis'
gem "hiredis"
gem 'rbtrace'
gem 'rspec'
gem 'typhoeus'
gem 'faraday'
@smostovoy
smostovoy / hello.rb
Last active December 12, 2015 10:09
tracing issue with Goliath
require 'goliath'
require "rbtrace"
require 'em-synchrony'
require 'redis'
class HelloWorld < Goliath::API
def response(env)
Redis.new(driver: :synchrony, host: "127.0.0.1", port: 6379).ping
[200, {}, 'ok']
end
@smostovoy
smostovoy / gist:4636227
Created January 25, 2013 17:17
Rack/Grape MongodbLogger middleware for rails
class MongodbLogger::Rack
def initialize(app)
@app = app
end
def call(env)
log_attrs = {:method => env['REQUEST_METHOD'],
:action => env['PATH_INFO'],
:controller => 'API',
:path => env['PATH_INFO'],