Skip to content

Instantly share code, notes, and snippets.

View vlasikhin's full-sized avatar
:octocat:

Pavel Vlasikhin vlasikhin

:octocat:
View GitHub Profile
#!/usr/bin/env ruby
# frozen_string_literal: true
require "net/http"
require "uri"
require "json"
require "logger"
require_relative "../config/environment"
@vlasikhin
vlasikhin / up.sh
Created November 28, 2023 18:56 — forked from milushov/up.sh
up.sh
#!/bin/bash
# Don't forget chmod +x up.sh
# Installation:
# brew install jq
#
# Define function in ~/.zshrc
# container_name() {
# docker ps --format "{{.Names}}" | grep "app-1"
#!/usr/bin/env ruby
# frozen_string_literal: true
require "net/http"
require "uri"
require "json"
require "logger"
require_relative "../config/environment"
@vlasikhin
vlasikhin / SIDEKIQ RUNIT.md
Created April 24, 2023 09:15 — forked from rusllonrails/SIDEKIQ RUNIT
SIDEKIQ RUNIT

sudo apt-get install runit

cd /etc/sv/ mkdir sidekiq cd sidekiq

nano run

#!/bin/sh
cd /home/deployer/application/current/
deploy 6774 0.0 0.0 4636 872 ? S Nov12 0:00 sh -c $HOME/code_update.sh > $HOME/output.log 2>&1 && athena start roepa.com_pl > log/roepa.com_pl.log 2>&1
deploy 6801 2.2 3.2 4881708 534460 ? Sl Nov12 16:08 \_ ruby /home/deploy/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bin/athena start roepa.com_pl
deploy 4563 0.0 0.5 34134700 98024 ? Sl Nov12 0:03 \_ /usr/bin/google-chrome --headless --disable-gpu --hide-scrollbars --mute-audio --enable-automation --disable-web-security --disable-session-crashe
deploy 4567 0.0 0.0 6328 828 ? S Nov12 0:00 | \_ cat
deploy 4568 0.0 0.0 0 0 ? Z Nov12 0:00 | \_ [cat] <defunct>
deploy 4575 0.0 0.3 33976376 55168 ? S Nov12 0:00 | \_ /opt/google/chrome/chrome --type=zygote --no-zygote-sandbox --headless --headless --crashpad-handler-pid=4570 --enable-crash-reporter
deploy 4594 0.0 0.3 34113196 63944 ? Sl Nov12 0:01 | | \_ /opt/g
{
"external_website": {
"url": "mh.chemistryrgconsulting.com"
},
"listing": {
"spec_set": {
"quantity": 2.0,
"intended use/discipline": "Biological Laboratory, Dental Laboratory",
"modified item": "No",
"country/region of manufacture": "Azerbaijan"
@vlasikhin
vlasikhin / convert_ruby_hash_string_to_json.rb
Created November 27, 2018 11:47 — forked from gene1wood/convert_ruby_hash_string_to_json.rb
A set of regex converstions to turn a ruby hash output string into a json parseable string
require 'json'
# Example ruby hash string which exercises all of the permutations of position and type
# See http://json.org/
ruby_hash_text='{"alpha"=>{"first second > third"=>"first second > third", "after comma > foo"=>:symbolvalue, "another after comma > foo"=>10}, "bravo"=>{:symbol=>:symbolvalue, :aftercomma=>10, :anotheraftercomma=>"first second > third"}, "charlie"=>{1=>10, 2=>"first second > third", 3=>:symbolvalue}, "delta"=>["first second > third", "after comma > foo"], "echo"=>[:symbol, :aftercomma], "foxtrot"=>[1, 2]}'
puts ruby_hash_text
# Transform object string symbols to quoted strings
ruby_hash_text.gsub!(/([{,]\s*):([^>\s]+)\s*=>/, '\1"\2"=>')
@vlasikhin
vlasikhin / example_activejob.rb
Created October 31, 2018 18:58 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
# сохраняем файл в корень проекта
# добавляем ссылку в гит:
# ln -s ../../rubocop_pre_commit_hook.rb .git/hooks/pre-commit
# проверяем добавился ли файл:
# ls -al .git/hooks/pre-commit
# должно быть что то типа:
# Aug 11 13:17 .git/hooks/pre-commit -> ../../rubocop_pre_commit_hook.rb
# даем права:
# chmod +x .git/hooks/pre-commit
# проверяем:

Тест "Пользователь"

  • Регистрация (отправка данных)
    • гостем
      • верных (зарегистрировать)
      • неверных (отказать)
    • пользователем (отказать)
  • Список пользователей
    • для гостя (отказать)
    • для зарегистрированого
  • корректный запрос (показать)