Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
@leemour
leemour / listen_ports.sh
Created December 14, 2018 17:08
Ubuntu network stat check ports listen
# sudo apt install net-tools
sudo netstat -ntlp | grep LISTEN
@leemour
leemour / .rubocop.yml
Last active December 3, 2018 11:06
Rubocop config
# inherit_from: .rubocop_todo.yml
AllCops:
# Default formatter will be used if no `-f/--format` option is given.
DefaultFormatter: fuubar
# Cop names are displayed in offense messages by default. Change behavior
# by overriding DisplayCopNames, or by giving the `--no-display-cop-names`
# option.
DisplayCopNames: true
# Style guide URLs are not displayed in offense messages by default. Change
@leemour
leemour / changelog.rake
Last active November 28, 2018 14:40 — forked from cdesch/rake task
Ruby git CHANGELOG generator
namespace :changelog do
# simple rake task to output a changelog between two commits, tags ...
# output is formatted simply, commits are grouped under each author name
#
desc "generate changelog with nice clean output"
task :generate, :since_c, :until_c do |t, args|
since_c = args[:since_c] || `git tag | head -1`.chomp
until_c = args[:until_c] || `git rev-parse --short HEAD`
cmd=`git log --pretty='format:%ci::%an <%ae>::%s::%H' --after=#{since_c} --before=#{until_c}`
@leemour
leemour / s3_folder_upload.rb
Last active January 22, 2021 14:26 — forked from fleveque/s3_folder_upload.rb
Upload folder to S3 recursively with ruby, multi threads and aws-sdk v3 gem
# frozen_string_literal: true
require 'rubygems'
require 'aws-sdk'
module S3
# Upload directory recursively to S3
class DirectoryUpload
attr_reader :folder_path, :bucket, :include_folder
attr_accessor :files
@leemour
leemour / where_is.rb
Created October 24, 2018 18:07 — forked from wtaysom/where_is.rb
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@leemour
leemour / optimize_png.sh
Created October 11, 2018 11:52
Optimize png images with pngquant and optipng
find . -name '*.png' -exec pngquant -ext .png -force 256 {} \;
find -type f -name "*.png" -exec optipng \-o2 \-strip all '{}' \;
@leemour
leemour / carrierwave_selectel.rb
Last active July 1, 2021 10:37
Carrierwave integration with Selectel using fog-openstack
CarrierWave.configure do |config|
if Rails.env.test? || Rails.env.cucumber?
config.storage = :file
config.enable_processing = false
else
config.asset_host = Rails.application.secrets.asset_host
config.fog_provider = 'fog/openstack'
config.fog_credentials = {
provider: 'OpenStack',
openstack_auth_url: 'https://api.selcdn.ru/v3',
@leemour
leemour / mass_delete_remote_branches.sh
Last active July 12, 2018 11:04
Mass delete multiple remote branches in git repository (and locally)
# Remote
git br -r | grep -v 'master\|dev\|new_front' | awk -Forigin/ '{print $2 $3}' | xargs -I {} git push origin :{}
# Local
git branch | grep -v 'master\|dev\|new_front' | xargs -I {} git branch -D {}
@leemour
leemour / reflections.rb
Last active June 28, 2018 02:58
Ruby reflections - find source location and source code
# Show method location
method(:meth).source_location
# Nice gem 'method_source' makes life easier. Use it inside console:
require 'method_source'
# Show method source
method(:meth).source.display
# Show class or method definition
show-source Job
show-source Job.work
@leemour
leemour / sass_convert.sh
Last active June 27, 2018 02:44 — forked from bds/gist:2207826
Convert files from .scss to .sass
sass-convert -F scss -T sass application_styles.css.scss application_styles.css.sass
# If you want convert folder recursively
sass-convert -R scss_folder -F scss -T sass