Skip to content

Instantly share code, notes, and snippets.

@berkayunal
berkayunal / nginx.conf
Created October 10, 2017 07:59 — forked from abpin/nginx.conf
nginx.conf File For ExpressionEngine or Codeigniter
server {
listen :80;
server_name www.example.com;
rewrite ^/(.*) http://example.com/$1 permanent;
}
server {
server_name example.com;
listen :80;
@berkayunal
berkayunal / after.sh
Created October 11, 2017 12:59 — forked from mewebstudio/after.sh
~/.homestead/after.sh
#!/usr/bin/env bash
# Populate this array with each of your dev site hostnames.
sites_hosts=( homestead.app ) # array, e.g., www.example.dev
# Config for SSL.
SSL_DIR="/etc/nginx/ssl"
PASSPHRASE="secret"
SUBJ="
C=BE
@berkayunal
berkayunal / Homestead.yaml
Created October 11, 2017 15:45 — forked from bubba-h57/Homestead.yaml
after.sh for Homestead
variables:
- key: STS_USER
value: "<your name>"
- key: STS_HOME
value: "<your customized home dir>"
- key: AWS_ACCESS_KEY_ID
value: "<your key>"
- key: AWS_SECRET_ACCESS_KEY
value: "<your secret>"
- key: AWS_DEFAULT_REGION
@berkayunal
berkayunal / Arch Linux, Fedora
Created October 17, 2017 11:42 — forked from elvetemedve/Arch Linux, Fedora
Allow Vagrant usage without providing sudo password
sudo tee /etc/sudoers.d/vagrant > /dev/null << EOL
#
# Arch Linux, Fedora sudoers entries
#
# Allow passwordless startup of Vagrant with vagrant-hostsupdater.
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts
%sudo ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE
@berkayunal
berkayunal / web.php
Created November 15, 2017 12:36
Simple routing for Laravel test controllers
<?php
/**
* Routes
*
* Example:
* http://localhost/test/hello/me/param1/param2
* http://localhost/test/hello/there/param1/param2
*/
@berkayunal
berkayunal / Laravel-Container.md
Created January 16, 2018 20:41
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

@berkayunal
berkayunal / .phpstorm.meta.php
Created March 29, 2018 12:48
Enable autocomplete for CakePHP 3 in PhpStorm
<?php
namespace PHPSTORM_META;
override(\Cake\ORM\TableRegistry::get(0), map(['' => '\App\Model\Table\@Table']));
@berkayunal
berkayunal / after.sh
Created October 11, 2017 13:10 — forked from truetamtam/after.sh
Laravel Homestead after.sh placed in ~/.homestead/after.sh
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
echo "Updating machine software"
locale-gen en_GB.UTF-8
# Updating composer
@berkayunal
berkayunal / mysql_repl_status.sh
Created May 17, 2018 18:08 — forked from JGaudette/mysql_repl_status.sh
MySQL Replication Health/Status
#!/bin/bash
#
# Determine if master and slave mysql servers are in sync
# If not, report it via STDOUT and non-zero return code
# If are in sync, exit successfully
#
# Paramters:
# -v - verbose, show stats even if 100% synchronized
USER='YOUR_USER_NAME'
@berkayunal
berkayunal / onchange.sh
Created May 17, 2018 18:12 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of