Skip to content

Instantly share code, notes, and snippets.

View hrom512's full-sized avatar

Roman Khrebtov hrom512

View GitHub Profile
@hrom512
hrom512 / ffmpeg.sh
Created August 6, 2024 15:44
Download m3u8 from website
# view info about format
ffmpeg -i https://my.com/my.m3u8
# save audio/video to file
ffmpeg -i https://my.com/my.m3u8 -c copy out.mp4
ffmpeg -i https://my.com/my.m3u8 -c copy out.flac
@hrom512
hrom512 / fix_keyboard.sh
Created May 25, 2021 08:33
Remap keys on MacOS for European keyboard
# https://developer.apple.com/library/archive/technotes/tn2450/_index.html
# 0xE1 - Left Shift
# 0x35 - ` and ~
# 0x64 - § and ±
# ± => ~
# ~ => left shift
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x7000000E1},{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'
@hrom512
hrom512 / autoload_dotenv.sh
Created January 17, 2021 15:37
Autoload .env
source_env() {
if [[ -f .env ]]; then
source .env
fi
}
autoload -U add-zsh-hook
add-zsh-hook chpwd source_env
source_env
@hrom512
hrom512 / ractor_workers.rb
Created October 18, 2020 15:55
Ruby 3.0 Ractor example
scheduler =
Ractor.new do
loop do
Ractor.yield Ractor.recv
end
end
workers =
8.times.map do |i|
Ractor.new(scheduler, Ractor.current) do |r_input, r_output|
@hrom512
hrom512 / thread_pool.rb
Created July 2, 2020 17:24
Multi-thread processing
class ThreadPool
attr_reader :pool_size, :queue_size, :block
def initialize(pool_size:, queue_size:, &block)
@pool_size = pool_size
@queue_size = queue_size
@block = block
pool
end
@hrom512
hrom512 / github_fixed_width.css
Last active July 3, 2020 08:27
Custom CSS for Github
/* возвращаем github к фиксированной ширине */
.js-header-wrapper {
background-color: #24292e;
}
header.Header {
padding-left: 16px;
}
@hrom512
hrom512 / kubectl.rb
Last active April 10, 2020 15:08
Kubernetes - kubectl helper
#!/usr/bin/env ruby
# frozen_string_literal: true
# .zshrc
# alias k="~/kubectl.rb"
# Usage:
# k prod/my_app get pods
# k prod.my_app get pods
# k prod get pods
@hrom512
hrom512 / vcr.rb
Last active February 12, 2021 14:49
VCR tips
VCR_COMMON_HEADERS = %w[Content-Type Accept Accept-Encoding Authorization].freeze
VCR.configure do |config|
common_headers_proc = ->(request) { request.headers.slice(*VCR_COMMON_HEADERS) }
config.register_request_matcher :common_headers do |request1, request2|
common_headers_proc[request1] == common_headers_proc[request2]
end
# https://github.com/vcr/vcr/blob/master/features/request_matching/README.md
config.default_cassette_options = {
@hrom512
hrom512 / migrations_helper.rb
Last active April 4, 2018 08:22
Rails migrations: add column with default to large tables
module MigrationsHelper
# Usage:
# include MigrationsHelper
# disable_ddl_transaction!
#
# def up
# add_column_with_default :articles, :priority, :float, default: 1.0, null: false
# end
#
# def down
@hrom512
hrom512 / translations.md
Last active May 29, 2017 11:46
Правила перевода

Информация для переводчиков

1. Спец. символы

Неразрывный пробел: \_

Примеры:

route_info: "Информация о\_рейсе"
title: "Билеты на\_автобус"