Skip to content

Instantly share code, notes, and snippets.

View aleksb86's full-sized avatar
🎯
Focusing

Aleksey aleksb86

🎯
Focusing
View GitHub Profile
@aleksb86
aleksb86 / query_from_curl_to_elasticsearch
Created December 21, 2018 11:09
How to send query to elasticsearch (REST)
curl -XGET 'localhost:9200/sed_test_db_core_ws_documents/_search?pretty=true&q=id:5c1bbd4cb29a000003000001'
# sed_test_db_core_ws_documents - название индекса, в котором ищется
@aleksb86
aleksb86 / GIT_DEPLOY_TO_HEROKU.md
Created January 8, 2019 21:40
GIT Deploying Django (DRF) project to Heroku

Before you start - use virtualenv for isolated Python environment. This manual cant apply to Django project with static files (JS, CSS, images etc.) 0. You should to register to heroku.com

  1. Install Heroku CLI: curl https://cli-assets.heroku.com/install-ubuntu.sh | sh or quick install: curl https://cli-assets.heroku.com/install.sh | sh
  2. Create Django-rest-framework project, init git repository.
  3. $ heroku login
  4. $ heroku create [preferred_name_of_application]
  5. Create file runtime.txt (on same level that Django project directory and application directory) with content:
@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",
@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 / 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: '[email protected]',
password: 'yourpassword',
authentication: :plain,
enable_starttls_auto: true
}
@aleksb86
aleksb86 / chmod.txt
Created June 2, 2019 20:52
Chmod for all files by path
find . -type d -exec chmod +rx {} \;
@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 / 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 / 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 / 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