This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In Gemfile... | |
gem 'virtus' | |
gem 'validates' # custom email validations | |
# In app/types/user_sign_in_type.rb | |
class UserSignInType | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
include Virtus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Install Postgres 9.2 on a clean Ubuntu 12.04 | |
""" | |
LC_ALL issue | |
comment out the AcceptEnv LANG LC_* line in the remote /etc/ssh/sshd_config file. | |
sudo apt-get install language-pack-en-base | |
sudo dpkg-reconfigure locales | |
comment out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveBtnTemplate(url) { | |
return ( | |
'<div class="fl_l"> \ | |
<div class="play_btn_wrap" target="_blank"><a href="' + url + '">Скачать</a></div> \ | |
</div>' | |
); | |
} | |
function arrangeRow(row) { | |
var info = row.querySelector('.info'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getClickHandler(handler) { | |
return function(e) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
handler(e); | |
} | |
} | |
function bindClickHandlers(el) { | |
el.addEventListener('click', getClickHandler(function(e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scaleworks.DATA.surveyMonkey("GET", "surveys/73476772/responses/bulk", { fetch_all: true }, function(r) { | |
console.log(r) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_dependency 'app/models/ability' | |
require_dependency 'app/models/staff/unit' | |
class AssignTopcallAbilitiesToProperTeams < ActiveRecord::Migration[6.0] # rubocop:disable Style/Documentation | |
extend Memoist | |
class MigrationStaffTeam < ActiveRecord::Base # rubocop:disable Style/Documentation | |
self.table_name = :staff_units | |
self.ignored_columns = %w[type] | |
db_belongs_to :ability, class_name: 'Migrations::Ability' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zlib' | |
module ConsistentHashing | |
class Point | |
attr_accessor :prev, :next, :hash_key, :value | |
def initialize(value:, hash_key:) | |
@value = value | |
@hash_key = hash_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple LRU Cache written in Ruby | |
class LinkedList | |
class Node | |
attr_accessor :key, :value, :next, :prev | |
def set(key: nil, value: nil) | |
@key = key if key | |
@value = value if value | |
end |