Skip to content

Instantly share code, notes, and snippets.

View pyaesone17's full-sized avatar

Nyan Win pyaesone17

View GitHub Profile
@pyaesone17
pyaesone17 / composition.php
Created November 26, 2017 09:57
Go lang struct composition implementation in PHP
<?php
class A {
public $dependencies = [];
public function __construct(...$arguments)
{
$this->dependencies = $arguments;
}
function file_get_contents_chunked($file,$chunk_size,$callback)
{
try
{
$handle = fopen($file, "r");
$i = 0;
while (!feof($handle))
{
call_user_func_array($callback,array(fread($handle,$chunk_size),&$handle,$i));
$i++;
<?php
class LogManager {
protected $logger;
public function __construct($logger) {
$this->logger = $loggervar;
}
public function log($msg, $level)
{
@pyaesone17
pyaesone17 / .php
Last active February 7, 2018 13:42
Queue
<?php
namespace App\Jobs;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
@pyaesone17
pyaesone17 / .php
Created February 7, 2018 14:02
route for queue
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
@pyaesone17
pyaesone17 / 1_kubernetes_on_macOS.md
Created July 10, 2018 18:31 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@pyaesone17
pyaesone17 / gist:0380ffa458741ce195e17ab361bb5709
Created September 7, 2018 06:39
Fan out Log writer in Go
f, err := os.OpenFile("bar.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
defer f.Close()
mw := io.MultiWriter(os.Stdout, f)
log.SetOutput(mw)