Skip to content

Instantly share code, notes, and snippets.

View kelvinj's full-sized avatar

Kelvin Jones kelvinj

  • Bright Machine
  • Cheltenham, UK
View GitHub Profile
@bluescreen
bluescreen / BroadwayProjectionRebuilder.php
Created September 23, 2014 19:01
Broadway Projection Rebuild
<?php
/**
* Projection Rebuilder
* @author Markus Muschol <markus.muschol@gmx.de>
*/
use Broadway\Domain\DateTime;
use Broadway\Domain\DomainEventStream;
use Broadway\Domain\DomainMessage;
use Broadway\Domain\Metadata;
use Broadway\EventHandling\EventBusInterface;
@stivni
stivni / Basket.php
Last active August 29, 2015 14:03
EventCentric Business Rules
<?php
final class Basket implements RecordsEvents
{
private $basketCanOnlyContainFiveProducts;
private function __construct()
{
$this->basketCanOnlyContainFiveProducts = new BasketCanOnlyContainFiveProducts();
}
@fideloper
fideloper / install.sh
Last active October 30, 2023 20:03
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@JeffreyWay
JeffreyWay / challenge.md
Last active February 25, 2019 01:36
Laravel challenge / poll for book.

Challenge: you need a flexible (swap in other repository implementations) way to display some kind of resource. Let's say, Posts. What does your folder structure look like?

Requirements:

  • Repository implements an interface
  • Must show at least one implementation of the interface (Eloquent version is fine)
  • The interface is injected into your PostsController.
  • Show where you register your IoC bindings
  • Show folder structure. Where are interfaces/repositories stored?
<?php
interface Context {
public function execute($params);
}
@justinko
justinko / Plea.markdown
Created May 30, 2012 19:40
Am I doing it wrong?

Dear Rubyists,

I just lost a contract because of my code in a Rails project.

The specific code in question is related to a "posting a comment" feature. Here are the details:

In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.

The "senior developer", whom is the stake holder's right hand man, said this:

@mitchellh
mitchellh / gist:1277049
Created October 11, 2011 01:30
Configure Vagrant VM to use Host DNS for VPN
Vagrant::Config.run do |config|
# ...
config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
@dustincurrie
dustincurrie / elb.sh
Created August 18, 2011 06:18
Run a command on all instances attached to an AWS ELB
#!/bin/bash
# Runs a command on all instances attached to a load balancer
# Elastic Load Balancer Tools from http://aws.amazon.com/developertools/2536
ELB=prod-axs-aeg
COMMAND='service varnish restart'
INSTANCES=$(elb-describe-instance-health $ELB | awk -F " " '{print $2}')
@tinogomes
tinogomes / start_stop_memcached_script.sh
Created June 21, 2010 17:34
Script sample to start/stop for linux with nohup
#!/bin/bash
#
BASE=/tmp
PID=$BASE/app.pid
LOG=$BASE/app.log
ERROR=$BASE/app-error.log
PORT=11211
LISTEN_IP='0.0.0.0'
MEM_SIZE=4