Skip to content

Instantly share code, notes, and snippets.

@DominikStyp
DominikStyp / test_routes.php
Last active March 30, 2022 13:28
Laravel: Test if request URI matches the route name (Unit Test)
<?php
namespace Tests\Feature\Controllers;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Request;
use Faker\Factory;
class SomeTestClass {
/**
@DominikStyp
DominikStyp / LogoutRoute.jsx
Last active April 8, 2022 15:55
React: custom route logout component
import { useEffect } from 'react';
import routes from '../../../domain/routes';
import { useHistory } from 'react-router-dom';
import { logoutAction } from 'redux/actions/authActions';
import { useStore } from 'react-redux';
const LogoutRoute = (props) => {
const store = useStore();
const history = useHistory();
@DominikStyp
DominikStyp / Logs.jsx
Created April 8, 2022 16:00
React: Laravel Log Viewer - How to load Laravel Logs Viewer in the Iframe in the React Component
import React, { useEffect, useState } from 'react';
import AxiosInstance from 'utils/services/AxiosInstance';
import Spinner from 'components/Common/Spinner';
const modifyHtml = (html) => {
const doc = document.createElement('html');
const script = document.createElement('script');
// we have to send the information to the parent which log file we want to load when we click it
script.innerHTML = `
function goToParent(href){
@DominikStyp
DominikStyp / deleteVersionTag.sh
Last active September 29, 2022 09:25
Git: composer package script to aumated release tag creation
#!/bin/bash
deleteTag=$1
if [ -z "$deleteTag" ]
then
echo "this scripts delete the remote and local git tag if it exists"
echo "example: $0 01.22.333"
exit 1;
fi
@DominikStyp
DominikStyp / guzzle_req_res_middleware.php
Created April 15, 2022 10:19 — forked from appkr/guzzle_req_res_middleware.php
Guzzle RequestResponseLog Middleware Example
<?php
namespace App\Providers;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Promise\PromiseInterface;
use Illuminate\Contracts\Foundation\Application;
@DominikStyp
DominikStyp / phpunit.xml
Created April 15, 2022 12:36
PHPUnit: Example configuration
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true">
@DominikStyp
DominikStyp / bubble.md
Created May 7, 2022 23:17 — forked from loilo/bubble.md
Make Vue events bubble

Make Vue events bubble

Vue events don't bubble the component tree on their own. However when writing wrapper components this can be the desired behaviour.

This code registers a global bubble directive which allows to re-emit all given events:

Let's say we want to bubble events start, accelerate and brake of our component Car.

Without any help, we'd roughly have to do this:

@DominikStyp
DominikStyp / dumpClosureInformation.php
Last active May 11, 2022 09:46
PHP: Dump Closure information for logging/debugging
<?php
class DumpClosureInformation {
/**
* Additional information about the closure we invoke - in log file
*
* @see https://stackoverflow.com/questions/25586109/view-a-php-closures-source
@DominikStyp
DominikStyp / exampleJSONPrettyPrintend.sh
Created May 11, 2022 11:00
JQ: Format JSON output using CURL + JQ
#!/bin/bash
output=`curl -vs -H "Accept: application/json" -v -s http://0.0.0.0:4010/Documents/1 2>&1`
echo $output | jq
@DominikStyp
DominikStyp / create_tables.sql
Last active May 20, 2022 23:36
SQL: MySQL Create tables with foreign keys and AUTO_INCREMENT
SET foreign_key_checks = 0;
DROP TABLE IF EXISTS `parent`;
DROP TABLE IF EXISTS `child_1`;
DROP TABLE IF EXISTS `child_2`;
SET foreign_key_checks = 1;
CREATE TABLE `parent` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)