Skip to content

Instantly share code, notes, and snippets.

@mikemadisonweb
mikemadisonweb / error_ini.php
Created September 3, 2014 14:08
Error reporting
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
header('Content-type: text/html; charset=utf-8');
print_r('<pre>');
var_dump();
exit();
<?php
if (array_key_exists('varShouldBeSet', get_defined_vars())) {
// variable $varShouldBeSet exists in current scope
}
// get a ConstraintViolationList
$errors = $this->get('validator')->validate( $user );
function add_querystring_var($url, $key, $value) {
$url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
$url = substr($url, 0, -1);
if (strpos($url, '?') === false) {
return ($url . '?' . $key . '=' . $value);
} else {
return ($url . '&' . $key . '=' . $value);
}
}
<?php
/**
* Проверка элементов массива на дубликаты
* @param $array
* @return boolean
*/
function arrayHasDuplicates($array) {
return count($array) !== count(array_unique($array));
}
{{ 'now'|date("Y") }}
@mikemadisonweb
mikemadisonweb / pedantically_commented_playbook.yml
Created July 17, 2016 11:19 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ 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.
@mikemadisonweb
mikemadisonweb / tailrecursion.php
Created July 19, 2016 06:44 — forked from beberlei/tailrecursion.php
PHP Tail Recursion
<?php
class TailRecursion
{
public $func;
public $acc;
public $recursing;
public function tail()
{
return call_user_func_array($this->func, func_get_args());

#Introduction If you're a php developer on ubuntu, there comes the time where you have to install/reinstall your system. I did it already a few times and i decided to write down the steps for a typical web developer stack with php. This is for a developer machine and not for a live environment!

I hope it helps you too!

fyi @mheiniger and me started with an installer here: https://github.com/mheiniger/webdev-setup