Skip to content

Instantly share code, notes, and snippets.

View IFilonov's full-sized avatar
🏠
Working from home

Igor IFilonov

🏠
Working from home
View GitHub Profile
== profile by cpu
require 'stackprof'
profile = StackProf.run(mode: :wall, raw: true) do
process(period: period, search_query: ['toDate(created_at) BETWEEN ? AND ?', period&.begin, period&.end])
end
File.write('stackprof.json', JSON.generate(profile))
# Go to https://www.speedscope.app/
db:migrate runs (single) migrations that have not run yet.
db:create creates the database
db:drop deletes the database
db:schema:load creates tables and columns within the existing database following schema.rb. This will delete existing data.
db:setup does db:create, db:schema:load, db:seed
@IFilonov
IFilonov / gist:876b8e4e122af42c9b19f227ba0737dc
Last active April 4, 2023 07:48
Install commands Ubuntu
Ubuntu
sudo apt-get install language-pack-ru --установка русской локали
sudo apt-get install firefox-locale-ru -- русский для firefox
sudo apt install numix-gtk-theme numix-icon-theme --установка темы Numix
sudo apt install unity-tweak-tool --для управления темой и расширенными настройками
-- Установка расширения VirtualBox GuestAddtion
sudo apt-get install virtualbox-guest-additions-iso
--environment variables --
Rspec example:
describe Class, type: :service do
let(a) { build(:a) }
let!(b) { build_stubbed(:b) }
let!(c) { create(:c) }
before do
VCR.turn_off!
WebMock.enable!
anc_desc= {}
ObjectSpace.each_object(Class).select{ |x| x < Object }.each{ |c| anc_desc[c.name] = c.superclass.name if c.name && c.superclass.name }
File.open'result.dot', 'w' do |file|
file.puts %Q(digraph "Ruby#{RUBY_VERSION}" {\n)
file.puts %Q(node [shape=box];\n edge [arrowtail="empty", dir=back];\n)
anc_desc.each.sort_by { |desc, anc| anc + desc }.each{ |desc, anc| file.puts %Q("#{anc}" -> "#{desc}";\n)}
#anc_desc.each{|desc, anc|file.puts%Q("#{anc}" -> "#{desc}";\n)}
file.puts'}';
end
system 'dot -Tsvg result.dot -o ruby.svg'
# frozen_string_literal: true
namespace :routes do
desc 'Поиск неприкрытых авторизацией роутов'
task list_all_routes: :environment do
controllers_actions = []
controllers_actions << { controller: 'Контроллер',
action: 'Метод',
verb: 'Глагол',
path: 'Путь',