Skip to content

Instantly share code, notes, and snippets.

View zhum's full-sized avatar

Zhumatiy Sergey zhum

View GitHub Profile
@zhum
zhum / ffmpeg.md
Created April 19, 2019 13:29 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@zhum
zhum / file_uploader.rb
Created July 10, 2019 06:18 — forked from DRBragg/file_uploader.rb
PDF Previews with carrierwave
class ItemUploader < CarrierWave::Uploader::Base
require 'carrierwave/orm/activerecord'
include CarrierWave::RMagick
if Rails.env.test?
storage :file
else
storage :fog
end

Summary

Опиши в 3-4 предложениях что происходило и почему. Это информативное представление о факапе с высоты птичьего полета, оно должно быть понятно любому человеку без контекста.

Ущерб

Качественная оценка Какая функциональность не работала, насколько долго, у кого. Была ли потеря или порча данных. Выбери поле справа.

Количественная оценка

@zhum
zhum / sqlite2pg.sh
Last active January 5, 2020 08:20 — forked from eclubb/sqlite2pg.sh
Script to import SQLite3 database into PostgreSQL
#!/bin/sh
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
SQLITE_DB_PATH=$1
PG_DB_NAME=$2
PG_USER_NAME=$3
@zhum
zhum / unslurm.rb
Created January 17, 2020 06:06
Unslurm
def interval prefix, str ,postfix
if /(\d+)-(\d+)/.match str
w="%0#{$1.size}d"
$1.to_i.upto($2.to_i).map {|i| "#{prefix}#{w % i}#{postfix}"}.join ','
else
"#{prefix}#{str}"
end
end
#
@zhum
zhum / xcat-install.sh
Created February 18, 2020 07:00 — forked from vlj91/xcat-install.sh
xCAT install (CentOS 7)
#!/bin/bash
cat << EOF > /etc/yum.repos.d/xCAT-core.repo
[xcat-2-core]
name=xCAT 2 Core packages
baseurl=http://xcat.org/files/xcat/repos/yum/2.13/xcat-core
enabled=1
gpgcheck=1
gpgkey=http://xcat.org/files/xcat/repos/yum/2.13/xcat-core/repodata/repomd.xml.key
EOF
module Comments
class ModelsList
if Rails.env.production?
def self.to_a
@@to_a ||= load
end
def self.to_a_labels
@@to_a_labels ||= to_a.map { |m| "#{m}|#{eval(m).model_name.human}"}
end
@zhum
zhum / bashscript-template.sh
Last active May 1, 2023 10:41
Bash script template with usefull things
#!/usr/bin/env bash
#
# YOUR DESCRIPTION HERE
#
#
# check it with https://www.shellcheck.net/
# set -e = FAIL if any command fails
# set -o pipefail = FAIL if any command in the pipe fails
# set -u = FAIL if any variable is used, but not initialized
@zhum
zhum / bash-cheatsheet.sh
Last active April 24, 2025 22:07
Bash script sheatsheet
#!/usr/bin/env bash
# latest version is here: https://gist.github.com/zhum/b00b6c55e0559d0684796191eecf21d9
# shellcheck disable=all
#-------------- options --------------
set -e # stop on any command fail
set -E # generate ERR exception on aliases, functions, and commands in if/while/until conditions
set -u # stop on any unbound variable
set -o pipefail # stop on any fail with pipe
user www-data;
worker_processes auto;
pid /run/nginx/nginx.pid; # only line changed from default
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}