Skip to content

Instantly share code, notes, and snippets.

View appkr's full-sized avatar
🎯
Focusing

appkr appkr

🎯
Focusing
View GitHub Profile
@appkr
appkr / ProcessExecutor.php
Created August 1, 2017 01:39 — 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.
<?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 / config-php.json
Created September 11, 2017 08:51
mesh point api swagger generator php config
{
"variableNamingConvention": "camelCase",
"packagePath": "meshkorea/mesh-point-api",
"invokerPackage": "Mesh\\PointApi",
"modelPackage": "Model",
"apiPackage": "Service",
"srcBasePath": "src/",
"gitUserId": "meshkorea",
"gitRepoId": "mesh-point-api",
"composerVendorName": "meshkorea",
@appkr
appkr / gist:f4d990299f76303c2ad99934840abb5f
Created December 15, 2017 03:50 — forked from nostah/gist:d610459d50564c729c56
php swagger 2.0 api sample
<?php
use Swagger\Annotations as SWG;
/**
* @SWG\Swagger(
* basePath="/v1",
* host="api.local",
* schemes={"http"},
* produces={"application/json"},
@appkr
appkr / Laravel-Container.md
Created January 23, 2018 01:21
Laravel's Dependency Injection Container in Depth

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

@appkr
appkr / .php_cs
Last active February 11, 2018 08:36 — forked from jwage/.php_cs
php-cs-fixer git pre commit hook
<?php
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'protected_to_private' => false,
'mb_str_functions' =>true,
]);
@appkr
appkr / phpmd
Last active June 24, 2018 12:44
phpmd
$ wget -c http://static.phpmd.org/php/latest/phpmd.phar && mv ./phpmd.phar /usr/local/bin/phpmd
$ php -d allow_url_fopen=On -d detect_unicode=Off -d memory_limit=512M phpmd \
app,config,database \
html \
cleancode,codesize,controversial,naming,unusedcode \
--reportfile phpmd.html \
--suffixes php
@appkr
appkr / basic_command.md
Last active January 15, 2024 08:22
OpenAPI Generator (a.k.a. Swagger Codegen)
openapi-generator version
openapi-generator help
openapi-generator list
openapi-generator help generate
openapi-generator generate -g spring -i api.yml -o build/spring_server

openapi-generator generate -g php -i api.yml -o build/php_client
@appkr
appkr / curl.md
Created June 25, 2018 10:59
cURL error 77: error setting certificate verify locations

Problem

[2018-06-25 19:54:37] local.DEBUG: GuzzleHttp\Exception\RequestException: cURL error 77: error setting certificate verify locations:
  CAfile: /tmp/cacert.pem
  CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in /Users/appkr/meshkorea/korean-address-database-laravel/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:187

Docker

@appkr
appkr / ddl.sql
Last active July 6, 2018 07:41
Add a database user
-- as master user
CREATE USER 'TICKET'@'%' IDENTIFIED BY '************';
GRANT SELECT ON `prime`.`table` TO 'TICKET'@'%';
GRANT INSERT, UPDATE ON TABLE `prime`.`table` TO 'TICKET'@'%';
FLUSH PRIVILEGES;
-- as TICKET user
-- DO SOME DANGEROUS JOB
-- as master user
@appkr
appkr / recovery-process.md
Last active July 8, 2018 02:10
MacOS disaster recovery

Summary

  • the iMac in the home was always yelling to upgrade the OS version for a long time.
  • but I ignored the alert.
  • Today I had a spare time and saw that alert again. I pressed "upgrade" and I quickly realized that I was mad.
  • so I was panicked. Even though I cannot remember what I have tried though, it was apparent that problem was arose because of the new file system(APFS) adopted starting from High Sierra.
  • (deep sigh) myself should be blamed.