This file contains 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
# Русский перевод для https://github.com/plataformatec/devise/tree/v1.4.2 | |
# Другие переводы на https://github.com/plataformatec/devise/wiki/I18n | |
ru: | |
errors: | |
messages: | |
expired: "устарела. Пожалуйста, запросите новую" | |
not_found: "не найдена" | |
already_confirmed: "уже подтверждена. Пожалуйста, попробуйте войти в систему" | |
not_locked: "не заблокирована" |
This file contains 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
# every 5 minutes run this script ↓ | |
*/12 * * * * /path/to/kill_memleaked_rails.sh |
This file contains 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
class Api::DelayedController < ApplicationController | |
# Public: Adds a delayed job into queue. | |
# | |
# params[:task] - The class name of the job. | |
# | |
def add | |
job = params[:task].constantize | |
Sidekiq::Client.enqueue job if Object.const_defined?(Sidekiq::Client) | |
Delayed::Job.enqueue job.new if Object.const_defined?(Delayed::Job) | |
render :text => "Background job queued", :status => :created |
This file contains 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
DELIMITER $$ | |
CREATE FUNCTION levenshtein( s1 VARCHAR(255), s2 VARCHAR(255) ) | |
RETURNS INT | |
DETERMINISTIC | |
BEGIN | |
DECLARE s1_len, s2_len, i, j, c, c_temp, cost INT; | |
DECLARE s1_char CHAR; | |
-- max strlen=255 | |
DECLARE cv0, cv1 VARBINARY(256); | |
SET s1_len = CHAR_LENGTH(s1), s2_len = CHAR_LENGTH(s2), cv1 = 0x00, j = 1, i = 1, c = 0; |
This file contains 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
class DropDelayedJobTable < ActiveRecord::Migration | |
def up | |
drop_table :delayed_jobs | |
end | |
def down | |
raise ActiveRecord::IrreversibleMigration | |
end | |
end |
This file contains 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
SET temp_buffers = 1000MB -- or whatever you can spare temporarily | |
CREATE TEMP TABLE tmp AS | |
SELECT t.* | |
FROM tbl t | |
LEFT JOIN del_list d USING (id) | |
WHERE d.id IS NULL; -- copy surviving rows into temporary table | |
TRUNCATE tbl; -- empty table - truncate is very fast for big tables |
This file contains 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
letters = Array('a'..'z') | |
shift = 3 | |
translation_map = letters.zip(letters.rotate(shift)).to_h | |
"hello".chars.map { |ch| translation_map[ch] }.join |