Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

appkr appkr

🎯
Focusing
View GitHub Profile
@appkr
appkr / JwtExampleTest.java
Created Feb 16, 2021 — forked from gimbimloki/JwtExampleTest.java
JWT Example (Sign, Verify and etc)
View JwtExampleTest.java
package com.nhn.jwt;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.ECDSAKeyProvider;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.ECDSASigner;
import com.nimbusds.jose.jwk.Curve;
View 0-CustomSerializationMain.java
package homo.efficio.json.jackson.custom.serialization;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import homo.efficio.json.jackson.custom.serialization.domain.CellPhone;
import homo.efficio.json.jackson.custom.serialization.domain.FamilyMember;
import homo.efficio.json.jackson.custom.serialization.domain.MobileVendor;
import homo.efficio.json.jackson.custom.serialization.serializer.CellPhoneSerializer;
import homo.efficio.json.jackson.custom.serialization.serializer.FamilyMemberSerializer;
@appkr
appkr / .php_cs
Last active Feb 11, 2018 — forked from jwage/.php_cs
php-cs-fixer git pre commit hook
View .php_cs
<?php
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'protected_to_private' => false,
'mb_str_functions' =>true,
]);
@appkr
appkr / Laravel-Container.md
Created Jan 23, 2018 — forked from davejamesmiller/Laravel-Container.md
Laravel's Dependency Injection Container in Depth
View Laravel-Container.md

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

View gist:f4d990299f76303c2ad99934840abb5f
<?php
use Swagger\Annotations as SWG;
/**
* @SWG\Swagger(
* basePath="/v1",
* host="api.local",
* schemes={"http"},
* produces={"application/json"},
@appkr
appkr / ProcessExecutor.php
Created Aug 1, 2017 — forked from SuoXC/ProcessExecutor.php
use anonymous function and an array of args to create a series of sub process to do the job,no need to care about process management api.
View ProcessExecutor.php
<?php
/**
* @example
*
* $a = new ProcessExecutor();
* $b = function ($arg){ sleep(1);echo "hello $arg\n"; };
* $a->setRunnables($b,['aaa','bbb']);
* $a->setCheckStatus(function($arg){return $arg === 'aaa';});
* $a->execute();
* var_dump($a->getRunStatusArr());
@appkr
appkr / request_parallely.php
Created Aug 1, 2017 — forked from SuoXC/request_parallely.php
use php curl_multi_* to perform http requests
View request_parallely.php
<?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");
@appkr
appkr / Facade.php
Created Aug 1, 2017 — forked from SuoXC/Facade.php
simple service locator + Facade(like in Laravel) implementation
View Facade.php
<?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 / install-docker-master.sh
Created Jul 9, 2017 — forked from alexellis/install-docker-master.sh
install docker engine for swarm3k on Ubuntu 16.04. 2 options for installing
View install-docker-master.sh
#!/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
View gist:4156bc20a921e4a3f7181042b3f1a83b

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