Skip to content

Instantly share code, notes, and snippets.

View appkr's full-sized avatar
🎯
Focusing

appkr appkr

🎯
Focusing
View GitHub Profile
@appkr
appkr / CQS_and_CQRS.cs
Created July 1, 2017 11:34 — forked from kellabyte/CQS_and_CQRS.cs
CQS_and_CQRS
// CQS (Command-Query Separation)
// Bertrand Meyer devised the CQS principle
// It states that every method should either be a command that performs an action, or a
// query that returns data to the caller, but not both. In other words, asking a question
// should not change the answer. More formally, methods should return a value only if they
// are referentially transparent and hence possess no side effects.
//
// Example:
public class CustomerService
@appkr
appkr / gist:4156bc20a921e4a3f7181042b3f1a83b
Created July 4, 2017 16:13 — forked from SzymonPobiega/gist:5220595
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@appkr
appkr / understanding_mysql_lock.sql
Created July 6, 2017 04:59
Understanding MySql Lock
-- 테스트 테이블 생성
CREATE TABLE messages (
id INT AUTO_INCREMENT PRIMARY KEY,
message VARCHAR(140)
) ENGINE=INNODB;
SHOW TABLE STATUS WHERE NAME = "messages";
@appkr
appkr / 00install_php_modules.config
Last active July 7, 2017 08:17
Install PHP Modules on AWS EB PHP7 Base Image
files:
/opt/elasticbeanstalk/hooks/appdeploy/pre/03_install_php_modules.sh:
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
set -xe
@appkr
appkr / install-docker-master.sh
Created July 9, 2017 15:10 — forked from alexellis/install-docker-master.sh
install docker engine for swarm3k on Ubuntu 16.04. 2 options for installing
#!/bin/sh
# option 2: paste this into user-data to automate install via boot script
# NOTE: update --label=owner=YOURNAME below if you want to easily identify yours
# renames the host to have a suffix of alexellisio
export original=$(cat /etc/hostname)
sudo hostname $original-master-alexellisio
echo $original-master-alexellisio | sudo tee /etc/hostname
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
@appkr
appkr / Dockerfile
Created July 14, 2017 06:47
Dockerfile for static website
# ------------------------------------------------------------------------------
# Dockerfile for a static website
# ------------------------------------------------------------------------------
FROM nginx:alpine
# ------------------------------------------------------------------------------
# Add source to the docker image
# ------------------------------------------------------------------------------
@appkr
appkr / template.rb
Last active July 20, 2017 02:43
RoR Docker template
generate(:scaffold, "post", "title:string", "body:text")
file 'config/database.yml', <<-CODE
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: db
username: <%= ENV.fetch('MYSQL_USER') %>
password: <%= ENV.fetch('MYSQL_PASSWORD') %>
@appkr
appkr / post.sh
Last active July 25, 2017 09:20
Apache Bench Post
ab -p "$(PWD)/delivery.json" \
-T "application/json" \
-H "Accept: application/json" \
-H "Authorization: bearer header.payload.signature" \
-c 10 -n 100 -v -r -l \
http://127.0.0.1/mpos/v1/stores/10/deliveries
@appkr
appkr / Facade.php
Created August 1, 2017 01:34 — forked from SuoXC/Facade.php
simple service locator + Facade(like in Laravel) implementation
<?php
class Facade{
private static $service = null;
public static function getKey(){
return 'world';
}
public static function __callstatic($method,$args){
if(!isset(self::$service)){
self::$service = ServiceLocator::getInstance()->getService(self::getKey());
}
@appkr
appkr / request_parallely.php
Created August 1, 2017 01:36 — forked from SuoXC/request_parallely.php
use php curl_multi_* to perform http requests
<?php
interface HandleIterator {
public function getNextHandle();
public function dataCallback($data);
}
class IndexHandleIterator implements HandleIterator{
private $curl;
private $count;
public function __construct(){
$this->curl = curl_init("http://localhost/index.php");