Skip to content

Instantly share code, notes, and snippets.

View mxr576's full-sized avatar

Dezső BICZÓ mxr576

View GitHub Profile
@mxr576
mxr576 / docker-compose.yml
Last active December 2, 2015 15:00
Build a completely dockerized environment for my Drupal based NewsFeeder project
# Configuration generated with Drupal Compose version 1.1.6
apache:
extends:
file: host.yml
service: apache
image: dockerizedrupal/apache-2.4:1.1.2
hostname: apache
ports:
- "80"
- "443"
@mxr576
mxr576 / index.php
Last active September 12, 2017 14:22
If you don't know the difference in PHP between the self and the static keywords, then here is a dummy example for you. https://3v4l.org/HBXAe
<?php
class Vehicle {
/**
* @var string
*/
private $name;
@mxr576
mxr576 / docker-cleanup.sh
Created March 6, 2016 16:02
Three useful aliases to clean-up after yourself #Docker
alias docker-cli="docker rmi $(docker images -qf dangling=true)"
alias docker-clc="docker rm -v $(docker ps -aqf status=exited)"
alias docker-clv="docker volume rm $(docker volume ls -qf dangling=true)"
@mxr576
mxr576 / iptables_rules.sh
Created December 28, 2016 19:02 — forked from virtualstaticvoid/iptables_rules.sh
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@mxr576
mxr576 / my_module.module
Last active March 6, 2017 10:31
Drupal: Search API : Provide default Search API server which configuration can be overridden with variables
<?php
/**
* Implements hook_default_search_api_server().
*/
function MY_MODULE_default_search_api_server() {
$items = [];
$host = variable_get('solr_search_api_host', 'localhost');
$scheme = variable_get('solr_search_api_scheme', 'http');
@mxr576
mxr576 / pass_by_reference_in_php.md
Last active September 8, 2017 19:19
Why you should not use pass by reference in PHP

First example

Run: https://3v4l.org/VV51q

<?php

$a = 1; $b = &$a; $b = 42; print $a;

This is pretty simple, isn't it?

@mxr576
mxr576 / oauth.php
Last active July 2, 2018 13:49
Apigee PHP API client OAuth test
<?php
require_once "vendor/autoload.php";
require_once "examples/authentication.inc";
$envCredProd = new EnvironmentCredentialProvider();
$auth = new \Apigee\Edge\HttpClient\Plugin\Authentication\Oauth($envCredProd->getUsername(), $envCredProd->getPassword(), new \Apigee\Edge\Tests\Test\HttpClient\Plugin\InMemoryOauthTokenStorage(), null, getenv('APIGEE_EDGE_PHP_SDK_CLIENT_ID') ?: null, getenv('APIGEE_EDGE_PHP_SDK_CLIENT_SECRET' ?: null), null, getenv('APIGEE_EDGE_PHP_SDK_AUTH_SERVER') ?: null);
$client = new \Apigee\Edge\Client($auth);
$envc = new \Apigee\Edge\Api\Management\Controller\EnvironmentController($envCredProd->getOrganization(), $client);
try {
@mxr576
mxr576 / apigee_edge_cleanup.php
Last active July 6, 2018 11:10
The Ultimate Apigee Edge clean up script in PHP - WARNING: Use it on your own risk!!!
<?php
require_once "vendor/autoload.php";
use GuzzleHttp\Client;
use GuzzleHttp\Promise;
$endpoint = getenv('APIGEE_EDGE_ENDPOINT') ?: 'https://api.enterprise.apigee.com/v1';
$org = getenv('APIGEE_EDGE_ORGANIZATION');
$client = new Client(['base_uri' => "{$endpoint}/o/{$org}/", 'auth' => [getenv('APIGEE_EDGE_USER'), getenv('APIGEE_EDGE_PASSWORD')]]);
@mxr576
mxr576 / benchmark.php
Created May 9, 2019 07:49
is_a() vs. reflection benchmark
<?php
$cnt = 10000000;
interface FooInterface {}
class BarClass implements FooInterface {
}
$x = 0;
@mxr576
mxr576 / ddd_cqrs_event-sourcing_in_php.md
Created January 31, 2021 11:15 — forked from jsor/ddd_cqrs_event-sourcing_in_php.md
DDD, CQRS and Event Sourcing in PHP

DDD, CQRS and Event Sourcing in PHP

  • Broadway - Infrastructure and testing helpers for creating CQRS and event sourced applications
  • EventCentric.Core - Event Sourcing and CQRS in PHP
  • LiteCQRS - Small convention based CQRS library for PHP
  • predaddy - Common DDD classes including an annotation driven message bus and tools for CQRS and Event Sourcing
  • ProophEventSourcing - Provides basic functionality for event-sourced aggregates
  • ProophEventStore - PHP 5.4+ EventStore Implementation
  • ProophServiceBus - PHP Enterprise Service Bus Implementation supporting CQRS and DDD