Skip to content

Instantly share code, notes, and snippets.

View gambala's full-sized avatar
🟢
Online

Vitaliy Emeliyantsev gambala

🟢
Online
View GitHub Profile
inherit_from: .rubocop_todo.yml
AllCops:
Exclude:
- 'bin/*'
- 'db/schema.rb'
- 'tmp/**/*'
- 'vendor/**/*'
RunRailsCops: true
Documentation:
Enabled: false
@gambala
gambala / pyramid.rb
Created July 11, 2016 08:36
Let's find minimal path in pyramid from top to bottom
class Pyramid
attr_accessor :layers_number
attr_accessor :layers
def initialize(layers_number, layers = [])
@layers_number = layers_number
@layers = layers
end
def populate_with_random_weights
@gambala
gambala / _form.slim
Created July 24, 2016 18:34
BootstrapFormBuilder
= form_for resource do |f|
= f.form_group :first_name do
= f.label :first_name, class: 'control-label'
= f.text_field :first_name, class: 'form-control'
= f.error_message :first_name
@gambala
gambala / example.scss
Created August 8, 2016 06:40
OOP-like CSS naming
// css/search-form.scss
.search-form {
> .field {
}
}
// css/search-form/iconic-button.scss
class PhrasesController < ApplicationController
def index
set_cookies
@phrases_left = avaible_ids(cookies[:showed_ph]).count
@phrases = Phrase.find(cookies_to_array(cookies[:showed_ph]))
end
def random_phrase
all_ids = avaible_ids(cookies[:showed_ph])
@phrases_left = all_ids.count - 1
@gambala
gambala / palindrom_searcher.rb
Last active September 6, 2016 20:15
Palindrom searcher class
class PalindromSearcher
attr_accessor :string
def initialize(string)
@string = string
end
def longest
return unless all.any?
all.max_by(&:length)
@gambala
gambala / trello.css
Created September 28, 2016 22:15
Gambala theme for Trello
/* webfont */
@import 'https://fonts.googleapis.com/css?family=Roboto';
body,
button,
html,
input,
select,
textarea {
@gambala
gambala / example.js
Created June 23, 2017 14:45
Params filter and formatter for fetch requests
import urlWithParams from 'urlWithParams'
fetch(
urlWithParams('/api/v1/cities.json', {
name: input,
city_id: this.state.cityID,
})
)
.then((response) => response.json())
.then((json) => {
@gambala
gambala / admin.slim
Created July 24, 2017 18:36
Redis::Objects use case
p = user.ip_addresses.size
p = user.ip_addresses.value
@gambala
gambala / rubocop.yml
Created July 27, 2017 10:16
Rubocop config
inherit_from: .rubocop_todo.yml
AllCops:
Exclude:
- 'bin/*'
- 'db/schema.rb'
- 'node_modules/**/*'
- 'vendor/**/*'
TargetRubyVersion: 2.4
Layout/IndentationConsistency:
EnforcedStyle: normal