Skip to content

Instantly share code, notes, and snippets.

View aleksb86's full-sized avatar
🎯
Focusing

Aleksey aleksb86

🎯
Focusing
  • Russian federation
View GitHub Profile
@aleksb86
aleksb86 / vi_commands.txt
Last active September 14, 2020 09:41
VI shortcuts
To comment out blocks in vim:
press Esc (to leave editing or other mode)
hit ctrl+v (visual block mode)
use the ↑/↓ arrow keys to select lines you want (it won't highlight everything - it's OK!)
Shift+i (capital I)
insert the text you want, e.g. %
press EscEsc
To uncomment blocks in vim:
@aleksb86
aleksb86 / docker.txt
Created May 25, 2020 10:26
Docker shorthands
# удалить все images без тегов
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")
@aleksb86
aleksb86 / jsonb_quering.rb
Last active August 11, 2020 09:48
Quering with Active Record json fields (PostgreSQL)
Orchestrator::Models::Order.where("params ->> 'parent_order_id' = :id", id: '2403')
VmOrder.where("params -> 'os' ? :os", os: 'RHEL 7.6 x64').first
@aleksb86
aleksb86 / example.sh
Created March 11, 2020 16:06
Build and install gem
# in progect directory with *.gemspec file
$ gem build faraday.gemspec # - build, after that should be new file faraday-1.0.0.gem
$ gem install faraday-1.0.0.gem # - installation, source code changes will affect installed gem
@aleksb86
aleksb86 / settings.json
Last active January 29, 2020 10:13
VS Code minimal Ruby configuration
{
"ruby.rubocop.configFilePath": "/home/aleks/dev/event_maker/rubocop.yml",
"ruby.rubocop.useBundler": true,
"workbench.startupEditor": "newUntitledFile",
"emmet.includeLanguages": {
"erb": "html",
"html.erb": "html"
},
"editor.tabSize": 2,
"editor.renderWhitespace": "all"
@aleksb86
aleksb86 / docker-compose.yml
Last active December 9, 2019 15:52
Simple compose file for Postgresql
version: '3.7'
services:
db:
image: postgres:12.1-alpine
ports:
- '5432:5432'
volumes:
- ./data:/var/lib/postgresql/data
environment:
@aleksb86
aleksb86 / chmod.txt
Created June 2, 2019 20:52
Chmod for all files by path
find . -type d -exec chmod +rx {} \;
@aleksb86
aleksb86 / ror_mail_settings.rb
Created April 5, 2019 11:29
Gmail settings for RoR
# In application config file:
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'xyz@gmail.com',
password: 'yourpassword',
authentication: :plain,
enable_starttls_auto: true
}
@aleksb86
aleksb86 / example.js
Created March 11, 2019 21:16
IndexedDb async example
var indexDB = {};
indexDB.db = null;
indexDB.logger = function(err){ console.log(err); };
indexDB.dbUpgradeneeded = function(storeNames, e) {
storeNames.forEach(function(store) {
e.currentTarget.result.createObjectStore(store, { keyPath: "id"});
});
this.db = e.target.result;
};
indexDB.performDbOpen = function(e){
@aleksb86
aleksb86 / how_to_update_mapping_index_for_elasticsearch.md
Last active January 10, 2019 08:36
Обновление маппинга для конкретного индекса в эластике.

NB! Операция вызывает удаление индекса и хранящихся там данных. Вас предупредили..

  1. Удалить старый индекс: curl -XDELETE 'localhost:9200/sed_test_db_core_ws_documents'
  2. Создать маппинг для нового индекса (Внимание! большой запрос): curl -H 'Content-Type: application/json' -X PUT -d '{"mappings":{"data":{"pr_performance_official_id":{"type":"string"},"approving_performance_official_name":{"type":"string"},"archived":{"type":"boolean"},"attachment":{"type":"string"},"attachment_description":{"type":"string"},"canceled_person_id":{"type":"string"},"canceled_step_id":{"type":"string"},"canceled_text":{"type":"string"},"character":{"type":"string"},"character_s":{"type":"string"},"citizen_add_info":{"type":"string"},"citizen_answer_to_applicant":{"type":"boolean"},"citizen_answer_type":{"type":"string"},"citizen_audit_result":{"type":"string"},"citizen_audit_result_text":{"type":"string"},"citizen_audit_status":{"type":"string"},"citizen_audit_status_text":{"type":"string"},"citizen_book_date":{"type":"date",