Skip to content

Instantly share code, notes, and snippets.


Berkay UNAL berkayunal

View GitHub Profile
View elasticsearch.monit
check process elasticsearch with pidfile /var/run/
start program = "/etc/init.d/elasticsearch start"
stop program = "/etc/init.d/elasticsearch stop"
if 5 restarts within 5 cycles then timeout
if failed host port 9200 type http then restart
berkayunal /
Created May 17, 2018 — forked from senko/
Watch current directory and execute a command if anything in it changes
# 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 <>
# Requires Linux, bash and inotifywait (from inotify-tools package).
# To avoid executing the command multiple times when a sequence of
berkayunal /
Created May 17, 2018 — forked from JGaudette/
MySQL Replication Health/Status
# 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
berkayunal / .phpstorm.meta.php
Created Mar 29, 2018
Enable autocomplete for CakePHP 3 in PhpStorm
View .phpstorm.meta.php
namespace PHPSTORM_META;
override(\Cake\ORM\TableRegistry::get(0), map(['' => '\App\Model\Table\@Table']));
berkayunal / ._ Loading variables from .env files in
Created Jan 16, 2018
Loading variables from .env files in Ansible
View ._ Loading variables from .env files in

Loading variables from .env files in Ansible

Ansible has various ways of looking up data from outside sources, including plain text password files, CSV files and INI files. But it doesn't seem to have a lookup for .env files, as used in Laravel projects, also available for PHP, Ruby, Node.js, Python and others.

One option is to launch Ansible with the Ruby dotenv command line script... But that requires Ruby, which seems like overkill to me.

So here is a simpler solution that I use. It consists of:

  1. The .env file itself
  2. A small shell script that loads the .env file into environment variables -
berkayunal /
Created Jan 16, 2018 — forked from davejamesmiller/
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 / web.php
Created Nov 15, 2017
Simple routing for Laravel test controllers
View web.php
* Routes
* Example:
* http://localhost/test/hello/me/param1/param2
* http://localhost/test/hello/there/param1/param2
berkayunal / Arch Linux, Fedora
Created Oct 17, 2017 — forked from elvetemedve/Arch Linux, Fedora
Allow Vagrant usage without providing sudo password
View Arch Linux, Fedora
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
berkayunal / pedantically_commented_playbook.yml
Created Oct 13, 2017 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
View pedantically_commented_playbook.yml
# ^^^ YAML documents must begin with the document separator "---"
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
berkayunal / Homestead.yaml
Created Oct 11, 2017 — forked from bubba-h57/Homestead.yaml for Homestead
View Homestead.yaml
- key: STS_USER
value: "<your name>"
- key: STS_HOME
value: "<your customized home dir>"
value: "<your key>"
value: "<your secret>"