Skip to content

Instantly share code, notes, and snippets.

View StanAngeloff's full-sized avatar

Stan Angeloff StanAngeloff

View GitHub Profile
<?php
// [..snip..]
$this->participantRepositoryFactory
->forTenant(
$this->getTenantIdFromOAuthClient($client)
)
->persist(
$participant
@StanAngeloff
StanAngeloff / ClassTest.php
Created March 4, 2015 09:04
Using annotations to control input for PHPUnit test cases
<?php
final class ClassTest extends \PHPUnit_Framework_TestCase
{
# [..]
/**
* {@inheritdoc}
*/
protected function runTest()
<?php
/**
* (c) PSP UK Group Ltd. <hello@psp-group.co.uk>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code.
*/
namespace Psp\Bundle\PspFrameworkBundle\DependencyInjection\Compiler;
QueueOrderEvidenceCollectionHandler (subscribes to 'order.paid' event)
-> push OrderEvidenceCollectionJob to queue (Resque)
-> worker pulls OrderEvidenceCollectionJob from queue
-> publish CollectOrderEvidenceCommand over command bus (RabbitMQ)
-> let handler perform actual work and delegate to collectors
@StanAngeloff
StanAngeloff / eu-vat-moss.feature
Created January 12, 2015 16:09
EU VAT regulations compliance example
@payment @tax
Feature: EU VAT regulations compliance
In order to be compliant with the new EU VAT regulations
As a Developer
I need to be able to charge different VAT rates depending on the country of origin
Background:
Given the following products exist:
| name | model | price | tax |
| ASUS MeMO Pad | ASUS:ME176C | £99.00 | 20% |
The MIT License (MIT)
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

Redundancy and Fail-over

MySQL

Master-Master in Active-Passive Mode

Two MySQL servers, each replicating data to the other. Any INSERT, UPDATE, etc. operations are transmitted over the network to the other instance. The two servers are local to each node and only the primary node gets all the HTTP/s connections. This is done so we can ensure only one web server accepts connections and writes to its local MySQL database.

Any change gets written to active server's binary log and flows through replication to the passive server's relay log. The passive server executes the query and writes the event to its own binary log, because the option log_slave_updates is enabled. The active server then retrieves the same change via replication into its own relay log, but ignores it because the server ID in the event matches its own.

@StanAngeloff
StanAngeloff / Makefile
Last active October 11, 2022 19:37
Generate RabbitMQ self-signed certificate authority, server and client certificates.
# See http://www.rabbitmq.com/ssl.html
#
# (c) Stan Angeloff / http://www.gnu.org/licenses/agpl-3.0.html
SHELL := /bin/bash
HOSTNAME ?= $(shell hostname)
PASSPHRASE ?= $(shell cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
PASSPHRASE_FILE = $(HOSTNAME)/.passphrase
SELECT "log"."audit"->>'entity' "entity", "log"."audit"->>'requestId' "requestId", "log".*
FROM "audit_log" "log"
WHERE ("log"."audit"->>'requestId') IS NOT NULL AND NOT EXISTS (
SELECT 1
FROM "audit_log" "log2"
WHERE ("log2"."audit"->>'requestId')::numeric = (("log"."audit"->>'requestId')::numeric - 1)
AND ("log2"."audit"->>'entity') = ("log"."audit"->>'entity')
)
ORDER BY "log"."audit"->>'entity' ASC, "log"."date_logged" ASC
@StanAngeloff
StanAngeloff / rsync_example.sh
Created September 1, 2014 15:12
Copying modified files from a remote host in a path with spaces using rsync.
# Copying modified files from a remote host in a path with spaces using rsync.
# NOTE: spaces are double-escaped, e.g., '\\ '.
$ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null user@hostname -- find /remote/path\\ to\\ files/ -type f -ctime -365 -print0 | \
rsync -avz --progress -e "ssh -C -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -0 --files-from=- user@hostname:/ ./local/path/