Skip to content

Instantly share code, notes, and snippets.

View andriesss's full-sized avatar

Andriesss andriesss

  • Egeniq
  • Belgium
View GitHub Profile
@andriesss
andriesss / gist:2216166
Created March 27, 2012 14:06
make zend_log work with namespaces
Index: library/Zend/Log.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- library/Zend/Log.php (revision 5616)
+++ library/Zend/Log.php (revision )
@@ -260,6 +260,7 @@
$params = isset($config[ $type .'Params' ]) ? $config[ $type .'Params' ] : array();
@andriesss
andriesss / gist:2234809
Created March 29, 2012 08:09
Compiling PHP from source on Ubuntu
sudo apt-get install make gcc bison re2c libxpm-dev libxml2-dev libpcre3-dev libsqlite3-dev libcurl4-dev
sudo apt-get install libpng-dev libjpeg-dev libmysqlclient-dev
./configure \
--enable-embed \
--with-regex=php \
--with-xpm-dir=/usr \
--disable-rpath \
--disable-static \
--with-pic \
@andriesss
andriesss / Module.php
Created June 8, 2012 17:53
why are these methods not called?
<?php
namespace Passy;
use Zend\ModuleManager\ModuleManager,
Zend\EventManager\StaticEventManager,
Zend\Mvc\MvcEvent;
class Module
{
@andriesss
andriesss / gist:3216640
Created July 31, 2012 12:19
Conditional on duplicate key update
# A simple example which assumes you have an ENUM('auto', 'manual') column "override" in your table.
INSERT INTO
foo( id, baz, bar )
VALUES
( ?, ?, ? )
ON DUPLICATE KEY UPDATE
baz = IF(override = 'auto', VALUES( baz ), baz),
bar = IF(override = 'auto', VALUES( bar ), bar);
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application;
@andriesss
andriesss / gist:3756380
Created September 20, 2012 14:50
packing hex into binary, checking if bits are properly set
<?php
$bin = pack('C*', 0xFF, 0xFA, 0x2C, 0x32, 0xFF, 0xF0, 0xFF);
$hex = unpack('H*', $bin);
$hex = $hex[1];
echo "\nbinary: ";
$parts = explode(' ', chunk_split($hex, 2, ' '));
foreach ($parts as $part) {
if ($part) printf('%1$08s ', base_convert($part, 16, 2));
@andriesss
andriesss / gist:3783623
Created September 25, 2012 18:36
PHPUnit error with PHPunit_Selenium
<?php
class ReproduceTest extends \PHPUnit_Extensions_SeleniumTestCase
{
public function testFoo()
{
throw new \Exception();
}
}
@andriesss
andriesss / gist:3801483
Created September 28, 2012 18:45
Travelling Elephpant problem
<?php
class Tep
{
/**
* amount of landmarks available
* @var integer
*/
protected $lcount = 0;
<!-- this label used to have a for="plane_colors" tag -->
<label class="desc optional">Kleurenpalet</label>
<label><input name="plane_colors[]" id="plane_colors-1" value="1" type="checkbox">Wit (100, 100, 100)</label><br>
<label><input name="plane_colors[]" id="plane_colors-2" value="2" checked="checked" type="checkbox">Rood (100, 0, 0)</label><br>
<label><input name="plane_colors[]" id="plane_colors-3" value="3" checked="checked" type="checkbox">Geel (100, 100, 0)</label><br>
<label><input name="plane_colors[]" id="plane_colors-4" value="4" type="checkbox">Groen (0, 100, 0)</label><br>
<label><input name="plane_colors[]" id="plane_colors-5" value="5" type="checkbox">Blauw (0, 0, 100)</label><br>
<label><input name="plane_colors[]" id="plane_colors-6" value="6" type="checkbox">Fullcolor (-, -, -)</label></div></li>
<?php
namespace Anse\Xmpp;
use Anse\Xmpp\Message\MessageInterface;
class Stream
{
/**
* @var string