Skip to content

Instantly share code, notes, and snippets.

View Enelar's full-sized avatar
💭
https://www.linkedin.com/in/offenso

Kirill Berezin Enelar

💭
https://www.linkedin.com/in/offenso
View GitHub Profile
@Enelar
Enelar / add-rbd-to-kvm.sh
Last active August 13, 2023 02:14
Add rbd pool to kvm
#!/bin/bash
# ChatGPT from https://blog.modest-destiny.com/posts/kvm-libvirt-add-ceph-rbd-pool/
# Allows adding multiple pools and use shared secret between them
# Define variables
VIRT_SCRT_PATH="/tmp/libvirt-secret.xml"
VIRT_POOL_PATH="/tmp/libvirt-rbd-pool.xml"
# Get script arguments
@Enelar
Enelar / to_promise.js
Created April 13, 2020 10:58
Quick to promise method
to_direct_promise(functor, ...args) {
return this.to_promise(functor, ...args, undefined);
}
to_promise(functor, ...args) {
const options = args.pop();
let resolve;
let reject;
const result = new Promise((res, cat) => {
resolve = res;
@Enelar
Enelar / shallow.compress.sh
Last active October 9, 2018 06:02
Shallow compress everything fastest possible way
nice -n 5 find * -maxdepth 0 -type d | parallel -j 1 "tar -cf {}.tar {} && pixz -9 {}.tar {}.txz && rm {}.tar"
@Enelar
Enelar / 20-graphics.conf
Created May 6, 2018 19:42
Arch flicker free ffmpeg screen capture
#etc/X11/xorg.conf.d/20-graphics.conf
Section "Device"
Identifier "Intel Graphics"
Driver "modesetting"
Option "AccelMethod" "glamor"
EndSection
@Enelar
Enelar / find_exceptions.sh
Created April 12, 2018 23:43
Find any catch block without _logger
rgrep -zoP "catch(?:.*){\n(?:.*\n){0,10}?(?:.*?(_logger)?.*\n)(?:.*\n){0,10}?.*}\n" | grep -aEvz "(.*.php).*(_logger).*?\n" | grep -aPo "(.*php)"
# catch (\Exception $e) {
# $this->_logger->critical($e);
# $message = __('An exception occurred while saving the address');
# $response = ['error' => 'true', 'message' => $message];
# }
@Enelar
Enelar / original_code.js
Created March 13, 2018 08:59
Is this so hard????
function initializeResizeEvents() {
jQuery('#select_size').on("change", function(event) {
var data = jQuery("#select_size option:selected").attr('resize-data');
window.productPrice.resize = '';
if (typeof(data) != 'undefined') {
if (data == 'custom') {} else {
data = eval('(' + data + ')');
window.productHeight = data.height;
window.productWidth = data.width;
}
@Enelar
Enelar / ucmp.php
Created March 5, 2018 08:23
Cleanest user compare function
function ucmp($a, $b)
{
$diff = $a - $b;
return ($diff > 0) - ($diff < 0);
}
usort([7,8,-1], "ucmp");
function you_get_the_idea($a, $b)
{
@Enelar
Enelar / self-signed-certificate-with-custom-ca.md
Created February 20, 2018 09:28 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@Enelar
Enelar / ffmpeg_hvec_vaapi.sh
Last active July 22, 2018 04:03
ffmpeg compress crf20
ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v hevc_vaapi output.mkv
#make sure that hvec profile is listed in vaapi command output
@Enelar
Enelar / postgres.array.parse.php
Created October 24, 2017 06:00
Parse PostgreSQL multidimensional array string
function RecursiveParse($text)
{
if (is_array($text))
{
$ret = [];
foreach ($text as $row)
$ret[] = RecursiveParse($row);
return $ret;
}