Skip to content

Instantly share code, notes, and snippets.

View hungtrinh's full-sized avatar

Hưng Trịnh hungtrinh

  • Ha Noi, Viet Nam
  • 08:50 (UTC +07:00)
View GitHub Profile
@hungtrinh
hungtrinh / discountRateByMembershipType.php
Created November 3, 2019 15:05
minimal production code for first requirement
<?php
function discountRateByMembershipType ($membershipType) {
if ('platinum' === $membershipType) return 0.15;
}
@hungtrinh
hungtrinh / testSuiteDiscountRateByMembershipType.php
Last active November 3, 2019 15:21
second specification, second requirement, business rule for gold customer
<?php
function test_with_gold_member_will_discount_ten_percent() {
if ( 0.1 === discountRateByMembershipType('gold') {
echo 'Test Done';
} else {
echo 'Test Fail';
}
}
//... code test_with_platinum_member_will_discount_fifteen_percent here
@hungtrinh
hungtrinh / discountRateByMembershipType.php
Created November 3, 2019 15:30
minimal production code pass business rule for 'platinum', 'gold' customer
<?php
function discountRateByMembershipType ($membershipType) {
if ('platinum' === $membershipType) return 0.15;
if ('gold' === $membershipType) return 0.1;
}
@hungtrinh
hungtrinh / discountRateByMembershipType.php
Created November 3, 2019 16:00
Final Production Code (Testable)
<?php
function discountRateByMembershipType ($membershipType) {
if ('platinum' === $membershipType) return 0.15;
if ('gold' === $membershipType) return 0.1;
if ('silver' === $membershipType) return 0.05;
throw new UnexpectedValueException('invalid membership type');
}
@hungtrinh
hungtrinh / .gitlab-ci.yml
Created May 12, 2020 10:39 — forked from jlis/.gitlab-ci.yml
AWS ECS and ECR deployment via Docker and Gitlab CI
image: docker:latest
variables:
REPOSITORY_URL: <AWS ACCOUNT ID>.dkr.ecr.eu-central-1.amazonaws.com/<ECS REPOSITORY NAME>
REGION: eu-central-1
TASK_DEFINTION_NAME: <TASK DEFINITION NAME>
CLUSTER_NAME: <CLUSTER NAME>
SERVICE_NAME: <SERVICE NAME>
services:
@hungtrinh
hungtrinh / composer.md
Created May 21, 2020 14:56 — forked from xeoncross/composer.md
How composer actually works

Composer

the missing quick-start guide

We will assume we have a package/project called https://github.com/foo/bar

Most redistributable packages are hosted on a version control website such as Github or Bitbucket. Version control repositories often have a tagging system where we can define stable versions of our application. For example with git we can use the command:

git tag -a 1.0.0 -m 'First version.'

With this we have created version 1.0.0 of our application. This is a stable release which people can depend on. If we wanted to include "foo/bar" then we could create a composer.json and specify the tagged release we wanted: