Skip to content

Instantly share code, notes, and snippets.

View hakuno's full-sized avatar

Seiji 誠 次 hakuno

  • Brazil
  • 06:28 (UTC -03:00)
View GitHub Profile
@hakuno
hakuno / Laravel-Container.md
Created July 3, 2018 22:04
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

<?php
namespace App\Http\Controllers;
use Symfony\Component\HttpFoundation\BinaryFileResponse; // http://api.symfony.com/4.0/Symfony/Component/HttpFoundation/BinaryFileResponse.html
use Symfony\Component\HttpFoundation\File\Stream; // https://api.symfony.com/3.4/Symfony/Component/HttpFoundation/File/Stream.html
use SplFileObject;
use Exception;
// https://symfony.com/doc/current/components/http_foundation.html
It's useful whenever your lastest version of Fedora has no Docker on its repository.
For instance, Fedora 30 had no Docker (stable) available when released.
Then, you can go with the test version.
Prepare
sudo dnf -y update
sudo dnf -y install dnf-plugins-core
@hakuno
hakuno / update-minikube.sh
Last active June 7, 2019 12:32
Fedora Minikube Setup & Start with KVM2
#!/bin/bash
if ! [ -x "$(command -v docker)" ]
then
echo "⛔ Oh, my Gosh! You don't even have Docker on it."
exit 1;
else
sudo systemctl start docker
fi
if [ "$(egrep --color 'vmx|svm' /proc/cpuinfo)" == "" ]
@hakuno
hakuno / app.php
Created June 10, 2019 14:13
Lumen disables putenv
<?php
require_once __DIR__.'/../vendor/autoload.php';
// Look for
// https://github.com/laravel/lumen/pull/132
// PoC
// Illuminate\Support\Env::disablePutenv();
@hakuno
hakuno / gist:08af35c10f72b1945371a86b1cee4e31
Last active August 14, 2019 20:38
Notes on Zabbix setup
*LOCALHOST|TEST PURPOSE ONLY*
# Exemplo 2
# Ou exemplo "Docker Compose"
https://www.zabbix.com/documentation/3.0/manual/installation/containers
# Link'em all
docker network create zabbix
# Banco de dados
Determinado usuário Linux tem "blank screen" após login.
sudo find . -type f -name "*displays*"
mv ~/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml ~/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml.bak
sudo reboot
OU
mv $(sudo find . -type f -name "*displays*") /opt/displays.xml.bak
@hakuno
hakuno / gist:c820364ec86619031867c9e907248023
Last active June 4, 2020 16:23
Make sure iptables and conntrack don't interfere with our traffic
Example
client$ iptables -I INPUT 1 --src 192.168.254.0/24 -j ACCEPT
client$ iptables -t raw -I PREROUTING 1 --src 192.168.254.0/24 -j NOTRACK
server$ iptables -I INPUT 1 --src 192.168.254.0/24 -j ACCEPT
server$ iptables -t raw -I PREROUTING 1 --src 192.168.254.0/24 -j NOTRACK
Example
receiver$ iptables -I INPUT 1 -p udp --dport 4321 -j ACCEPT
receiver$ iptables -t raw -I PREROUTING 1 -p udp --dport 4321 -j NOTRACK
@hakuno
hakuno / .makefile
Created November 12, 2020 17:42
Run Ansible Playbook in .makefile
# I found at https://dreisbach.us/articles/simple-ansible-makefile/
# Replace this
# ansible-playbook -i hosts --vault-password-file=.vault-password.txt site.yml
# For this
tags = $(subst roles/,,$(wildcard roles/*))
.PHONY: all $(tags)
all:
ansible-playbook -i hosts --vault-password-file=.vault-password.txt site.yml
$(tags):
@hakuno
hakuno / Dockerfile
Created November 18, 2020 18:18
Alpine + iconv
# fix work iconv library with alphine
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php