Skip to content

Instantly share code, notes, and snippets.

View yakubenko's full-sized avatar
👽
Eat. Sleep. Code.

Stanislav Yakubenko yakubenko

👽
Eat. Sleep. Code.
View GitHub Profile
@yakubenko
yakubenko / Laravel-Container.md
Created August 18, 2021 09:31
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

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).

import 'dart:async';
class CounterBloc {
int _counter = 0;
final _stateController = StreamController<int>();
// This one goes to the StreamBuilder
Stream<int> get counterStream => _stateController.stream;
// This is one of posible modificators
@yakubenko
yakubenko / .eslintrc.json
Created January 11, 2019 06:01
ESLint config
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"parserOptions": {
"parser": "babel-eslint"
},
"extends": [
<!DOCTYPE html>
<html>
<head>
<?= $this->Html->charset() ?>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>
$this->fetch('title') ?>
</title>
<?php
return [
'inputContainer' => '<div class="form-group {{required}}">{{content}}<small class="form-text text-muted">{{help}}</small></div>',
'inputContainerError' => '<div class="form-group {{required}} error">{{content}}<small class="form-text text-muted">{{help}}</small>{{error}}</div>',
'error' => '<div class="invalid-field">{{content}}</div>',
'input' => '<input type="{{type}}" class="form-control" name="{{name}}"{{attrs}} />',
// 'checkbox' => '<input type="checkbox" class="form-check-input" name="{{name}}" value="{{value}}"{{attrs}}>',
'checkboxFormGroup' => '<div class="form-check">{{label}}</div>',
'checkboxWrapper' => '<div class="form-check">{{label}}</div>',
'nestingLabel' => '{{hidden}}{{input}}<label {{attrs}}>{{text}}</label>',
@yakubenko
yakubenko / myjs.js
Created June 27, 2018 07:01
JS gems
// get a string representation of the client's timezone
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone);
<?php
namespace App\Database\Type;
use Cake\Database\Driver;
use Cake\Database\Type;
class FileType extends Type
{
/**
* Marshalls flat data into PHP objects.
@yakubenko
yakubenko / geonames_postgres.rb
Created June 9, 2018 17:25 — forked from kaspergrubbe/geonames_postgres.rb
Import files from Geonames.com into a PostgreSQL database that runs Postgis
#!/usr/bin/env ruby
require 'open3'
require 'fileutils'
def run_command(command)
puts("+: " + command)
Open3.popen2e(command) do |stdin, stdout_stderr, wait_thread|
Thread.new do
stdout_stderr.each {|l| puts l }
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y nginx
RUN mkdir /var/www/app/
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y apache2
RUN apt-get install -y php php-common php-cli php-mysql php-curl \