Skip to content

Instantly share code, notes, and snippets.

View BackEndTea's full-sized avatar

Gert de Pagter BackEndTea

View GitHub Profile
@BackEndTea
BackEndTea / why.php
Last active May 30, 2020 21:05
Query busses dont make sense to me
<?php
final class FindUserByIdHandler
{
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
@BackEndTea
BackEndTea / unused.php
Last active February 11, 2020 08:56
Find unused dependencies in your composer.json
<?php
class Node
{
/** @var string */
public $name;
/** @var bool */
public $visited = false;
public function __construct(string $name)
<?php
use Psr\Log\LoggerInterface;
class LoggerInstance
{
private static $instance;
public static function instance(): LoggerInterface
{
if(self::$instance === null) {
@BackEndTea
BackEndTea / travis.yml
Created October 4, 2019 09:05
Allow composer to intall on nightly php
install:
- if [[ $TRAVIS_PHP_VERSION = nightly ]]; then export COMPOSER_FLAGS="--ignore-platform-reqs"; fi
- travis_retry composer update --prefer-dist $COMPOSER_FLAGS
@BackEndTea
BackEndTea / dddd.php
Last active October 4, 2019 08:43
Introducing the newest Laravel helper dddd, defecate dump debug and die
<?php
/**
* Uses https://flareapp.io/blog/1-introducing-ddd-a-new-global-helper-for-laravel
* But it gives you 10 minutes, so you have time to defecate first.
*/
if (!function_exists('dddd')) {
function dddd(...$arguments) {
sleep(600);
return ddd(...$arguments);
@BackEndTea
BackEndTea / sw_registration.js
Created April 24, 2018 07:37
Quick service worker registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js').then(
function (serviceWorkerRegistration) {
console.log('service worker has been registered, attempting to register push manager');
if (!('PushManager' in window)) {
console.log('This browser does not support push notifications');
return;
}
serviceWorkerRegistration.pushManager.subscribe().then(
function getRandomColor(){for(var o="#",n=0;n<6;n++)o+="0123456789ABCDEF"[Math.floor(16*Math.random())];return o}function setColor(){document.body.style.backgroundColor=getRandomColor()}document.body.innerHTML="",setInterval(setColor,0);
<?php
$days = ($month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year %400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31)); //returns days in the given month
@import "http://mal-image.appspot.com/all/fluffyyqt";
.animetitle {
display: inline-block;
font-weight: bold;
margin: 2px;
}
@BackEndTea
BackEndTea / MALrandom.js
Created April 24, 2017 13:45 — forked from IA21/MALrandom.js
picks random anime/manga from your MAL animelist/mangalist pages
// ==UserScript==
// @name MAL random
// @version 3
// @description picks random anime/manga from your MAL animelist/mangalist pages
// @author IA21
// @match https://myanimelist.net/mangalist/*
// @match https://myanimelist.net/animelist/*
// @grant none
// ==/UserScript==