Skip to content

Instantly share code, notes, and snippets.

@japicoder
japicoder / mount_qcow2.md
Created July 1, 2021 15:37 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@japicoder
japicoder / ExtendedTemplateProcessor.php
Last active March 28, 2023 05:34
ExtendedTemplateProcessor class for PHPOffice/PHPWord that updates the relationships for links.
<?php
namespace App\Utils;
use PhpOffice\PhpWord\Element\Link;
use PhpOffice\PhpWord\Exception\Exception as PhpWordException;
use PhpOffice\PhpWord\TemplateProcessor;
class ExtendedTemplateProcessor extends TemplateProcessor
@japicoder
japicoder / RenderElementWrapper.php
Created July 12, 2018 14:00
Drupal 8 - How to wrap a webform managed file field
<?php
namespace Drupal\example;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides functionality to process render elements.
*/
class RenderElementWrapper {
@japicoder
japicoder / video-convert.sh
Created January 24, 2018 14:17
Convert all the MP4 mobile video of a folder to HEVC/M4V using ffmpeg
#!/bin/bash
DIR=`dirname $(readlink -f $0)`
HEVC_ACTIVE=1
for FILE in *.mp4; do
[ -f "$FILE" ] || break;
FILENAME=`basename $FILE .mp4`
if [[ $HEVC_ACTIVE = 1 ]]; then
@japicoder
japicoder / gist:6888124db2a5611c881cd8f763f5b454
Created September 6, 2017 14:35
Drupal 8 - How to retrive the profile of an user
/**
* The following example allows to obtain the profile of a given user.
*
* @param $user \Drupal\Core\Session\AccountInterface
* User or UserSession object.
* @param $profile_type string
* Bundle type of the profile.
static function getUserProfile(AccountInterface $user, $profile_type) {
$profile = $this->profile_storage->loadByUser($user, $profile_type);