Skip to content

Instantly share code, notes, and snippets.

View coudenysj's full-sized avatar

Jachim Coudenys coudenysj

View GitHub Profile
@coudenysj
coudenysj / stats.php
Last active April 23, 2019 07:07
A small script to return PHP stats in JSON format
<?php
header('Content-Type: application/json');
echo json_encode(
[
'opcache' => opcache_get_status(),
'realpath_cache_size' => [
'configured' => ini_get('realpath_cache_size'),
'real' => realpath_cache_size(),
]
],
@coudenysj
coudenysj / Vagrantfile
Last active August 11, 2016 08:07
Running Ansible 2.0 in a Debian Vagrant box
Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
sudo echo "deb http://httpredir.debian.org/debian jessie-backports main contrib non-free" > /etc/apt/sources.list.d/jessie-backports.list
sudo apt-get update
sudo apt-get -t jessie-backports install ansible -y
ansible-playbook /vagrant/playbook.yml
SHELL
end
@coudenysj
coudenysj / DateTimeType.php
Last active February 22, 2016 12:40
Doctrine DateTimeType supporting MySQL fractional seconds
<?php
/**
* A custom type type for datetime(3) in MySQL.
*
* @see http://www.doctrine-project.org/jira/browse/DBAL-1084
*/
namespace My\Project\DBAL\Types;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
<?php
/**
* Create a PULL socket to receive print requests from the webserver.
* Create a PUB socket to send print requests to the windows laptop.
*/
$context = new ZMQContext();
$pub = $context->getSocket(ZMQ::SOCKET_PUB);
$pub->bind('tcp://*:5566');
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://*:5567');
@coudenysj
coudenysj / update.php
Created March 5, 2013 09:58
A small snippet that uses Zend\Db, but should create bind placeholder in the $query->where() instead of injecting the actual value.
<?php
$sql = new \Zend\Db\Sql\Sql($db, 'user');
$query = $sql->update();
$query->set(array('_update' => date('Y-m-d H:i:s')));
$query->where(array('userID' => 1));
$stmt = $sql->prepareStatementForSqlObject($query);
$stmt->execute(array('userID' => 1));
@coudenysj
coudenysj / config.log
Created November 29, 2012 07:46
brew install php54-memcached
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/php54-memcached/2.0.1 --with-php-config=/usr/local/Cellar/php54/5.4.9/bin/php-config --with-libmemcached-dir=/usr/local/Cellar/libmemcached/1.0.14
## --------- ##
## Platform. ##
@coudenysj
coudenysj / DatabaseTest.php
Created November 21, 2012 10:58
Using multiple databases in phpunit/dbunit with composer
/**
* Specific example for Zend Framework 1.0 applications (update the database "fetching")
*/
class DatabaseTest extends PHPUnit_Extensions_MultipleDatabase_TestCase
{
protected function getDatabaseConfigs()
{
$configs = array();
$options = $this->_application->getOptions();
$databases = $options['resources']['dbs'];
@coudenysj
coudenysj / config.log
Created June 12, 2012 12:55
brew install php53-gearman --HEAD
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/php53-gearman/HEAD --with-gearman=/usr/local/Cellar/gearman/0.33
## --------- ##
## Platform. ##
@coudenysj
coudenysj / ERD.png
Last active August 29, 2015 14:15
Using reStructuredText to generate an ERD
ERD.png