Skip to content

Instantly share code, notes, and snippets.

View zhum's full-sized avatar

Zhumatiy Sergey zhum

View GitHub Profile
@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
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 / 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
@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 / 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

Summary

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

Ущерб

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

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

@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
@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:

# TURN OFF HDMI if not in use
# Get the current video output type and strip away the unimportant bits
video="$(tvservice -s | sed "s/^.*\[\([^ ]*\) .*$/\1/" )"
if [ "$video" != "HDMI" ]; then
printf "HDMI not detected. Turning off.\n"
tvservice -off > /dev/null
else
printf "HDMI detected.\n"
fi
@zhum
zhum / Gemfile
Created March 21, 2018 08:03
rom test for dynamic class
source 'https://rubygems.org'
gem 'rom'
gem 'rom-sql'
gem 'rom-yaml', '2.0.0.rc2'
gem 'sqlite3'