Word.destroy_all
WordMongo.destroy_all
Word.create(name: 'xа́е́x')
WordMongo.create(name: 'xа́е́x')
search = 'Xа́е́x'
pattern = /#{RegexpExtension.accent_insensitive_pattern Regexp.escape(search)}/
wm = WordMongo.where(name: pattern).first
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
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa | |
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa | |
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa |
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
#!/bin/sh | |
USER="example" | |
PASS="example" | |
USER_ROOT="/var/www/example.lv" | |
# fix "Authentication token manipulation error" error: | |
# https://www.codevoila.com/post/26/fix-authentication-token-manipulation-error-when-changing-user-password-in-ubuntu | |
sudo mount -rw -o remount / |
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
#!/bin/bash | |
# | |
# This script configures WordPress file permissions based on recommendations | |
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions | |
# | |
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org> | |
# | |
WP_OWNER=www-data # <-- wordpress owner | |
WP_GROUP=www-data # <-- wordpress group | |
WP_ROOT=$1 # <-- wordpress root directory |
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
unless File.exists?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
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
# Usage in model: | |
# | |
# validates :title, translation_presence: true, | |
# validates :title, translation_presence: {message: ''} | |
# | |
class TranslationPresenceValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
record.translations.each do |translation| | |
if translation[attribute].blank? |
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
# Usage in model: | |
# | |
# validates :title, translation_uniqueness: true # will assume it must be uniq across all languages | |
# validates :title, translation_uniqueness: {scope: :locale, message: ''} | |
# | |
class TranslationUniquenessValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
record.translations.each do |t| |
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
require 'capistrano-resque' |
- Windows 10 has 2 new services, SSH Server Proxy and SSH Server Broker which will already be bound to port 22
- Do not allow public connection on this rule, WSL is not proven safe
Add as cmd startup with bash.exe --login
sudo apt-get update && sudo apt-get upgrade -y
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
# lib/store_stylesheet.rb | |
class StoreStylesheet | |
def initialize(store) | |
@store = store | |
end | |
# The path of the compiled stylesheet, i.e. stores/id_timestamp.css | |
def stylesheet_file | |
filename = [ | |
@store.id, |
NewerOlder