Skip to content

Instantly share code, notes, and snippets.

View alexeyfrank's full-sized avatar

Alexey Frank alexeyfrank

View GitHub Profile
# 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
require 'zlib'
module ConsistentHashing
class Point
attr_accessor :prev, :next, :hash_key, :value
def initialize(value:, hash_key:)
@value = value
@hash_key = hash_key
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'
Scaleworks.DATA.surveyMonkey("GET", "surveys/73476772/responses/bulk", { fetch_all: true }, function(r) {
console.log(r)
})
function getClickHandler(handler) {
return function(e) {
e.preventDefault();
e.stopPropagation();
handler(e);
}
}
function bindClickHandlers(el) {
el.addEventListener('click', getClickHandler(function(e) {
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');
#!/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.
@alexeyfrank
alexeyfrank / gist:4993376
Created February 20, 2013 06:18
Use Types in Rails for models validates
# 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