Skip to content

Instantly share code, notes, and snippets.

@berarma
berarma / FirefoxHWAccel.md
Last active August 2, 2022 21:33
Settings for full video hardware acceleration for Firefox 103 on Debian 11 with Ryzen 5 5500U

Enable Hardware Video Acceleration with VA-API on Firefox and AMD GPU

Requirements

Tested with Firefox 103.1.

Use command vainfo to check supported codecs.

Use radeontop to check for AMD GPU usage.

Optimize JPEG/PNG images for the web using ImageMagick

convert -filter Triangle -define filter:support=2 -thumbnail %target-width% -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality %jpeg-quality% -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB original-image.jpg optimized-image.jpg

%target-width%: Width of the final image in pixels. %jpeg-quality%: JPEG quality setting (0-100).

@berarma
berarma / RefreshAssociationsTrait.php
Last active June 29, 2022 12:15
RefreshAssociationTrait for CakePHP3
<?php
namespace App\Model\Table;
use Cake\ORM\Entity;
trait RefreshAssociationsTrait
{
public function refreshAssociations(Entity $entity, array $associations = null)
{
if ($associations === null) {
@berarma
berarma / build_neovim_in_debian.markdown
Last active March 6, 2019 14:26
Neovim build instructions for Debian

This is what I had to do to build and install Neovim 0.3.4 with Python2 and Python3 support on Debian Stretch.

$ sudo apt install cmake libuv1-dev libmsgpack-dev libluajit-5.1-dev libunibilium-dev libtermkey-dev libvterm-dev libjemalloc-dev luajit lua-mpack gperf python3-pip

$ sudo pip2 install --upgrade pynvim

$ sudo pip3 install --upgrade pynvim

$ git clone neovim/neovim

@berarma
berarma / AssetsHelper.php
Created December 26, 2013 11:50
CakePHP helper class that extends AssetCompress.AssetCompress to inline CSS and JS.
<?php
App::uses('AssetCompress.AssetCompress', 'View/Helper');
class AssetsHelper extends AssetCompressHelper {
public function inlineCss($file, $options = array()) {
if (Configure::read('debug') > 0) {
return $this->css($file, $options);
}
$file = $this->_addExt($file, '.css');