Skip to content

Instantly share code, notes, and snippets.

View dkarlovi's full-sized avatar
🖌️
Moving bytes around.

Dalibor Karlović dkarlovi

🖌️
Moving bytes around.
View GitHub Profile
<?php declare(strict_types=1);
if (
extension_loaded( 'xdebug' )
&& version_compare( '2.6.0', phpversion( 'xdebug' ), '<=' )
)
{
/** @noinspection PhpUndefinedFunctionInspection */
/** @noinspection PhpUndefinedConstantInspection */
xdebug_set_filter(
@pulkitsinghal
pulkitsinghal / notes.md
Last active February 8, 2019 18:00
Loopback: How to log any errors via a global error handler?

Pitfalls

The REST adapter for strong-remoting sets up its own error handler! So you cannot accomplish this for REST API related calls by replacing:

  1. app.use(loopback.errorHandler()); in server/server.js
  2. or, loopback#errorHandler in middleware.json

So don't waste your time there.

Deeper Understanding

@romaricdrigon
romaricdrigon / docker-compose.override.yaml
Created August 27, 2020 14:36
Using Mutagen Compose
version: '3.7'
volumes:
appdata: ~
code: ~
services:
php:
volumes:
- code:/var/www/html
jobs:
strategy:
fail-fast: false
matrix:
chunk_count: [5]
chunk_number: [1, 2, 3, 4, 5]
env:
CHUNK_COUNT: ${{matrix.chunk_count}}
CHUNK_NUMBER: ${{matrix.chunk_number}}
@xenithorb
xenithorb / kmod-signer.sh
Last active November 16, 2021 07:49
Akmod kernel module auto-signer for kernel upgrades on Fedora
#!/bin/bash
#
# /etc/kernel/postinst.d script to sign akmods kmods after kernel upgrade
#
# Author: Michael Goodwin Date: 2016-09-21
# 1. Copy this script to /etc/kernel/postinst.d/ and `chmod +x` it
#
# 2. Create signing keys (store these somewhere useful and safe):
# $ mkdir -p /etc/pki/tls/private/mok
@jakzal
jakzal / QueueScraperTest.php
Last active September 28, 2022 14:55
RabbitMQ integration test
<?php
namespace Zalas\Infrastructure\Scraper;
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
use PhpAmqpLib\Connection\AbstractConnection;
use PhpAmqpLib\Connection\AMQPLazyConnection;
use PhpAmqpLib\Exception\AMQPTimeoutException;
@michelv
michelv / ConsecutiveCallsTrait.php
Last active March 2, 2023 15:07
Replacement for PHPUnit's deprecated method InvocationMocker::withConsecutive
<?php
declare(strict_types=1);
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\Constraint\Constraint;
/**
* This is a replacement for InvocationMocker::withConsecutive() which is
@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
@jerieljan
jerieljan / How I Do PlantUML.md
Last active January 1, 2024 06:23
PlantUML with Style -- How I do PlantUML

I use PlantUML a lot. It's what I use for drawing all sorts of diagrams and it's handy because of its easy markup (once you get used to it) while making things easy to maintain as projects grow (thanks to version control)

This gist explains how I do my PlantUML workspace in a project.

  • The idea is to keep a globals directory for all diagrams to follow (like the "stylesheet" below) to keep things consistent.
  • I use a stylesheet.iuml file that keeps the use of colors consistent through use of basic FOREGROUND, BACKGROUND and ACCENT colors.
  • The style-presets.iuml file defines these colors so you can make "presets" or "themes" out of them.
  • As stated in the stylesheet.iuml, you'll need the Roboto Condensed and Inconsolata fonts for these to work properly.
  • You can choose to either run the PlantUML jar over your file/s, or use an IDE like VSCode with the PlantUML extension. Here's a preview of example-sequence.puml for example: https://imgur.com/Klk3w2F
@jhass
jhass / 1-Yubikey_session_lock.md
Last active January 28, 2024 13:54
Lock (Gnome) session when removing Yubico U2F key

Setup

  1. Copy 99-u2f_lock_screen.rules to /etc/udev/rules.d.
  2. Copy gnome_lock_all_sessions to /usr/local/bin.
  3. Mark gnome_lock_all_sessions as executable: chmod +x /usr/local/bin/gnome_lock_all_sessions
  4. Reload udev: udevadm control -R