Skip to content

Instantly share code, notes, and snippets.

View skalibog's full-sized avatar
🇺🇦
Working from home

Edward Skalibog skalibog

🇺🇦
Working from home
View GitHub Profile
@skalibog
skalibog / application.rb
Created May 16, 2019 09:15
autoload lib
config.autoload_paths << Rails.root.join('lib')
config.autoload_paths += Dir["#{config.root}/lib/**/"]
@skalibog
skalibog / index.js
Created June 27, 2019 13:55
auto import global components
import Vue from 'vue'
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
const requireComponent = require.context(
'@/components', true, /\.vue$/
)
requireComponent.keys().forEach(fileName => {
const componentConfig = requireComponent(fileName)
# frozen_string_literal: true
class Rabbit
attr_accessor :status, :payload
def initialize(status, payload)
self.status = status
self.payload = payload
end
def call
# ruby 2.6.3
#
class Crypto
def initialize(method, string, count)
@method = method
@string = string
@count = count
end
# ruby 2.6.3
#
class Crypto
def initialize(method, string, count)
@method = method
@string = string
@count = count
end
def parse(text)
arr = text.split(/[,.!? ]/).reject(&:empty?)
a = arr.map(&:downcase).each_with_object(Hash.new(0)) do |k, v|
v[k] += 1
end
return [] if a.count < 3
p a.sort_by { |_, v| v }.reverse[0...3]
end
@skalibog
skalibog / snake.rb
Created August 28, 2019 08:10
Snake case modify
snake_case_modify = ->(string) { string.nil? ? nil : string&.gsub(/[^a-zA-Z]/, "_")&.downcase }
@skalibog
skalibog / db.rake
Last active November 10, 2020 11:28
custom seeds
namespace :db do namespace :seed do
Dir[Rails.root.join('db', 'seeds', '*.rb')].each do |filename|
task_name = File.basename(filename, '.rb')
desc "Seed #{task_name}, based on the file with the same name in `db/seeds/*.rb`"
task task_name.to_sym => :environment do
load(filename) if File.exist?(filename)
end
end
end
end
@skalibog
skalibog / rails.rb
Created March 2, 2020 14:25
rescue
rescue => error
Rails.logger.error(error)
Rails.logger.error(error.message)
Rails.logger.error(error.backtrace.join("\n"))
@skalibog
skalibog / sample_ssh.sh
Created April 6, 2020 14:35
Script for change github access
echo "=========================================="
echo "Set ssh id_rsa(sample desc)"
echo "=========================================="
git config --global --replace-all user.email "YOURNAME@gmail.com"
git config --global --replace-all user.name "GITHUB NAME"
echo "------------------------------------------"
echo "User creds"
git config --global user.email
git config --global user.name